Merge xorg/maint into xorg/master
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Wed, 14 Nov 2012 23:34:50 +0000 (00:34 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Wed, 14 Nov 2012 23:34:50 +0000 (00:34 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
39 files changed:
ChangeLog
bin/cron/cron_ml_moderate.php
bin/lists.create_promo.php
classes/profile.php
classes/user.php
core
htdocs/css/nl.FX.css
include/mailinglist.inc.php [new file with mode: 0644]
include/reminder/ml.inc.php
include/reminder/promotion_ml.inc.php
include/userset.inc.php
include/validations/listes.inc.php
modules/auth.php
modules/lists.php
modules/lists/lists.inc.php
modules/payment.php
modules/payment/money/bplccyberplus.inc.php
modules/payment/money/paypal.inc.php
modules/platal.php
modules/register.php
modules/register/register.inc.php
modules/xnetgrp.php
modules/xnetlists.php
plugins/function.profile.php
templates/admin/index.tpl
templates/carnet/notifs.tpl
templates/lists/display_list.tpl
templates/lists/header_listes.tpl
templates/newsletter/nl.FX.mail.tpl
templates/payment/reconcile.tpl
templates/profile/general.tpl
templates/xnetgrp/announce-admin.tpl
templates/xnetgrp/awaiting_active.tpl
templates/xnetlists/index.tpl
upgrade/1.1.6/01_survey_answer.sql [new file with mode: 0644]
upgrade/1.1.6/02_payments.sql [new file with mode: 0644]
upgrade/1.1.6/README [new file with mode: 0644]
upgrade/1.1.6/connect.db.inc.php [new symlink]
upgrade/1.1.6/update.sh [new file with mode: 0755]

index e490c72..f678377 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,33 @@
 ================================================================================
+VERSION 1.1.6                                                         XX XX XXXX
+
+    * AX:
+        - Pre-split addresses for AX CSV export                            -XEL
+
+    * Lists:
+        - Rewrite MailingList backend                                      -XEL
+        - Update promo ML subscription pages                               -XEL
+        - Enhance list members view performance                            -XEL
+
+    * Payments:
+        - Add a reference to RIBs in the payment table                     -KIT
+        - Allow many payments for a single event                           -KIT
+
+    * XnetEvent:
+        - Order events in decreasing order                                 -XEL
+
+    * XnetGrp:
+        - #1627: Fixes accounts awaiting validation page                   -JAC
+
+From 1.1.5 branch:
+
+    * Search:
+        - #1622: Fixes address search                                      -JAC
+
+    * XnetEvent:
+        - #1621: Properly computes event participants for the whole event  -JAC
+
+================================================================================
 VERSION 1.1.5                                                         31 05 2012
 
 Bug/Wish:
@@ -1902,6 +1931,7 @@ ACRONYMS:
     * JAC: Stéphane Jacob       (jacou)     <stephane.jacob@m4x.org>
     * JM : Jean-Marc Bécu                   <jean-marc.becu@m4x.org>
     * JS : Jean Sébastien Bedo              <jean-sebastien.bedo@m4x.org>
+    * KIT: Anne Limoges         (Kithyane)  <anne.limoges@m4x.org>
     * MC : Pierre Habouzit      (MadCoder)  <pierre.habouzit@m4x.org>
     * mYk: Aymeric Augustin     (mYk)       <aymeric.augustin@m4x.org>
     * OG : Olivier Guillaumin               <olivier.guillaumin@m4x.org>
index e77643d..3720907 100755 (executable)
@@ -42,37 +42,35 @@ while ($sent_mails < $globals->lists->max_mail_per_min
     if (XDB::affectedRows() == 0) {
         break;
     }
-    $query = XDB::query('SELECT  a.full_name, a.uid, a.password,
-                                 ml.ml, ml.domain, ml.mid, ml.action, ml.message
-                           FROM  accounts            AS a
-                     INNER JOIN  email_list_moderate AS ml ON (a.uid = ml.uid)
-                          WHERE  ml.handler = {?}', $handler);
-    list($fullname, $uid, $password, $list, $domain, $mid, $action, $reason) = $query->fetchOneRow();
-
-    // build the client
-    $client = new MMList($uid, $password, $domain);
+    $query = XDB::query('SELECT  uid, ml, domain, mid, action, message
+                           FROM  email_list_moderate
+                          WHERE  handler = {?}', $handler);
+    list($uid, $list, $domain, $mid, $action, $reason) = $query->fetchOneRow();
+    $user = User::get($uid);
+    $fullname = $user->fullName();
+    $mlist = new MailingList($list, $domain, $user);
 
     // send the mail
-    $mail = $client->get_pending_mail($list, $mid);
-    list($det,$mem,$own) = $client->get_members($list);
+    $mail = $mlist->getPendingMail($mid);
+    list($det,$mem,$own) = $mlist->getMembers();
     $count = 0;
     switch ($action) {
       case 'accept':
-        $action = 1;    /** 1 = ACCEPT **/
+        $action = MailingList::REQ_ACCEPT;
         $subject = "Message accepté";
         $append  = "a été accepté par $fullname.\n";
         $type = 'nonspam';
         $count += count($mem) + count($own);
         break;
       case 'refuse':
-        $action = 2;    /** 2 = REJECT **/
+        $action = MailingList::REQ_REJECT;
         $subject = "Message refusé";
         $append  = "a été refusé par $fullname avec la raison :\n\n" . $reason;
         $type = 'nonspam';
         $count += count($own) + 1;
         break;
       case 'delete':
-        $action = 3;    /** 3 = DISCARD **/
+        $action = MailingList::REQ_DISCARD;
         $subject = "Message supprimé";
         $append  = "a été supprimé par $fullname.\n\n"
                  . "Rappel : il ne faut utiliser cette opération "
@@ -83,7 +81,7 @@ while ($sent_mails < $globals->lists->max_mail_per_min
     }
 
     // if the mail was classified as Unsure, feed bogo
-    $raw_mail = html_entity_decode($client->get_pending_mail($list, $mid, 1));
+    $raw_mail = html_entity_decode($mlist->getPendingMail($mid, 1));
     // search for the X-Spam-Flag header
     $end_of_headers = strpos($raw_mail, "\r\n\r\n");
     if ($end_of_headers === false) {   // sometimes headers are separated by \n
@@ -103,7 +101,7 @@ while ($sent_mails < $globals->lists->max_mail_per_min
     }
 
     // send feedback to the mailing list owners
-    if ($client->handle_request($list, $mid, $action, utf8_decode($reason))) {
+    if ($mlist->handleRequest($action, $mid, $reason)) {
         $sent_mails += $count;
         $texte = "Le message suivant :\n\n"
                . "    Auteur: {$mail['sender']}\n"
index 78accf9..07e7ca6 100755 (executable)
@@ -27,7 +27,7 @@ if (!$owner_user) {
 }
 
 // Creates the list.
-$req = new ListeReq($owner_user, false, "promo$promo", $globals->mail->domain, "Liste de la promotion $promo",
+$req = new ListeReq($owner_user, false, "promo", $promo . '.' . $globals->mail->domain, "Liste de la promotion $promo",
                     1 /*private*/, 2 /*moderate*/, 0 /*free subscription*/,
                     array($owner), array());
 $req->submit();
index b11e31d..593568c 100644 (file)
@@ -171,6 +171,13 @@ class Profile implements PlExportable
         $this->visibility = $visibility;
     }
 
+    public function __destruct()
+    {
+        // Need to delete objects allocated by the profile
+        // http://www.php.net/manual/en/function.unset.php#98692
+        unset($this->owner);
+    }
+
     public function id()
     {
         return $this->pid;
index b8cca26..d2ecc1a 100644 (file)
@@ -363,12 +363,18 @@ class User extends PlUser
         if (!$this->_profile_fetched || $forceFetch) {
             $this->_profile_fetched = true;
             $this->_profile = Profile::get($this, $fields, $visibility);
-        } else if ($this->_profile !== null && !$this->_profile->visibility->equals($visibility)) {
+        } else if ($this->_profile !== null && $visibility !== null && !$this->_profile->visibility->equals($visibility)) {
             return Profile::get($this, $fields, $visibility);
         }
         return $this->_profile;
     }
 
+    public function setPrefetchedProfile(Profile $profile)
+    {
+        $this->_profile_fetched = true;
+        $this->_profile = $profile;
+    }
+
     /** Return true if the user has an associated profile.
      */
     public function hasProfile()
diff --git a/core b/core
index bce0d8c..ee47c43 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit bce0d8c7608b7dd361810d4143792db5affaf2ca
+Subproject commit ee47c4357d535e26a408f14e1144a3f8ed85528f
index dcbab87..0ff0835 100644 (file)
@@ -66,6 +66,39 @@ div.fx_mail div.signature {
     text-align : right;
 }
 
+/* Category */
+div.fx_mail h1.category {
+    margin: 3ex 0 2ex;
+    padding : 1.5ex 2ex 0.5ex 1ex;
+    font-size : 120%;
+    font-weight : bold;
+    text-align : right;
+}
+
+/* Article title */
+div.fx_mail h2.xorg_nl {
+    margin : 2ex 0 0;
+    padding : 0.4ex 2ex;
+    font-size : 100%;
+    font-weight : bold;
+    font-style : italic;
+    border-width : thin 0;
+    border-style : solid;
+}
+
+/* Article text */
+div.fx_mail div.art {
+    margin: 2ex 3ex;
+}
+
+/* Article details */
+div.fx_mail div.app {
+    margin : 2ex 6ex 0 3ex;
+    font-size : 95%;
+    text-align : left;
+    color: #333;
+}
+
 /* Give */
 div.fx_mail div.give {
     font-weight: bold;
diff --git a/include/mailinglist.inc.php b/include/mailinglist.inc.php
new file mode 100644 (file)
index 0000000..c8ceca2
--- /dev/null
@@ -0,0 +1,287 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+// {{{ class MailingList
+
+class MailingList
+{
+    public $address;        // Fully qualified address of the list
+    public $mbox;           // mailbox for the list
+    public $domain;         // domain for the list
+    protected $mmclient;    // The XML-RPC client for Mailman requests
+
+    public function __construct($mbox, $domain, $user=null)
+    {
+        $this->mbox = $mbox;
+        $this->domain = $domain;
+        $this->address = "$mbox@$domain";
+
+        if (is_null($user)) {
+            $user = S::user();
+        }
+        $this->mmclient = new MMList($user, $this->domain);
+    }
+
+    /** Instantiate a MailingList from its address.
+     */
+    public static function fromAddress($address, $user=null)
+    {
+        if (strstr($address, '@') !== false) {
+            list($mbox, $domain) = explode('@', $address);
+        } else {
+            global $globals;
+            $mbox = $address;
+            $domain = $globals->mail->domain;
+        }
+        return new MailingList($mbox, $domain, $user);
+    }
+
+    /** Retrieve the MailingList associated with a given promo.
+     */
+    public static function promo($promo, $user=null)
+    {
+        global $globals;
+        $mail_domain = $globals->mail->domain;
+        return new MailingList('promo', "$promo.$mail_domain", $user);
+    }
+
+    const KIND_BOUNCE = 'bounces';
+    const KIND_OWNER = 'owner';
+    public function getAddress($kind)
+    {
+        return $this->mbox . '-' . $kind . '@' . $this->domain;
+    }
+
+    /** Subscribe the current user to the list
+     */
+    public function subscribe()
+    {
+        return $this->mmclient->subscribe($this->mbox);
+    }
+
+    public static function subscribeTo($mbox, $domain, $user=null)
+    {
+        $mlist = new MailingList($mbox, $domain, $user);
+        return $mlist->subscribe();
+    }
+
+    public static function subscribePromo($promo, $user=null)
+    {
+        $mlist = MailingList::promo($promo, $user);
+        return $mlist->subscribe();
+    }
+
+    /** Subscribe a batch of users to the list
+     */
+    public function subscribeBulk($members)
+    {
+        return $this->mmclient->mass_subscribe($this->mbox, $members);
+    }
+
+    /** Unsubscribe the current user from the list
+     */
+    public function unsubscribe()
+    {
+        return $this->mmclient->unsubscribe($this->mbox);
+    }
+
+    /** Unsubscribe a batch of users from the list
+     */
+    public function unsubscribeBulk($members)
+    {
+        return $this->mmclient->mass_unsubscribe($this->mbox, $members);
+    }
+
+    /** Retrieve owners for the list.
+     *
+     * TODO: document the return type
+     */
+    public function getOwners()
+    {
+        return $this->mmclient->get_owners($this->mbox);
+    }
+
+    /** Add an owner to the list
+     */
+    public function addOwner($email)
+    {
+        return $this->mmclient->add_owner($this->mbox, $email);
+    }
+
+    /** Remove an owner from the list
+     */
+    public function removeOwner($email)
+    {
+        return $this->mmclient->del_owner($this->mbox, $email);
+    }
+
+    /** Retrieve members of the list.
+     *
+     * TODO: document the return type
+     */
+    public function getMembers()
+    {
+        return $this->mmclient->get_members($this->mbox);
+    }
+
+    /** Retrieve a subset of list members.
+     *
+     * TODO: document the return type
+     */
+    public function getMembersLimit($page, $number_per_page)
+    {
+        return $this->mmclient->get_members_limit($this->mbox, $page, $number_per_page);
+    }
+
+    /** Fetch pending list operations.
+     *
+     * TODO: document the return type
+     */
+    public function getPendingOps()
+    {
+        return $this->mmclient->get_pending_ops($this->mbox);
+    }
+
+    const REQ_ACCEPT = 1;
+    const REQ_REJECT = 2;
+    const REQ_DISCARD = 3;
+    const REQ_SUBSCRIBE = 4;
+
+    /** Handle a mailing list request
+     */
+    public function handleRequest($kind, $value, $comment='')
+    {
+        return $this->mmclient->handle_request($this->mbox, $value, $kind,
+           utf8_decode($comment));
+    }
+
+    /** Retrieve the current status of a pending subscription request
+     */
+    public function getPendingSubscription($email)
+    {
+        return $this->mmclient->get_pending_sub($this->mbox, $email);
+    }
+
+    /** Retrieve pending mails
+     */
+    public function getPendingMail($mid)
+    {
+        return $this->mmclient->get_pending_mail($this->mbox, $mid);
+    }
+
+    /** Create a list
+     */
+    public static function create($mbox, $domain, $user, $description,
+        $advertise, $moderation_level, $subscription_level,
+        $owners, $members)
+    {
+        $mlist = new MailingList($mbox, $domain, $user);
+        return $mlist->mmclient->create_list($mlist->mbox, utf8_decode($description),
+            $advertise, $moderation_level, $subscription_level,
+            $owners, $members);
+    }
+
+    /** Delete a list
+     */
+    public function delete($remove_archives=false)
+    {
+        return $this->mmclient->delete_list($this->mbox, $remove_archives);
+    }
+
+    /** Set antispam level.
+     */
+    public function setBogoLevel($level)
+    {
+        return $this->mmclient->set_bogo_level($this->mbox);
+    }
+
+    /** Get antispam level.
+     *
+     * @return int
+     */
+    public function getBogoLevel()
+    {
+        $bogo = $this->mmclient->get_bogo_level($this->mbox);
+        return $bogo;
+    }
+
+    /** Set public options.
+     *
+     * @param $options array
+     */
+    public function setOwnerOptions($options)
+    {
+        return $this->mmclient->set_owner_options($this->mbox, $options);
+    }
+
+    /** Retrieve owner options
+     *
+     * @return array
+     */
+    public function getOwnerOptions()
+    {
+        return $this->mmclient->get_owner_options($this->mbox);
+    }
+
+    /** Set admin options.
+     *
+     * @param $options array
+     */
+    public function setAdminOptions($options)
+    {
+        return $this->mmclient->set_admin_options($this->mbox, $options);
+    }
+
+    /** Retrieve admin options
+     *
+     * @return array
+     */
+    public function getAdminOptions()
+    {
+        return $this->mmclient->get_admin_options($this->mbox);
+    }
+
+    /** Check options, optionnally fixing them.
+     */
+    public function checkOptions($fix=false)
+    {
+        return $this->mmclient->check_options($this->mbox, $fix);
+    }
+
+    /** Add an email to the list of whitelisted senders
+     */
+    public function whitelistAdd($email)
+    {
+        return $this->mmclient->add_to_wl($this->mbox, $email);
+    }
+
+    /** Remove an email from the list of whitelisted senders
+     */
+    public function whitelistRemove($email)
+    {
+        return $this->mmclient->del_from_wl($this->mbox, $email);
+    }
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 enc=utf-8:
+?>
index 8244654..0eb475a 100644 (file)
@@ -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,7 @@ 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);
+                    MailingList::subscribeTo($sub, $domain);
                 }
             }
 
@@ -67,14 +62,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);
+            list($details, ) = $mlist->getMembers();
             $lists["$sub@$domain"] = $details;
         }
         $page->assign_by_ref('lists', $lists);
index c311e13..710ac4f 100644 (file)
@@ -31,8 +31,7 @@ class ReminderPromotionMl extends Reminder
                                         FROM  groups
                                        WHERE  diminutif = {?}',
                          $user->id(), $user->profile()->yearPromo());
-            $mmlist = new MMList($user);
-            $mmlist->subscribe('promo' . $user->profile()->yearPromo());
+            MailingList::subscribePromo($user->profile()->yearPromo());
 
             $this->UpdateOnYes();
             break;
@@ -80,10 +79,9 @@ class ReminderPromotionMl extends Reminder
             Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
         }
         if ($mlCount == 0) {
-            $mmlist = new MMList($user);
+            $mlist = MailingList::promo($user->profile()->yearPromo());
             try {
-                $mmlist->get_members_limit('promo' + $user->profile()->yearPromo(),
-                                           0, 0);
+                $mlist->getMembersLimit(0, 0);
             } catch (Exception $e) {
                 return false;
             }
index ac6b261..d191161 100644 (file)
@@ -427,6 +427,36 @@ class AddressesView implements PlView
         $this->set =& $set;
     }
 
+    /* Convert a single address field into 3 lines.
+     */
+    public static function split_address($address)
+    {
+        $lines = preg_split("/(\r|\n)+/", $address, -1, PREG_SPLIT_NO_EMPTY);
+        $nb_lines = count($lines);
+        switch ($nb_lines) {
+        case 0:
+            // No data => nothing
+            return array("", "", "");
+        case 1:
+            // Single line => Assume it's city+zipcode
+            $line = $lines[0];
+            return array("", "", $line);
+        case 2:
+            // Two lines => Assume it's street \n city
+            $line1 = $lines[0];
+            $line3 = $lines[1];
+            return array($line1, "", $line3);
+        case 3:
+            return $lines;
+        default:
+            // More than 3 lines => Keep 2 last intact, merge other lines.
+            $line3 = array_pop($lines);
+            $line2 = array_pop($lines);
+            $line1 = implode(" ", $lines);
+            return array($line1, $line2, $line3);
+        }
+    }
+
     public function apply(PlPage $page)
     {
         $pids = $this->set->getIds(new PlLimit());
@@ -434,7 +464,10 @@ class AddressesView implements PlView
         pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1, 'adresses.csv');
 
         $csv = fopen('php://output', 'w');
-        fputcsv($csv,  array('PROMOTION', 'CIVILITE', 'NOM', 'PRENOM', 'SOCIETE', 'ADRESSE', 'CP', 'EMAIL'), ';');
+        fputcsv($csv,
+            array('PROMOTION', 'CIVILITE', 'NOM', 'PRENOM', 'SOCIETE', 'ADRESSE', 'ADRESSE1', 'ADRESSE2', 'ADRESSE3', 'CP', 'EMAIL'),
+            ';');
+
         if (!empty($pids)) {
             $res = XDB::query("SELECT  pd.promo, p.title,
                                        IF (pn.firstname_ordinary = '', UPPER(pn.firstname_main), UPPER(pn.firstname_ordinary)) AS firstname,
@@ -448,8 +481,12 @@ class AddressesView implements PlView
                                                                         AND pj.id = IF(pa.type = 'job', pa.id, NULL))
                             LEFT JOIN  profile_job_enum     AS pje  ON (pj.jobid = pje.id)
                                 WHERE  pa.pid IN {?} AND FIND_IN_SET('ax_mail', pa.flags)", $pids);
-            foreach ($res->fetchAllAssoc() as $item) {
-                fputcsv($csv, array_map('utf8_decode', $item), ';');
+            foreach ($res->fetchAllRow() as $item) {
+                list($promo, $title, $lastname, $firstname, $company, $full_address, $zipcode, $email) = array_map('utf8_decode', $item);
+                $lines = self::split_address($full_address);
+                fputcsv($csv,
+                    array($promo, $title, $lastname, $firstname, $company, $full_address, $lines[0], $lines[1], $lines[2], $zipcode, $email),
+                    ';');
             }
         }
         fclose($csv);
index ef19a21..8ab84eb 100644 (file)
@@ -138,15 +138,17 @@ 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);
+
+            $success = MailingList::create($this->liste, $this->domain, null,
+                $this->desc, $this->advertise,
+                $this->modlevel, $this->inslevel,
+                $owners, $members);
+
             if ($success) {
                 create_list($this->liste, $this->domain);
             }
index e222eeb..53250d6 100644 (file)
@@ -134,6 +134,8 @@ class AuthModule extends PLModule
             } else {
                 $page->assign('group', null);
             }
+            // Add a P3P header for compatibility with IE in iFrames (http://www.w3.org/TR/P3P11/#compact_policies)
+            header('P3P: CP="CAO COR CURa ADMa DEVa OUR IND PHY ONL COM NAV DEM CNT STA PRE"');
             return PL_DO_AUTH;
         }
 
index 8a5ccb9..d4e3d81 100644 (file)
@@ -21,8 +21,6 @@
 
 class ListsModule extends PLModule
 {
-    protected $client;
-
     function handlers()
     {
         return array(
@@ -48,22 +46,54 @@ class ListsModule extends PLModule
         );
     }
 
-    function prepare_client($page, $user = null)
+    protected function prepare_client($user = null)
     {
-        global $globals;
-
-        $this->load('lists.inc.php');
         if (is_null($user)) {
             $user = S::user();
         }
 
-        $this->client = new MMList($user);
+        $domain = $this->get_lists_domain();
+
+        return new MMList($user, $domain);
+    }
+
+    protected function get_lists_domain()
+    {
+        global $globals;
         return $globals->mail->domain;
     }
 
-    function verify_list_owner($page, $liste)
+    /** Prepare a MailingList from its mailbox
+     */
+    protected function prepare_list($mbox)
+    {
+        // Required: modules/xnetlists.php uses it too.
+        Platal::load('lists', 'lists.inc.php');
+
+        return new MailingList($mbox, $this->get_lists_domain());
+    }
+
+    /** Ensure the current user is an administrator of the group.
+     */
+    protected function is_group_admin($page)
+    {
+        $force_rights = false;
+        if ($GLOBALS['IS_XNET_SITE']) {
+            $perms = S::v('perms');
+            if (is_object($perms) && $perms->hasFlag('groupadmin')) {
+                $force_rights = true;
+            }
+        }
+        $page->assign('group_admin', $force_rights);
+
+        return $force_rights;
+    }
+
+    /** Ensure the current user owns the given MailingList.
+     */
+    protected function verify_list_owner($page, $mlist)
     {
-        if (list(, , $owners) = $this->client->get_members($liste)) {
+        if (list(, , $owners) = $mlist->getMembers()) {
             if (!(in_array(S::user()->forlifeEmail(), $owners) || S::admin())) {
                 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.");
             }
@@ -74,15 +104,17 @@ class ListsModule extends PLModule
         }
     }
 
-    function get_pending_ops($domain, $list)
+    /** Fetch pending operations on a MailingList instance.
+     */
+    protected function get_pending_ops($mlist)
     {
-        list($subs,$mails) = $this->client->get_pending_ops($list);
+        list($subs, $mails) = $mlist->getPendingOps();
         $res = XDB::query("SELECT  mid
                              FROM  email_list_moderate
                             WHERE  ml = {?} AND domain = {?}",
-                          $list, $domain);
+                          $mlist->mbox, $mlist->domain);
         $mids = $res->fetchColumn();
-        foreach ($mails as $key=>$mail) {
+        foreach ($mails as $key => $mail) {
             if (in_array($mail['id'], $mids)) {
                 unset($mails[$key]);
             }
@@ -92,6 +124,7 @@ class ListsModule extends PLModule
 
     function handler_lists($page)
     {
+
         function filter_owner($list)
         {
             return $list['own'];
@@ -102,20 +135,20 @@ class ListsModule extends PLModule
             return $list['sub'];
         }
 
-        $domain = $this->prepare_client($page);
-
         $page->changeTpl('lists/index.tpl');
         $page->setTitle('Listes de diffusion');
 
 
         if (Get::has('del')) {
             S::assert_xsrf_token();
-            $this->client->unsubscribe(Get::v('del'));
+            $mlist = $this->prepare_list(Get::v('del'));
+            $mlist->unsubscribe();
             pl_redirect('lists');
         }
         if (Get::has('add')) {
             S::assert_xsrf_token();
-            $this->client->subscribe(Get::v('add'));
+            $mlist = $this->prepare_list(Get::v('add'));
+            $mlist->subscribe();
             pl_redirect('lists');
         }
         if (Post::has('promo_add')) {
@@ -123,19 +156,22 @@ class ListsModule extends PLModule
 
             $promo = Post::i('promo_add');
             if ($promo >= 1900 and $promo < 2100) {
-                $this->client->subscribe("promo$promo");
+                $mlist = MailingList::promo($promo);
+                $mlist->subscribe();
             } else {
                 $page->trigError("promo incorrecte, il faut une promo sur 4 chiffres.");
             }
         }
 
-        if (!is_null($listes = $this->client->get_lists())) {
+        $client = $this->prepare_client();
+        if (!is_null($listes = $client->get_lists())) {
             $owner  = array_filter($listes, 'filter_owner');
             $listes = array_diff_key($listes, $owner);
             $member = array_filter($listes, 'filter_member');
             $listes = array_diff_key($listes, $member);
             foreach ($owner as $key => $liste) {
-                list($subs, $mails) = $this->get_pending_ops($domain, $liste['list']);
+                $mlist = $this->prepare_list($liste['list']);
+                list($subs, $mails) = $this->get_pending_ops($mlist);
                 $owner[$key]['subscriptions'] = $subs;
                 $owner[$key]['mails'] = $mails;
             }
@@ -149,26 +185,26 @@ class ListsModule extends PLModule
     function handler_ajax($page, $list = null)
     {
         pl_content_headers("text/html");
-        $domain = $this->prepare_client($page);
         $page->changeTpl('lists/liste.inc.tpl', NO_SKIN);
         S::assert_xsrf_token();
 
+        $mlist = $this->prepare_list($list);
         if (Get::has('unsubscribe')) {
-            $this->client->unsubscribe($list);
+            $mlist->unsubscribe();
         }
         if (Get::has('subscribe')) {
-            $this->client->subscribe($list);
+            $mlist->subscribe();
         }
-        if (Get::has('sadd')) { /* 4 = SUBSCRIBE */
-            $this->client->handle_request($list, Get::v('sadd'), 4, '');
+        if (Get::has('sadd')) {
+            $mlist->handleRequest(MailingList::REQ_SUBSCRIBE, Get::v('sadd'));
         }
         if (Get::has('mid')) {
-            $this->moderate_mail($domain, $list, Get::i('mid'));
+            $this->moderate_mail($mlist, Get::i('mid'));
         }
 
-        list($liste, $members, $owners) = $this->client->get_members($list);
+        list($liste, $members, $owners) = $mlist->getMembers();
         if ($liste['own']) {
-            list($subs,$mails) = $this->get_pending_ops($domain, $list);
+            list($subs, $mails) = $this->get_pending_ops($mlist);
             $liste['subscriptions'] = $subs;
             $liste['mails'] = $mails;
         }
@@ -318,23 +354,24 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client($page);
+        $mlist = $this->prepare_list($liste);
+        $this->is_group_admin($page);
 
         $page->changeTpl('lists/members.tpl');
 
         if (Get::has('del')) {
             S::assert_xsrf_token();
-            $this->client->unsubscribe($liste);
-            pl_redirect('lists/members/'.$liste);
+            $mlist->unsubscribe();
+            pl_redirect('lists/members/' . $liste);
         }
 
         if (Get::has('add')) {
             S::assert_xsrf_token();
-            $this->client->subscribe($liste);
-            pl_redirect('lists/members/'.$liste);
+            $mlist->subscribe();
+            pl_redirect('lists/members/' . $liste);
         }
 
-        $members = $this->client->get_members($liste);
+        $members = $mlist->getMembers();
 
         $tri_promo = !Env::b('alpha');
 
@@ -356,8 +393,10 @@ class ListsModule extends PLModule
         if (is_null($liste)) {
             return PL_NOT_FOUND;
         }
-        $this->prepare_client($page);
-        $members = $this->client->get_members($liste);
+        $this->is_group_admin($page);
+
+        $mlist = $this->prepare_list($liste);
+        $members = $mlist->getMembers();
         $list = list_fetch_basic_info(list_extract_members($members[1]));
         pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1);
 
@@ -372,25 +411,27 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client($page);
+        $this->is_group_admin($page);
+
+        $mlist = $this->prepare_list($liste);
 
         if (Get::has('del')) {
             S::assert_xsrf_token();
-            $this->client->unsubscribe($liste);
+            $mlist->unsubscribe();
             pl_redirect('lists/annu/'.$liste);
         }
         if (Get::has('add')) {
             S::assert_xsrf_token();
-            $this->client->subscribe($liste);
+            $mlist->subscribe();
             pl_redirect('lists/annu/'.$liste);
         }
 
-        $owners = $this->client->get_owners($liste);
+        $owners = $mlist->getOwners();
         if (!is_array($owners)) {
             $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
         }
 
-        list(,$members) = $this->client->get_members($liste);
+        list(,$members) = $mlist->getMembers();
 
         if ($action == 'moderators') {
             $users = $owners;
@@ -428,16 +469,18 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $domain = $this->prepare_client($page);
+        $this->is_group_admin($page);
+
+        $mlist = $this->prepare_list($liste);
 
         $page->changeTpl('lists/archives.tpl');
 
-        if (list($det) = $this->client->get_members($liste)) {
+        if (list($det) = $mlist->getMembers()) {
             if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv'])
                     && !$det['own'] && ($det['sub'] < 2)) {
                 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
             }
-            $get = Array('listname' => $liste, 'domain' => $domain);
+            $get = Array('listname' => $mlist->mbox, 'domain' => $mlist->domain);
             if (Post::has('updateall')) {
                 $get['updateall'] = Post::v('updateall');
             }
@@ -459,20 +502,28 @@ class ListsModule extends PLModule
             return PL_FORBIDDEN;
         }
 
-        $domain = $this->prepare_client($page, $user);
-        if (list($det) = $this->client->get_members($liste)) {
+        $mlist = $this->prepare_list($liste);
+
+        if (list($det) = $mlist->getMembers()) {
             if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv'])
                     && !$det['own'] && ($det['sub'] < 2)) {
                 exit;
             }
             require_once('banana/ml.inc.php');
-            $banana = new MLBanana($user, Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
+            $banana = new MLBanana($user, Array(
+                'listname' => $mlist->mbox,
+                'domain' => $mlist->domain,
+                'action' => 'rss2'));
             $banana->run();
         }
         exit;
     }
 
-    function moderate_mail($domain, $liste, $mid)
+    /** Register a moderation decision.
+     * @param $mlist MailingList: the mailing list being moderated
+     * @param $mid int: the message being moderated
+     */
+    protected function moderate_mail($mlist, $mid)
     {
         if (Env::has('mok')) {
             $action = 'accept';
@@ -486,7 +537,7 @@ class ListsModule extends PLModule
         Get::kill('mid');
         return XDB::execute("INSERT IGNORE INTO  email_list_moderate
                                          VALUES  ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)",
-                            $liste, $domain, $mid, S::i('uid'), $action, Post::v('reason'));
+                            $mlist->mbox, $mlist->domain, $mid, S::i('uid'), $action, Post::v('reason'));
     }
 
     function handler_moderate($page, $liste = null)
@@ -495,8 +546,10 @@ class ListsModule extends PLModule
              return PL_NOT_FOUND;
         }
 
-        $domain = $this->prepare_client($page);
-        $this->verify_list_owner($page, $liste);
+        $mlist = $this->prepare_list($liste);
+        if (!$this->is_group_admin($page)) {
+            $this->verify_list_owner($page, $mlist);
+        }
 
         $page->changeTpl('lists/moderate.tpl');
 
@@ -505,23 +558,27 @@ class ListsModule extends PLModule
         if (Env::has('sadd') || Env::has('sdel')) {
             S::assert_xsrf_token();
 
-            if (Env::has('sadd')) { /* 4 = SUBSCRIBE */
-                $sub = $this->client->get_pending_sub($liste, Env::v('sadd'));
-                $this->client->handle_request($liste,Env::v('sadd'),4,'');
+            if (Env::has('sadd')) {
+                // Ensure the moderated request is still active
+                $sub = $mlist->getPendingSub(Env::v('sadd'));
+
+                $mlist->handleRequest(MailingList::REQ_SUBSCRIBE, Env::v('sadd'));
                 $info = "validée";
             }
-            if (Post::has('sdel')) { /* 2 = REJECT */
-                $sub = $this->client->get_pending_sub($liste, Env::v('sdel'));
-                $this->client->handle_request($liste, Post::v('sdel'), 2, utf8_decode(Post::v('reason')));
+            if (Post::has('sdel')) {
+                // Ensure the moderated request is still active
+                $sub = $mlist->getPendingSub(Env::v('sdel'));
+
+                $mlist->handleRequest(MailingList::REQ_REJECT, Post::v('sdel'), Post::v('reason'));
                 $info = "refusée";
             }
             if ($sub) {
                 $mailer = new PlMailer();
-                $mailer->setFrom("$liste-bounces@{$domain}");
-                $mailer->addTo("$liste-owner@{$domain}");
-                $mailer->addHeader('Reply-To', "$liste-owner@{$domain}");
+                $mailer->setFrom($mlist->getAddress(MailingList::KIND_BOUNCE));
+                $mailer->addTo($mlist->getAddress(MailingList::KIND_OWNER));
+                $mailer->addHeader('Reply-To', $mlist->getAddress(MailingList::KIND_OWNER));
                 $mailer->setSubject("L'inscription de {$sub['name']} a été $info");
-                $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S::user()->fullName(true) . ".\n";
+                $text = "L'inscription de {$sub['name']} à la liste " . $mlist->address ." a été $info par " . S::user()->fullName(true) . ".\n";
                 if (trim(Post::v('reason'))) {
                     $text .= "\nLa raison invoquée est :\n" . Post::v('reason');
                 }
@@ -538,20 +595,24 @@ class ListsModule extends PLModule
 
             $mails = array_keys(Post::v('select_mails'));
             foreach($mails as $mail) {
-                $this->moderate_mail($domain, $liste, $mail);
+                $this->moderate_mail($mlist, $mail);
             }
         } elseif (Env::has('mid')) {
             if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) {
                 require_once 'banana/moderate.inc.php';
 
                 $page->changeTpl('lists/moderate_mail.tpl');
-                $params = array('listname' => $liste, 'domain' => $domain,
-                                'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action'));
-                $params['client'] = $this->client;
+                $params = array(
+                    'listname' => $mlist->mbox,
+                    'domain' => $mlist->domain,
+                    'artid' => Get::i('mid'),
+                    'part' => Get::v('part'),
+                    'action' => Get::v('action'));
+                $params['client'] = $this->prepare_client();
                 run_banana($page, 'ModerationBanana', $params);
 
                 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
-                $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
+                $msg = str_replace("%(adminaddr)s", $mlist->getAddress(MailingList::KIND_OWNER), $msg);
                 $msg = str_replace("%(request)s",   "<< SUJET DU MAIL >>",    $msg);
                 $msg = str_replace("%(reason)s",    "<< TON EXPLICATION >>",  $msg);
                 $msg = str_replace("%(listname)s",  $liste, $msg);
@@ -559,9 +620,9 @@ class ListsModule extends PLModule
                 return;
             }
 
-            $this->moderate_mail($domain, $liste, Env::i('mid'));
+            $this->moderate_mail($mlist, Env::i('mid'));
         } elseif (Env::has('sid')) {
-            if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
+            if (list($subs,$mails) = $this->get_pending_ops($mlist)) {
                 foreach($subs as $user) {
                     if ($user['id'] == Env::v('sid')) {
                         $page->changeTpl('lists/moderate_sub.tpl');
@@ -573,7 +634,7 @@ class ListsModule extends PLModule
 
         }
 
-        if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
+        if (list($subs,$mails) = $this->get_pending_ops($mlist)) {
             foreach ($mails as $key=>$mail) {
                 $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
                 if ($mail['fromx']) {
@@ -615,17 +676,10 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $domain = $this->prepare_client($page);
-        $force_rights = false;
-        if ($GLOBALS['IS_XNET_SITE']) {
-            $perms = S::v('perms');
-            if (is_object($perms) && $perms->hasFlag('groupadmin')) {
-                $force_rights = true;
-            }
-        }
-        $page->assign('group_admin', $force_rights);
-        if (!$force_rights) {
-            $this->verify_list_owner($page, $liste);
+        $mlist = $this->prepare_list($liste);
+        $this->is_group_admin($page);
+        if (!$this->is_group_admin($page)) {
+            $this->verify_list_owner($page, $mlist);
         }
 
         $page->changeTpl('lists/admin.tpl');
@@ -649,7 +703,7 @@ class ListsModule extends PLModule
                         $from = ($action == 'marketu') ? 'user' : 'staff';
                         $market = Marketing::get($uids[$key], $mail);
                         if (!$market) {
-                            $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S::v('uid'));
+                            $market = new Marketing($uids[$key], $mail, 'list', $mlist->address, $from, S::v('uid'));
                             $market->add();
                             break;
                         }
@@ -658,7 +712,7 @@ class ListsModule extends PLModule
                   default:
                     XDB::execute('INSERT IGNORE INTO  register_subs (uid, type, sub, domain)
                                               VALUES  ({?}, \'list\', {?}, {?})',
-                                  $uids[$key], $liste, $domain);
+                                  $uids[$key], $mlist->mbox, $mlist->domain);
                 }
             }
         }
@@ -688,7 +742,7 @@ class ListsModule extends PLModule
             // emails.
             $members = array_values(array_unique($members));
 
-            $arr = $this->client->mass_subscribe($liste, $members);
+            $arr = $mlist->subscribeBulk($members);
 
             $successes = array();
             if (is_array($arr)) {
@@ -719,10 +773,10 @@ class ListsModule extends PLModule
 
             if (strpos(Env::v('del_member'), '@') === false) {
                 if ($del_member = User::getSilent(Env::t('del_member'))) {
-                    $this->client->mass_unsubscribe($liste, array($del_member->forlifeEmail()));
+                    $mlist->unsubscribeBulk(array($del_member->forlifeEmail()));
                 }
             } else {
-                $this->client->mass_unsubscribe($liste, array(Env::v('del_member')));
+                $mlist->unsubscribeBulk(array(Env::v('del_member')));
             }
             pl_redirect('lists/admin/'.$liste);
         }
@@ -732,8 +786,8 @@ class ListsModule extends PLModule
 
             $owners = User::getBulkForlifeEmails(Env::v('add_owner'), false, array('ListsModule', 'no_login_callback'));
             if ($owners) {
-                foreach ($owners as $login) {
-                    if ($this->client->add_owner($liste, $login)) {
+                foreach ($owners as $forlife_email) {
+                    if ($mlist->addOwner($forlife_email)) {
                         $page->trigSuccess($login ." ajouté aux modérateurs.");
                     }
                 }
@@ -745,15 +799,15 @@ class ListsModule extends PLModule
 
             if (strpos(Env::v('del_owner'), '@') === false) {
                 if ($del_owner = User::getSilent(Env::t('del_owner'))) {
-                    $this->client->mass_unsubscribe($liste, array($del_owner->forlifeEmail()));
+                    $mlist->unsubscribeBulk(array($del_owner->forlifeEmail()));
                 }
             } else {
-                $this->client->del_owner($liste, Env::v('del_owner'));
+                $mlist->removeOwner(Env::v('del_owner'));
             }
             pl_redirect('lists/admin/'.$liste);
         }
 
-        if (list($det,$mem,$own) = $this->client->get_members($liste)) {
+        if (list($det,$mem,$own) = $mlist->getMembers()) {
             global $list_unregistered;
             if ($list_unregistered) {
                 $page->assign_by_ref('unregistered', $list_unregistered);
@@ -778,8 +832,10 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client($page);
-        $this->verify_list_owner($page, $liste);
+        $mlist = $this->prepare_list($liste);
+        if (!$this->is_group_admin($page)) {
+            $this->verify_list_owner($page, $mlist);
+        }
 
         $page->changeTpl('lists/options.tpl');
 
@@ -796,7 +852,7 @@ class ListsModule extends PLModule
             if ($spamlevel > 3 || $spamlevel < 0 || $unsurelevel < 0 || $unsurelevel > 1) {
                 $page->trigError("Réglage de l'antispam non valide");
             } else {
-                $this->client->set_bogo_level($liste, ($spamlevel << 1) + $unsurelevel);
+                $mlist->setBogoLevel(($spamlevel << 1) + $unsurelevel);
             }
             switch($values['moderate']) {
                 case '0':
@@ -819,20 +875,20 @@ class ListsModule extends PLModule
             if (isset($values['subject_prefix'])) {
                 $values['subject_prefix'] = trim($values['subject_prefix']).' ';
             }
-            $this->client->set_owner_options($liste, $values);
+            $mlist->setOwnerOptions($values);
         } elseif (isvalid_email(Post::v('atn_add'))) {
             S::assert_xsrf_token();
-            $this->client->add_to_wl($liste, Post::v('atn_add'));
+            $mlist->whitelistAdd(Post::v('atn_add'));
         } elseif (Get::has('atn_del')) {
             S::assert_xsrf_token();
-            $this->client->del_from_wl($liste, Get::v('atn_del'));
+            $mlist->whitelistRemove(Post::v('atn_del'));
             pl_redirect('lists/options/'.$liste);
         }
 
-        if (list($details,$options) = $this->client->get_owner_options($liste)) {
+        if (list($details, $options) = $mlist->getOwnerOptions()) {
             $page->assign_by_ref('details', $details);
             $page->assign_by_ref('options', $options);
-            $bogo_level = intval($this->client->get_bogo_level($liste));
+            $bogo_level = intval($mlist->getBogoLevel());
             $page->assign('unsure_level', $bogo_level & 1);
             $page->assign('bogo_level', $bogo_level >> 1);
         } else {
@@ -847,16 +903,19 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $domain = $this->prepare_client($page);
-        $this->verify_list_owner($page, $liste);
+        $mlist = $this->prepare_list($liste);
+        if (!$this->is_group_admin($page)) {
+            $this->verify_list_owner($page, $mlist);
+        }
+
         $page->changeTpl('lists/delete.tpl');
         if (Post::v('valid') == 'OUI') {
             S::assert_xsrf_token();
 
-            if ($this->client->delete_list($liste, Post::b('del_archive'))) {
+            if ($mlist->delete(Post::b('del_archive'))) {
                 require_once 'emails.inc.php';
 
-                delete_list($liste, $domain);
+                delete_list($mlist->mbox, $mlist->domain);
                 $page->assign('deleted', true);
                 $page->trigSuccess('La liste a été détruite&nbsp;!');
             } else {
@@ -864,13 +923,13 @@ class ListsModule extends PLModule
                          . 'Contact les administrateurs du site pour régler le problème : '
                          . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>.');
             }
-        } elseif (list($details,$options) = $this->client->get_owner_options($liste)) {
+        } elseif (list($details, $options) = $mlist->getOwnerOptions()) {
             if (!$details['own']) {
                 $page->trigWarning('Tu n\'es pas administrateur de la liste, mais du site.');
             }
             $page->assign_by_ref('details', $details);
             $page->assign_by_ref('options', $options);
-            $page->assign('bogo_level', $this->client->get_bogo_level($liste));
+            $page->assign('bogo_level', $mlist->getBogoLevel());
         } else {
             $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.");
         }
@@ -882,8 +941,10 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client($page);
-        $this->verify_list_owner($page, $liste);
+        $mlist = $this->prepare_list($liste);
+        if (!$this->is_group_admin($page)) {
+            $this->verify_list_owner($page, $mlist);
+        }
 
         $page->changeTpl('lists/soptions.tpl');
 
@@ -895,10 +956,10 @@ class ListsModule extends PLModule
             unset($values['submit']);
             $values['advertised'] = empty($values['advertised']) ? false : true;
             $values['archive'] = empty($values['archive']) ? false : true;
-            $this->client->set_admin_options($liste, $values);
+            $mlist->setAdminOptions($values);
         }
 
-        if (list($details,$options) = $this->client->get_admin_options($liste)) {
+        if (list($details, $options) = $mlist->getAdminOptions()) {
             $page->assign_by_ref('details', $details);
             $page->assign_by_ref('options', $options);
         } else {
@@ -912,17 +973,19 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client($page);
-        $this->verify_list_owner($page, $liste);
+        $mlist = $this->prepare_list($liste);
+        if (!$this->is_group_admin($page)) {
+            $this->verify_list_owner($page, $mlist);
+        }
 
         $page->changeTpl('lists/check.tpl');
 
         if (Post::has('correct')) {
             S::assert_xsrf_token();
-            $this->client->check_options($liste, true);
+            $mlist->checkOptions(true);
         }
 
-        if (list($details,$options) = $this->client->check_options($liste)) {
+        if (list($details, $options) = $mlist->checkOptions()) {
             $page->assign_by_ref('details', $details);
             $page->assign_by_ref('options', $options);
         } else {
@@ -935,8 +998,8 @@ class ListsModule extends PLModule
         $page->changeTpl('lists/admin_all.tpl');
         $page->setTitle('Administration - Mailing lists');
 
-        $this->prepare_client($page);
-        $listes = $this->client->get_all_lists();
+        $client = $this->prepare_client();
+        $listes = $client->get_all_lists();
         $page->assign_by_ref('listes', $listes);
     }
 
index a1aacc7..f167ab2 100644 (file)
 
 // {{{ function list_sort_owners
 
-function list_sort_owners($members, $tri_promo = true)
+function list_sort_owners($emails, $tri_promo = true)
 {
     global $globals;
 
     // $membres' structure is the following: $sortKey => $key => $listMember
     $membres = array();
+    $seen = array();
+
+    $members = array();
+
+    $uf = new UserFilter(new UFC_Email($emails));
+    $it = $uf->iterUsers();
+    while ($u = $it->next()) {
+        $members[$u->uid] = array(
+            'user' => $u,
+            'profile' => null,
+            'email' => $u->forlifeEmail());
+        $seen[] = $u->forlifeEmail();
+    }
+
+    $pf = new ProfileFilter(new UFC_Email($emails));
+    $it = $pf->iterProfiles();
+    while ($p = $it->next()) {
+        $members[$p->owner_id]['user']->setPrefetchedProfile($p);
+        $members[$p->owner_id]['profile'] = $p;
+    }
+
+    foreach ($emails as $email) {
+        if (!in_array($email, $seen)) {
+            $seen[] = $email;
+            $members[$email] = array('user' => null, 'profile' => null,
+                'email' => $email);
+        }
+    }
+
+    // $members is now an array of uid => {'user': User or null, 'email': $email}
+
+    // $sorted_members is an array of $sortKey1 => $sortKey2 => {User, email}
+    $sorted_members = array();
 
     foreach($members as $member) {
-        $user = User::getSilent($member);
-        if (!$user) {
-            $membres[0][$member] = array('name' => null, 'email' => $member, 'category' => null, 'uid' => null, 'lost' => null, 'hasProfile' => null);
+        if (is_null($member['user'])) {
+            $category = 'AAAAA';
+            $name = $member['email'];
         } else {
-            $hasProfile = $user->hasProfile();
-            $uid = $user->id();
-            $name = $user->directoryName();
-            $category = $user->category();
-            $key = $tri_promo ? ($category ? $category : 'AAAAA') : strtoupper($name{0});
-            if (!$category) {
-                $category = 'extérieurs';
-            }
-            $membres[$key][$name] = array('name' => $name, 'email' => $member, 'category' => $category,
-                                          'uid' => $uid, 'lost' => $user->lost, 'hasProfile' => $hasProfile);
+            $category = $member['user']->category();
+            $name = $member['user']->directoryName();
         }
+        if (empty($category)) {
+            $category = "AAAAA";
+        }
+
+        $main_sort_key = $tri_promo ? $category : strtoupper($name{0});
+        $alt_sort_key = $name;
+
+        if (!array_key_exists($main_sort_key, $sorted_members)) {
+            $sorted_members[$main_sort_key] = array();
+        }
+
+        $sorted_members[$main_sort_key][$alt_sort_key] = $member;
     }
 
-    uksort($membres, 'strcasecmp');
-    foreach($membres as &$membre)  {
-        uksort($membre, 'strcasecmp');
+    uksort($sorted_members, 'strcasecmp');
+    foreach($sorted_members as &$subsorted_members)  {
+        uksort($subsorted_members, 'strcasecmp');
     }
-    return $membres;
+    return $sorted_members;
 }
 
 // }}}
index 623aad2..e3788e5 100644 (file)
  ***************************************************************************/
 
 /* sort en affichant une erreur */
-function cb_erreur($text) {
+function cb_erreur($text, $conf_title="") {
     global $globals;
     echo "Error: ".$text."\n";
     $mymail = new PlMailer();
     $mymail->addTo($globals->money->email);
     $mymail->setFrom("webmaster@" . $globals->mail->domain);
     $mymail->setSubject("erreur lors d'un télépaiement (CyberPaiement)");
-    $mymail->setTxtBody("raison de l'erreur : ".$text."\n".
-                        "paiement : $conf_title \n\n".
-                        "dump de REQUEST :\n".
-                        var_export($_REQUEST,true));
+    $content = "raison de l'erreur : " . $text . "\n";
+    if ($conf_title != "") {
+        $content = $content."paiement : ".$conf_title."\n";
+    }
+    $content = $content . "dump de REQUEST :\n" . var_export($_REQUEST, true);
+    $mymail->setTxtBody($content);
     $mymail->send();
     echo "Notification sent.\n";
     exit;
@@ -270,7 +272,7 @@ class PaymentModule extends PLModule
 
         /* on extrait le code de retour */
         if (Env::v('vads_result') != '00') {
-            cb_erreur('erreur lors du paiement : ?? (' . Env::v('vads_result') . ')');
+            cb_erreur('erreur lors du paiement : ?? (' . Env::v('vads_result') . ')', $conf_title);
         }
 
         /* on fait l'insertion en base de donnees */
@@ -585,10 +587,13 @@ class PaymentModule extends PLModule
         $table_editor->describe('amount_max', 'montant maximum', false, true);
         $table_editor->describe('mail', 'email contact', true);
         $table_editor->describe('confirmation', 'message confirmation', false, true);
-
+        $table_editor->describe('rib_id', 'RIB', false, true);
         // adds a column with the start date of the linked event if there is one
         $table_editor->add_option_table('group_events', 'group_events.paiement_id = t.id');
-        $table_editor->add_option_field('group_events.debut', 'related_event', 'évènement', 'timestamp');
+        $table_editor->add_option_field('group_events.archive', 'related_event', 'évènement archivé ?', 'tinyint');
+        // adds a column with the linked rib if there is one
+        $table_editor->add_option_table('payment_bankaccounts', 'payment_bankaccounts.id = t.rib_id');
+        $table_editor->add_option_field('payment_bankaccounts.owner', 'linked_rib_owner', 'rib associé', 'varchar');
 
         $table_editor->apply($page, $action, $id);
     }
@@ -691,8 +696,9 @@ class PaymentModule extends PLModule
                                   $recongp['id']);
                 $recongp['recons'] = $res->fetchAllAssoc();
 
-                $res = XDB::query('SELECT  id, payment_id, amount, account_id, message, date
-                                     FROM  payment_transfers
+                $res = XDB::query('SELECT  t.id, t.payment_id, t.amount, b.owner, t.message, t.date
+                                     FROM  payment_transfers    AS t
+                                LEFT JOIN  payment_bankaccounts AS b ON (t.account_id=b.id)
                                     WHERE  recongroup_id = {?}',
                                   $recongp['id']);
                 $recongp['transfers'] = $res->fetchAllAssoc();
@@ -895,7 +901,7 @@ class PaymentModule extends PLModule
 
             // create transfers
             XDB::execute('INSERT INTO  payment_transfers
-                               SELECT  NULL, {?}, t.ref, SUM(t.amount+t.commission), NULL, p.text, NULL
+                               SELECT  NULL, {?}, t.ref, SUM(t.amount+t.commission), p.rib_id, p.text, NULL
                                  FROM  payment_transactions AS t
                             LEFT JOIN  payments             AS p ON (t.ref = p.id)
                             LEFT JOIN  groups               AS g ON (p.asso_id = g.id)
index 344712f..46bf7f0 100644 (file)
@@ -66,7 +66,7 @@ class BPLCCyberPlus
         $log = S::v('log');
 
         // Transaction's reference computation.
-        $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
+        $prefix = rand_url_id();
         $fullref = substr("$prefix-{$pay->id}",-12); // FIXME : check for duplicates
         $ts = time();
         $trans_date = gmdate("YmdHis", $ts);
index a6d9ab4..f5232d1 100644 (file)
@@ -91,7 +91,7 @@ class PayPal
         }
 
         // We build the transaction's reference
-        $prefix = ($pay->flags->hasflag('unique')) ? str_pad("", 15, "0") : rand_url_id();
+        $prefix = rand_url_id();
         $fullref = substr("$prefix-xorg-{$pay->id}", -15);
 
         $this->infos['commande'] = array(
index baa18b1..3c4776a 100644 (file)
@@ -370,9 +370,14 @@ class PlatalModule extends PLModule
         $mymail->setFrom('"Gestion des mots de passe" <support+password@' . $globals->mail->domain . '>');
         if (is_null($to)) {
             $mymail->addTo($user);
-            $mymail->addTo($inactives_to);
+            $log_to = $user->bestEmail();
+            if (!is_null($inactives_to)) {
+                $log_to = $inactives_to . ', ' . $log_to;
+                $mymail->addTo($inactives_to);
+            }
         } else {
             $mymail->addTo($to);
+            $log_to = $to;
         }
         $mymail->setSubject("Ton certificat d'authentification");
         $mymail->setTxtBody("Visite la page suivante qui expire dans six heures :
@@ -388,7 +393,7 @@ Email envoyé à ".Env::v('login') . (is_null($to) ? '' : '
 Adresse de secours : ' . $to));
         $mymail->send();
 
-        S::logger($user->id())->log('recovery', is_null($to) ? $inactives_to . ', ' . $user->bestEmail() : $to);
+        S::logger($user->id())->log('recovery', $log_to);
     }
 
     function handler_recovery_ext($page)
index 27478a1..79196c4 100644 (file)
@@ -426,8 +426,7 @@ class RegisterModule extends PLModule
                                                       VALUES  ({?}, {?})',
                                          $uid, $asso_id);
                             try {
-                                $mmlist = new MMList($user);
-                                $mmlist->subscribe("promo" . $yearpromo);
+                                MailingList::subscribePromo($yearpromo, $user);
                             } catch (Exception $e) {
                                 PlErrorReport::report($e);
                                 $page->trigError("L'inscription à la liste promo" . $yearpromo . " a échouée.");
index 1ccb041..a4980a9 100644 (file)
@@ -158,34 +158,48 @@ function createAliases($subState)
     $emailXorg  = PlUser::makeUserName($subState->t('firstname'), $subState->t('lastname'));
     $suffix = (User::$sub_mail_domains[$type] ? substr(User::$sub_mail_domains[$type], 0, 1) : '') . substr($subState->v('yearpromo'), -2);
     $emailXorg2 = $emailXorg . '.' . $suffix;
+    // Search for homonyms:
+    //  * first case: only one homonym already registered.
     $res = XDB::query('SELECT  uid, expire
                          FROM  email_source_account
                         WHERE  email = {?} AND type != \'alias_aux\'',
                       $emailXorg);
-    if ($res->numRows()) {
-        list($h_id, $expire) = $res->fetchOneRow();
-        if (empty($expire)) {
-            XDB::execute('UPDATE  email_source_account
-                             SET  expire = ADDDATE(NOW(), INTERVAL 1 MONTH)
-                           WHERE  email = {?} AND type != \'alias_aux\'',
+    //  * second case: at least two homonyms registerd.
+    $result = XDB::query("SELECT  hrmid
+                            FROM  email_source_other
+                           WHERE  type = 'homonym' AND email = {?}",
                          $emailXorg);
-            $hrmid = User::makeHomonymHrmid($emailXorg);
+    if ($res->numRows() || $result->numRows()) {
+        if ($res->numRows()) {
+            list($h_id, $expire) = $res->fetchOneRow();
+            if (empty($expire)) {
+                XDB::execute('UPDATE  email_source_account
+                                 SET  expire = ADDDATE(NOW(), INTERVAL 1 MONTH)
+                               WHERE  email = {?} AND type != \'alias_aux\'',
+                             $emailXorg);
+                $hrmid = User::makeHomonymHrmid($emailXorg);
+                XDB::execute('INSERT IGNORE INTO  homonyms_list (hrmid, uid)
+                                          VALUES  ({?}, {?}), ({?}, {?})',
+                             $hrmid, $h_id, $hrmid, $subState->i('uid'));
+                $als = XDB::fetchColumn('SELECT  email
+                                           FROM  email_source_account
+                                          WHERE  uid = {?} AND type != \'alias_aux\' AND expire IS NULL',
+                                        $h_id);
+
+                $homonym = User::getSilentWithUID($h_id);
+                $mailer = new PlMailer('register/lostalias.mail.tpl');
+                $mailer->addTo($homonym);
+                $mailer->setSubject("Perte de ton alias $emailXorg dans un mois !");
+                $mailer->assign('emailXorg', $emailXorg);
+                $mailer->assign('als', join(', ', $als));
+                $mailer->SetTxtBody(wordwrap($msg,72));
+                $mailer->send();
+            }
+        } else {
+            $hrmid = $result->fetchOneCell();
             XDB::execute('INSERT IGNORE INTO  homonyms_list (hrmid, uid)
-                                      VALUES  ({?}, {?}), ({?}, {?})',
-                         $hrmid, $h_id, $hrmid, $subState->i('uid'));
-            $als = XDB::fetchColumn('SELECT  email
-                                       FROM  email_source_account
-                                      WHERE  uid = {?} AND type != \'alias_aux\' AND expire IS NULL',
-                                    $h_id);
-
-            $homonym = User::getSilentWithUID($h_id);
-            $mailer = new PlMailer('register/lostalias.mail.tpl');
-            $mailer->addTo($homonym);
-            $mailer->setSubject("Perte de ton alias $emailXorg dans un mois !");
-            $mailer->assign('emailXorg', $emailXorg);
-            $mailer->assign('als', join(', ', $als));
-            $mailer->SetTxtBody(wordwrap($msg,72));
-            $mailer->send();
+                                      VALUES  ({?}, {?})',
+                         $hrmid, $subState->i('uid'));
         }
 
         $subState->set('forlife', $forlife);
index 933d6d2..0da98ab 100644 (file)
@@ -680,17 +680,19 @@ class XnetGrpModule extends PLModule
             $page->trigSuccess('Relances effectuées avec succès.');
         }
 
-        $registration_date = XDB::fetchAllAssoc('uid', 'SELECT  uid, date
-                                                          FROM  register_pending_xnet
-                                                         WHERE  uid IN {?}', $uids);
-        $last_date = XDB::fetchAllAssoc('uid', 'SELECT  uid, last_date
-                                                  FROM  register_pending_xnet
-                                                 WHERE  uid IN {?}', $uids);
+        if ($uids) {
+            $registration_date = XDB::fetchAllAssoc('uid', 'SELECT  uid, date
+                                                              FROM  register_pending_xnet
+                                                             WHERE  uid IN {?}', $uids);
+            $last_date = XDB::fetchAllAssoc('uid', 'SELECT  uid, last_date
+                                                      FROM  register_pending_xnet
+                                                     WHERE  uid IN {?}', $uids);
 
-        $users = User::getBulkUsersWithUIDs($uids);
-        $page->assign('users', $users);
-        $page->assign('registration_date', $registration_date);
-        $page->assign('last_date', $last_date);
+            $users = User::getBulkUsersWithUIDs($uids);
+            $page->assign('users', $users);
+            $page->assign('registration_date', $registration_date);
+            $page->assign('last_date', $last_date);
+        }
 
     }
 
index 8fb6fe0..2db6c73 100644 (file)
@@ -23,8 +23,6 @@ Platal::load('lists');
 
 class XnetListsModule extends ListsModule
 {
-    var $client;
-
     function handlers()
     {
         return array(
@@ -54,41 +52,31 @@ class XnetListsModule extends ListsModule
         );
     }
 
-    function prepare_client($page, $user = null)
+    protected function get_lists_domain()
     {
         global $globals;
-        Platal::load('lists', 'lists.inc.php');
-
-        if (is_null($user)) {
-            $user =& S::user();
-        }
-        $this->client = new MMList($user, $globals->asso('mail_domain'));
-
-        $page->assign('asso', $globals->asso());
-        $page->setType($globals->asso('cat'));
-
         return $globals->asso('mail_domain');
     }
 
     function handler_lists($page, $order_by = null, $order = null)
     {
-        global $globals;
         require_once 'emails.inc.php';
 
-        if (!$globals->asso('mail_domain')) {
+        if (!$this->get_lists_domain()) {
             return PL_NOT_FOUND;
         }
-        $this->prepare_client($page);
         $page->changeTpl('xnetlists/index.tpl');
 
         if (Get::has('del')) {
             S::assert_xsrf_token();
-            $this->client->unsubscribe(Get::v('del'));
+            $mlist = $this->prepare_list(Get::v('del'));
+            $mlist->unsubscribe();
             pl_redirect('lists');
         }
         if (Get::has('add')) {
             S::assert_xsrf_token();
-            $this->client->subscribe(Get::v('add'));
+            $mlist = $this->prepare_list(Get::v('add'));
+            $mlist->subscribe();
             pl_redirect('lists');
         }
 
@@ -97,11 +85,12 @@ class XnetListsModule extends ListsModule
 
             $alias = Post::t('del_alias');
             list($local_part, ) = explode('@', $alias);
-            delete_list_alias($local_part, $globals->asso('mail_domain'));
+            delete_list_alias($local_part, $this->get_lists_domain());
             $page->trigSuccess($alias . ' supprimé&nbsp;!');
         }
 
-        $listes = $this->client->get_lists();
+        $client = $this->prepare_client();
+        $listes = $client->get_lists();
         // Default ordering is by ascending names.
         if (is_null($order_by) || is_null($order)
             || !in_array($order_by, array('list', 'desc', 'nbsub'))
@@ -135,12 +124,13 @@ class XnetListsModule extends ListsModule
         $page->assign('listes', $listes);
         $page->assign('order_by', $order_by);
         $page->assign('order', $order);
-        $page->assign('aliases', iterate_list_alias($globals->asso('mail_domain')));
+        $page->assign('aliases', iterate_list_alias($this->get_lists_domain()));
         $page->assign('may_update', may_update());
         if (S::suid()) {
             $page->trigWarning("Attention&nbsp;: l'affichage des listes de diffusion ne tient pas compte de l'option « Voir le site comme&hellip; ».");
         }
 
+        global $globals;
         if (count($listes) > 0 && !$globals->asso('has_ml')) {
             XDB::execute("UPDATE  groups
                              SET  flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml')
@@ -151,12 +141,9 @@ class XnetListsModule extends ListsModule
 
     function handler_create($page)
     {
-        global $globals;
-
-        if (!$globals->asso('mail_domain')) {
+        if (!$this->get_lists_domain()) {
             return PL_NOT_FOUND;
         }
-        $this->prepare_client($page);
         $page->changeTpl('xnetlists/create.tpl');
 
         if (!Post::has('submit')) {
@@ -177,7 +164,7 @@ class XnetListsModule extends ListsModule
         }
 
         require_once 'emails.inc.php';
-        if (list_exist($list, $globals->asso('mail_domain'))) {
+        if (list_exist($list, $this->get_lists_domain())) {
             $page->trigError('Cet alias est déjà pris.');
             return;
         }
@@ -186,17 +173,19 @@ class XnetListsModule extends ListsModule
             return;
         }
 
-        $success = $this->client->create_list($list, utf8_decode(Post::t('desc')), Post::t('advertise'),
-                                              Post::t('modlevel'), Post::t('inslevel'),
-                                              array(S::user()->forlifeEmail()), array(S::user()->forlifeEmail()));
+        $mlist = $this->prepare_list($list);
+        $success = $mlist->create(Post::t('desc'),
+            Post::t('advertise'), Post::t('modlevel'), Post::t('inslevel'),
+            array(S::user()->forlifeEmail()), array(S::user()->forlifeEmail()));
 
         if (!$success) {
             $page->kill("Un problème est survenu, contacter "
                         ."<a href='mailto:support@m4x.org'>support@m4x.org</a>");
             return;
         }
-        create_list($list, $globals->asso('mail_domain'));
+        create_list($mlist->mbox, $mlist->domain);
 
+        global $globals;
         XDB::execute("UPDATE  groups
                          SET  flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml')
                        WHERE  id = {?}",
@@ -207,23 +196,27 @@ class XnetListsModule extends ListsModule
 
     function handler_sync($page, $liste = null)
     {
-        global $globals;
-
-        if (!$globals->asso('mail_domain')) {
+        if (!$this->get_lists_domain()) {
+            return PL_NOT_FOUND;
+        }
+        if (!$liste) {
             return PL_NOT_FOUND;
         }
-        $this->prepare_client($page);
+
         $page->changeTpl('xnetlists/sync.tpl');
 
+        $mlist = $this->prepare_list($liste);
+
         if (Env::has('add')) {
             S::assert_xsrf_token();
-            $this->client->mass_subscribe($liste, array_keys(Env::v('add')));
+            $mlist->subscribeBulk(array_keys(Env::v('add')));
         }
 
-        list(,$members) = $this->client->get_members($liste);
+        list(,$members) = $mlist->getMembers();
         $mails = array_map(create_function('$arr', 'return $arr[1];'), $members);
         $subscribers = array_unique($mails);
 
+        global $globals;
         $ann = XDB::fetchColumn('SELECT  uid
                                    FROM  group_members
                                   WHERE  asso_id = {?}', $globals->asso('id'));
@@ -241,16 +234,15 @@ class XnetListsModule extends ListsModule
 
     function handler_aadmin($page, $lfull = null)
     {
-        global $globals;
-
-        if (!$globals->asso('mail_domain') || is_null($lfull)) {
+        if (!$this->get_lists_domain() || is_null($lfull)) {
             return PL_NOT_FOUND;
         }
         $page->changeTpl('xnetlists/alias-admin.tpl');
 
         require_once 'emails.inc.php';
         list($local_part, $domain) = explode('@', $lfull);
-        if ($globals->asso('mail_domain') != $domain || !preg_match("/^[a-zA-Z0-9\-\.]*$/", $local_part)) {
+        if ($this->get_lists_domain() != $domain || !preg_match("/^[a-zA-Z0-9\-\.]*$/", $local_part)) {
+            global $globals;
             $page->trigErrorRedirect('Le nom de l\'alias est erroné.', $globals->asso('diminutif') . '/lists');
         }
 
@@ -280,9 +272,7 @@ class XnetListsModule extends ListsModule
 
     function handler_acreate($page)
     {
-        global $globals;
-
-        if (!$globals->asso('mail_domain')) {
+        if (!$this->get_lists_domain()) {
             return PL_NOT_FOUND;
         }
         $page->changeTpl('xnetlists/alias-create.tpl');
@@ -305,13 +295,14 @@ class XnetListsModule extends ListsModule
         }
 
         require_once 'emails.inc.php';
-        if (list_exist($list, $globals->asso('mail_domain'))) {
+        $lists_domain = $this->get_lists_domain();
+        if (list_exist($list, $lists_domain)) {
             $page->trigError('Cet alias est déjà pris.');
             return;
         }
 
-        add_to_list_alias(S::i('uid'), $list, $globals->asso('mail_domain'));
-        pl_redirect('alias/admin/' . $list . '@' . $globals->asso('mail_domain'));
+        add_to_list_alias(S::i('uid'), $list, $lists_domain);
+        pl_redirect('alias/admin/' . $list . '@' . $lists_domain);
     }
 
     function handler_profile($page, $user = null)
index abfb165..ccf45fc 100644 (file)
@@ -29,6 +29,8 @@ function smarty_function_profile($params, $smarty)
     $with_groupperms = $params->b('groupperms', true);
     $raw = $params->b('raw', false);
     $user = $params->v('user');
+    $profile = $params->v('profile');
+
     if (is_int($user) || ctype_digit($user)) {
         $user = User::getWithUID($user);
     }
@@ -52,7 +54,10 @@ function smarty_function_profile($params, $smarty)
         $name = '&bull;' . $name;
     }
     if ($with_link) {
-        $profile = ($user instanceof Profile) ? $user : $user->profile();
+        if (is_null($profile)) {
+            $profile = $user->profile();
+        }
+
         if ($profile) {
             $name = '<a href="profile/' . $profile->hrid() . '" class="popup2">' . $name . '</a>';
         }
index 74d07d1..d7cf838 100644 (file)
       <a href="admin/payments">Paiements</a>
       &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="admin/reconcile">Virements</a>
+      &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="admin/reconcile/bankaccounts">RIBs</a>
+      &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="admin/payments/methods">Méthodes de paiement</a>
     </td>
   </tr>
   <tr class="pair">
index 86e19b9..12a84e5 100644 (file)
@@ -164,10 +164,10 @@ et cliquer sur les icones {icon name=add} pour les ajouter à cette liste.
     {else}
     Tu surveilles {if $nonins|@count eq 1}le non-inscrit{else}les non-inscrits{/if}&nbsp;:
     <ul>
-    {foreach from=$nonins item=p}
+    {foreach from=$nonins item=u}
     <li>
-      {profile user=$p promo=true sex=true}
-      <a href="carnet/notifs/del_nonins/{$p->login()}?token={xsrf_token}">{icon name='cross' title='retirer'}</a>
+      {profile user=$u promo=true sex=true}
+      <a href="carnet/notifs/del_nonins/{$u->login()}?token={xsrf_token}">{icon name='cross' title='retirer'}</a>
     </li>
     {/foreach}
   </ul>
index 5f65363..39bbdc9 100644 (file)
 {**************************************************************************}
 
 {assign var=lostUsers value=false}
-{foreach from=$list item=users key=sort_key}
-{foreach from=$users item=user name=all}
+{foreach from=$list item=members key=sort_key}
+{foreach from=$members item=member name=all}
+  {assign var=user value=$member.user}
+  {assign var=profile value=$member.profile}
+  {assign var=email value=$member.email}
+
 <tr>
   <td class='titre' style="width: 20%">
     {if $smarty.foreach.all.first}
     {/if}
   </td>
   <td>
-    {if t($user.hasProfile)}
-      {if t($user.lost)}{assign var=lostUsers value=true}{/if}
-      {profile user=$user.uid promo=$promo}
-    {elseif t($user.uid)}
-      <a href="mailto:{$user.email}">{if t($user.name)}{$user.name}{else}{$user.email}{/if}{if t($promo)} (extérieur){/if}</a>
-    {else}
-      <a href="mailto:{$user.email}">{if t($user.name)}{$user.name}{else}{$user.email}{/if}</a>
+    {if t($profile)}
+      {if $user->lost}{assign var=lostUsers value=true}{/if}
+      {profile user=$user profile=$profile promo=$promo}
+    {elseif t($user)}
+      <a href="mailto:{$email}">{if $user->directoryName}{$user->directoryName}{else}{$email}{/if}{if not t($promo)} (extérieur){/if}</a>
+    {else}{* Email without account or email *}
+      <a href="mailto:{$email}">{$email}</a>
     {/if}
   </td>
   {if t($delete)}
   <td class="center">
-    {if t($user.uid)}
-    <a href="{$platal->ns}member/{$user.uid}">{icon name=user_edit title='Éditer'}</a>&nbsp;
+    {if t($member.user)}
+    <a href="{$platal->ns}member/{$member.user->uid}">{icon name=user_edit title='Éditer'}</a>&nbsp;
     {else}
     {icon name=null}&nbsp;
     {/if}
-    <a href='{$platal->pl_self(1)}?{$delete}={$user.email}&amp;token={xsrf_token}'>{icon name=cross title='Retirer'}</a>
+    <a href='{$platal->pl_self(1)}?{$delete}={$member.email}&amp;token={xsrf_token}'>{icon name=cross title='Retirer'}</a>
   </td>
   {/if}
 </tr>
index f0117ee..7034d99 100644 (file)
@@ -46,7 +46,7 @@
       {/if}
     </td>
   </tr>
-  {if $details.own || hasPerms('admin,groupadmin')}
+  {if $details.own || hasPerms('admin') || $group_admin}
   <tr>
     <td><strong>Administrer la liste&nbsp;:</strong></td>
     <td>
@@ -73,8 +73,7 @@
     </td>
   </tr>
   {/if}
-  {if hasPerms('admin,groupadmin')}
-
+  {if hasPerms('admin') || $group_admin}
   <tr>
     <td><strong>Administrer (avancé)&nbsp;:</strong></td>
     <td>
index 8332667..4f41fbf 100644 (file)
 
 {$issue->head($user, 'text')}
 
+{foreach from=$issue->arts key=cid item=arts}
+--------------------------------------------------------------------
+*{$issue->category($cid)}*
+--------------------------------------------------------------------
+
+{foreach from=$arts item=art}
+{$art->toText($hash, $user->login())}
+
+{/foreach}
+{/foreach}
+
 {$issue->signature('text')}
 
 --------------------------------------------------------------------
@@ -79,10 +90,18 @@ ne plus recevoir : &lt;https://www.polytechnique.org/fxletter/out/{if $hash}{$ha
     <div class='fx_mail'>
       <div class="title">{$issue->title()}</div>
       <div class="intro">{$issue->head($user, 'html')|smarty:nodefaults}</div>
+      {foreach from=$issue->arts key=cid item=arts name=cats}
+      <h1 class="category"><a id="cat{$cid}"></a>
+        {$issue->category($cid)}
+      </h1>
+      {foreach from=$arts item=art}
+        {$art->toHtml($hash, $user->login())|smarty:nodefaults}
+      {/foreach}
+      {/foreach}
       <div class="signature">{$issue->signature('html')|smarty:nodefaults}</div>
       <div class="give"><a href="http://fondationx.fr/fond/paiement.php">Faire un don</a></div>
       <div class="foot1">
-        Cette lettre est envoyée par la FX grâce aux outils de Polytechnique.org.
+        Cette lettre est envoyée par la Fondation grâce aux outils de Polytechnique.org.
       </div>
       <div class="foot2">
         [<a href="https://www.polytechnique.org/fxletter">archives</a>&nbsp;|
index 8770588..d517c10 100644 (file)
@@ -94,7 +94,7 @@
                                                <td>{$transfer.id}</td>
                                                <td>{if $transfer.date}{$transfer.date}{else}à virer{/if}</td>
                                                <td><small>{$transfer.message}</small></td>
-                                               <td>{$transfer.account}</td>
+                                               <td>{$transfer.owner}</td>
                                                <td class="right">{$transfer.amount}</td>
                                                <td class="right">
                                                  {if !$transfer.date}<a href="admin/reconcile/transfers/confirm/{$transfer.id}?token={xsrf_token}">{icon name=tick title='Confirmer la réalisation'}</a>{/if}
index 9e7b57b..8eaae5a 100644 (file)
@@ -66,8 +66,6 @@
       <span class="smaller">Ils déterminent la façon dont
       {if $isMe}ton{else}son{/if} nom apparaît sur les annuaires
       en ligne et papier et ta fiche apparaitra quand on cherche un de ces noms.</span><br/>
-      <div class="small center">Si un de tes noms commence par une particule,
-      coche la case en bout de ligne.</div>
     </td>
   </tr>
   {include file="profile/general.public_names.tpl" names=$search_names.public_names}
index 28d18ec..e21a35f 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-<h1>{$asso->nom}&nbsp;: Administration des announces</h1>
+<h1>{$asso->nom}&nbsp;: Administration des annonces</h1>
 
 <table class="bicol">
   <tr>
index a3cd289..84fa71d 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{if $users|@count}
+{if t($users) && $users|@count}
 <form action="{$platal->ns}directory/awact" method="post">
   {xsrf_token_field}
   <table cellspacing="2" cellpadding="0" class="tiny">
index f672c20..976afda 100644 (file)
@@ -100,7 +100,8 @@ croix verte te permet de t'inscrire, après accord des responsables si l'inscrip
     <td>
       {if $l.own}
       {icon name=wrench title="Modérateur"}
-      {elseif $l.priv}
+      {/if}
+      {if $l.priv}
       {icon name=weather_cloudy title="Liste privée"}
       {/if}
       <a href='{$platal->ns}lists/members/{$l.list}'>{$l.list}</a>
diff --git a/upgrade/1.1.6/01_survey_answer.sql b/upgrade/1.1.6/01_survey_answer.sql
new file mode 100644 (file)
index 0000000..a600f5e
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE survey_answers CHANGE COLUMN id id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.6/02_payments.sql b/upgrade/1.1.6/02_payments.sql
new file mode 100644 (file)
index 0000000..5813f3d
--- /dev/null
@@ -0,0 +1,4 @@
+ALTER TABLE payments ADD COLUMN rib_id INT(11) NULL DEFAULT NULL ;
+ALTER TABLE payments ADD CONSTRAINT fk_rib_id FOREIGN KEY (rib_id) REFERENCES payment_bankaccounts(id);
+
+-- vim=set syntax=mysql:
diff --git a/upgrade/1.1.6/README b/upgrade/1.1.6/README
new file mode 100644 (file)
index 0000000..b382cce
--- /dev/null
@@ -0,0 +1,2 @@
+1. Run all migrations (update.sh)
+2. Profit.
diff --git a/upgrade/1.1.6/connect.db.inc.php b/upgrade/1.1.6/connect.db.inc.php
new file mode 120000 (symlink)
index 0000000..442fab7
--- /dev/null
@@ -0,0 +1 @@
+../../bin/connect.db.inc.php
\ No newline at end of file
diff --git a/upgrade/1.1.6/update.sh b/upgrade/1.1.6/update.sh
new file mode 100755 (executable)
index 0000000..9230e34
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+. ../inc/pervasive.sh
+
+###########################################################
+[ "$DATABASE" != "x4dat" ] || die "Cannot target x4dat"
+
+confirm "* Running database upgrade scripts"
+mysql_run_directory .