From 22c5024fa1ae6ca6462890e2da38921e76096a80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 8 Nov 2012 00:09:44 +0100 Subject: [PATCH] Get rid of the 'pass' argument to MailingList. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also default to S::user(). Signed-off-by: Raphaël Barrois --- include/mailinglist.inc.php | 21 ++++++++------------- include/reminder/ml.inc.php | 4 ++-- include/reminder/promotion_ml.inc.php | 4 ++-- include/validations/listes.inc.php | 2 +- modules/lists.php | 9 +++------ 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/include/mailinglist.inc.php b/include/mailinglist.inc.php index d2808c1..84cb526 100644 --- a/include/mailinglist.inc.php +++ b/include/mailinglist.inc.php @@ -28,24 +28,21 @@ class MailingList public $domain; // domain for the list protected $mmclient; // The XML-RPC client for Mailman requests - public function __construct($mbox, $domain, $user, $pass='') + public function __construct($mbox, $domain, $user=null) { $this->mbox = $mbox; $this->domain = $domain; $this->address = "$mbox@$domain"; - if ($user instanceof PlUser) { - $this->mmclient = new MMList($user, $this->domain); - } else { - $this->mmclient = new MMList($user, $pass, $this->domain); + if (is_null($user)) { + $user = S::user(); } + $this->mmclient = new MMList($user, $this->domain); } /** Instantiate a MailingList from its address. - * - * $user and $pass are connection parameters for MailMan. */ - public static function fromAddress($address, $user, $pass='') + public static function fromAddress($address, $user=null) { if (strstr($address, '@') !== false) { list($mbox, $domain) = explode('@', $address); @@ -54,18 +51,16 @@ class MailingList $mbox = $address; $domain = $globals->mail->domain; } - return new MailingList($mbox, $domain, $user, $pass); + return new MailingList($mbox, $domain, $user); } /** Retrieve the MailingList associated with a given promo. - * - * $user and $pass are connection parameters for MailMan. */ - public static function promo($promo, $user, $pass='') + public static function promo($promo, $user=null) { global $globals; $mail_domain = $globals->mail->domain; - return new MailingList('promo', "$promo.$mail_domain", $user, $pass); + return new MailingList('promo', "$promo.$mail_domain", $user); } const KIND_BOUNCE = 'bounces'; diff --git a/include/reminder/ml.inc.php b/include/reminder/ml.inc.php index 3701c9e..808fc3e 100644 --- a/include/reminder/ml.inc.php +++ b/include/reminder/ml.inc.php @@ -35,7 +35,7 @@ class ReminderMl extends Reminder S::i('uid')); while (list($sub, $domain) = $res->next()) { if (array_shift($subs) == "$sub@$domain") { - $mlist = new MailingList($sub, $domain, S::user()); + $mlist = new MailingList($sub, $domain); $mlist->subscribe(); } } @@ -65,7 +65,7 @@ class ReminderMl extends Reminder S::i('uid')); $lists = array(); while (list($sub, $domain) = $res->next()) { - $mlist = new MailingList($sub, $domain, S::user()); + $mlist = new MailingList($sub, $domain); list($details, ) = $mlist->getMembers(); $lists["$sub@$domain"] = $details; } diff --git a/include/reminder/promotion_ml.inc.php b/include/reminder/promotion_ml.inc.php index 8733fc7..ab8da38 100644 --- a/include/reminder/promotion_ml.inc.php +++ b/include/reminder/promotion_ml.inc.php @@ -31,7 +31,7 @@ class ReminderPromotionMl extends Reminder FROM groups WHERE diminutif = {?}', $user->id(), $user->profile()->yearPromo()); - $mlist = MailingList::promo($user->profile()->yearPromo(), $user); + $mlist = MailingList::promo($user->profile()->yearPromo()); $mlist->subscribe(): $this->UpdateOnYes(); @@ -80,7 +80,7 @@ class ReminderPromotionMl extends Reminder Reminder::MarkCandidateAsAccepted($user->id(), $candidate); } if ($mlCount == 0) { - $mlist = MailingList::promo($user->profile()->yearPromo(), $user); + $mlist = MailingList::promo($user->profile()->yearPromo()); try { $mlist->getMembersLimit(0, 0); } catch (Exception $e) { diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index f4caad9..3b42d4a 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -144,7 +144,7 @@ class ListeReq extends Validate $owners = array_values(array_unique($owners)); $members = array_values(array_unique($members)); - $list = new MailingList($this->liste, $this->domain, S::user()); + $list = new MailingList($this->liste, $this->domain); $success = $list->create($this->desc, $this->advertise, $this->modlevel, $this->inslevel, $owners, $members); diff --git a/modules/lists.php b/modules/lists.php index 0c0a376..d4e3d81 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -65,15 +65,12 @@ class ListsModule extends PLModule /** Prepare a MailingList from its mailbox */ - protected function prepare_list($mbox, $user=null) + protected function prepare_list($mbox) { // Required: modules/xnetlists.php uses it too. Platal::load('lists', 'lists.inc.php'); - if (is_null($user)) { - $user = S::user(); - } - return new MailingList($mbox, $this->get_lists_domain(), $user); + return new MailingList($mbox, $this->get_lists_domain()); } /** Ensure the current user is an administrator of the group. @@ -159,7 +156,7 @@ class ListsModule extends PLModule $promo = Post::i('promo_add'); if ($promo >= 1900 and $promo < 2100) { - $mlist = MailingList::promo($promo, S::user()); + $mlist = MailingList::promo($promo); $mlist->subscribe(); } else { $page->trigError("promo incorrecte, il faut une promo sur 4 chiffres."); -- 2.1.4