/** Retrieve all newsletters
* @return An array of $id => NewsLetter objects
*/
- public static function getAll()
+ public static function getAll($sort = 'id', $order = 'ASC')
{
- $res = XDB::query('SELECT id
- FROM newsletters');
- $nls = array();
- foreach ($res->fetchColumn() as $id) {
- $nls[$id] = new NewsLetter($id);
- }
- return $nls;
+ $res = XDB::fetchAllAssoc('SELECT n.id, g.nom AS group_name, n.name, n.custom_css, n.criteria, g.diminutif AS group_link
+ FROM newsletters AS n
+ INNER JOIN groups AS g ON (n.group_id = g.id)
+ ORDER BY ' . $sort . ' ' . $order);
+ return $res;
}
// }}}
$this->id);
$ufc = new PFC_And($this->getRecipientsUFC(), new UFC_NLSubscribed($this->nl->id, $this->id), new UFC_HasValidEmail());
- $uf = new UserFilter($ufc, array(new UFO_IsAdmin(), new UFO_Uid()));
+ $uf = new UserFilter($ufc, array(new UFO_IsAdmin(true), new UFO_Uid()));
$limit = new PlLimit(self::BATCH_SIZE);
$global_sent = array();
}
foreach ($users as $user) {
if (array_key_exists($user->id(), $global_sent)) {
- Platal::kill('Sending the same newsletter issue ' . $this->id . ' to user ' . $user->id() . ' twice, something must be wrong.');
+ Platal::page()->kill('Sending the same newsletter issue ' . $this->id . ' to user ' . $user->id() . ' twice, something must be wrong.');
}
$sent[] = $user->id();
$global_sent[$user->id()] = true;