X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=7f1975c6bde36aa96be6fbd8ac2833264ee00a46;hb=47712f77e9718652c516c85cde99a58d142f67c9;hp=7944c7d09a7b0bec76ea0f86e0899eaf48bf7a6a;hpb=5289c142e04219cb8e846c86ccd9f5005d7d49e1;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 7944c7d..7f1975c 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -105,15 +105,13 @@ class NewsLetter /** 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; } // }}} @@ -1231,7 +1229,7 @@ class NLIssue $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(); @@ -1243,7 +1241,7 @@ class NLIssue } 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;