From 92ac93ec91a6e7b0f00fd21c6d19c31d46fe9f52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sun, 4 Nov 2012 20:20:56 +0100 Subject: [PATCH] Start using the new MailingList class. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- include/reminder/ml.inc.php | 16 ++++------------ include/reminder/promotion_ml.inc.php | 9 ++++----- include/validations/listes.inc.php | 9 +++++---- modules/lists.php | 3 ++- modules/register.php | 4 ++-- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/include/reminder/ml.inc.php b/include/reminder/ml.inc.php index 8244654..3701c9e 100644 --- a/include/reminder/ml.inc.php +++ b/include/reminder/ml.inc.php @@ -27,7 +27,6 @@ class ReminderMl extends Reminder case 'suscribe': S::assert_xsrf_token(); $subs = array_keys(Post::v('sub_ml')); - $current_domain = null; $res = XDB::iterRow("SELECT sub, domain FROM register_subs @@ -36,11 +35,8 @@ class ReminderMl extends Reminder S::i('uid')); while (list($sub, $domain) = $res->next()) { if (array_shift($subs) == "$sub@$domain") { - if ($domain != $current_domain) { - $current_domain = $domain; - } - $client = new MMList(S::user(), $domain); - $client->subscribe($sub); + $mlist = new MailingList($sub, $domain, S::user()); + $mlist->subscribe(); } } @@ -67,14 +63,10 @@ class ReminderMl extends Reminder WHERE uid = {?} AND type = 'list' ORDER BY domain", S::i('uid')); - $current_domain = null; $lists = array(); while (list($sub, $domain) = $res->next()) { - if ($current_domain != $domain) { - $current_domain = $domain; - $client = new MMList(S::user(), $domain); - } - list($details, ) = $client->get_members($sub); + $mlist = new MailingList($sub, $domain, S::user()); + list($details, ) = $mlist->getMembers(); $lists["$sub@$domain"] = $details; } $page->assign_by_ref('lists', $lists); diff --git a/include/reminder/promotion_ml.inc.php b/include/reminder/promotion_ml.inc.php index c311e13..8733fc7 100644 --- a/include/reminder/promotion_ml.inc.php +++ b/include/reminder/promotion_ml.inc.php @@ -31,8 +31,8 @@ class ReminderPromotionMl extends Reminder FROM groups WHERE diminutif = {?}', $user->id(), $user->profile()->yearPromo()); - $mmlist = new MMList($user); - $mmlist->subscribe('promo' . $user->profile()->yearPromo()); + $mlist = MailingList::promo($user->profile()->yearPromo(), $user); + $mlist->subscribe(): $this->UpdateOnYes(); break; @@ -80,10 +80,9 @@ class ReminderPromotionMl extends Reminder Reminder::MarkCandidateAsAccepted($user->id(), $candidate); } if ($mlCount == 0) { - $mmlist = new MMList($user); + $mlist = MailingList::promo($user->profile()->yearPromo(), $user); try { - $mmlist->get_members_limit('promo' + $user->profile()->yearPromo(), - 0, 0); + $mlist->getMembersLimit(0, 0); } catch (Exception $e) { return false; } diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index ef19a21..f4caad9 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -138,15 +138,16 @@ class ListeReq extends Validate array('ListsModule', 'no_login_callback')); $owners = User::getBulkForlifeEmails($this->owners, true, array('ListsModule', 'no_login_callback')); - $list = new MMList(S::user(), $this->domain); // Make sure we send a list (array_values) of unique (array_unique) // emails. $owners = array_values(array_unique($owners)); $members = array_values(array_unique($members)); - $success = $list->create_list($this->liste, utf8_decode($this->desc), $this->advertise, - $this->modlevel, $this->inslevel, - $owners, $members); + + $list = new MailingList($this->liste, $this->domain, S::user()); + $success = $list->create($this->desc, $this->advertise, + $this->modlevel, $this->inslevel, + $owners, $members); if ($success) { create_list($this->liste, $this->domain); } diff --git a/modules/lists.php b/modules/lists.php index 001a1da..346e55b 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -137,7 +137,8 @@ class ListsModule extends PLModule $promo = Post::i('promo_add'); if ($promo >= 1900 and $promo < 2100) { - $this->client->subscribe("promo$promo"); + $mlist = MailingList::promo($promo, S::user()); + $mlist->subscribe(); } else { $page->trigError("promo incorrecte, il faut une promo sur 4 chiffres."); } diff --git a/modules/register.php b/modules/register.php index 27478a1..70480c7 100644 --- a/modules/register.php +++ b/modules/register.php @@ -426,8 +426,8 @@ class RegisterModule extends PLModule VALUES ({?}, {?})', $uid, $asso_id); try { - $mmlist = new MMList($user); - $mmlist->subscribe("promo" . $yearpromo); + $mlist = MailingList::promo($yearpromo, $user); + $mlist->subscribe(); } catch (Exception $e) { PlErrorReport::report($e); $page->trigError("L'inscription à la liste promo" . $yearpromo . " a échouée."); -- 2.1.4