Get rid of the 'pass' argument to MailingList.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Wed, 7 Nov 2012 23:09:44 +0000 (00:09 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sat, 10 Nov 2012 16:04:44 +0000 (17:04 +0100)
Also default to S::user().

Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
include/mailinglist.inc.php
include/reminder/ml.inc.php
include/reminder/promotion_ml.inc.php
include/validations/listes.inc.php
modules/lists.php

index d2808c1..84cb526 100644 (file)
@@ -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';
index 3701c9e..808fc3e 100644 (file)
@@ -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;
         }
index 8733fc7..ab8da38 100644 (file)
@@ -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) {
index f4caad9..3b42d4a 100644 (file)
@@ -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);
index 0c0a376..d4e3d81 100644 (file)
@@ -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.");