Last core, implements User::password().
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 30 Dec 2008 21:57:31 +0000 (22:57 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 30 Dec 2008 21:57:31 +0000 (22:57 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/user.php
core
include/validations/listes.inc.php
modules/auth.php
modules/lists.php
modules/xnetlists.php

index a26a75e..7fb56c2 100644 (file)
@@ -144,9 +144,8 @@ class User extends PlUser
                                    CONCAT(af.alias, '@{$globals->mail->domain}') AS forlife,
                                    CONCAT(ab.alias, '@{$globals->mail->domain}') AS bestalias,
                                    a.full_name, a.display_name, a.sex = 'female' AS gender,
-                                   a.email_format, a.password,
-                                   IF (a.state = 'active', at.perms, '') AS perms,
-                                   a.is_admin
+                                   IF(a.state = 'active', at.perms, '') AS perms,
+                                   a.email_format, a.is_admin
                              FROM  accounts AS a
                        INNER JOIN  account_types AS at ON (at.type = a.type)
                        INNER JOIN  profile_display AS d ON (d.uid = a.uid)
@@ -206,6 +205,15 @@ class User extends PlUser
         $this->perm_flags = self::makePerms($this->perms, $this->is_admin);
     }
 
+    // We do not want to store the password in the object.
+    // So, fetch it 'on demand'
+    public function password()
+    {
+        return XDB::fetchOneCell('SELECT  a.password
+                                    FROM  accounts AS a
+                                   WHERE  a.uid = {?}', $this->id());
+    }
+
     /** Return the main profile attached with this account if any.
      */
     public function profile()
diff --git a/core b/core
index 933e1c2..35fff9b 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 933e1c23f280a829faf7c112164341f47957c0fb
+Subproject commit 35fff9b04585817e74f4709f36b70d959ce3224c
index 7b803fa..1bb878e 100644 (file)
@@ -139,7 +139,7 @@ class ListeReq extends Validate
             return 1;
         }
 
-        $list = new MMList(S::user()->id(), S::v('password'), $this->domain);
+        $list = new MMList(S::user()->id(), $this->domain);
         $ret = $list->create_list($this->liste, utf8_decode($this->desc), $this->advertise,
                                   $this->modlevel, $this->inslevel,
                                   $this->owners, $this->members);
index 1601c58..47801ae 100644 (file)
@@ -53,11 +53,7 @@ class AuthModule extends PLModule
         $cle = $globals->core->econfiance;
 
         if (S::v('chall') && $_GET['PASS'] == md5(S::v('chall').$cle)) {
-
-            $res  = XDB::query("SELECT password FROM auth_user_md5 WHERE user_id=10154");
-            $pass = $res->fetchOneCell();
-
-            $list = new MMList(10154, $pass, "x-econfiance.polytechnique.org");
+            $list = new MMList(User::getWithUID(10154), "x-econfiance.polytechnique.org");
             $members = $list->get_members('membres');
             if (is_array($members)) {
                 $membres = Array();
index e7d5674..d1a40cf 100644 (file)
@@ -56,7 +56,7 @@ class ListsModule extends PLModule
             $user = S::user();
         }
 
-        $this->client = new MMList($user->id(), $user->password);
+        $this->client = new MMList($user);
         return $globals->mail->domain;
     }
 
@@ -894,12 +894,13 @@ class ListsModule extends PLModule
         }
     }
 
-    function handler_admin_all(&$page) {
+    function handler_admin_all(&$page)
+    {
         $page->changeTpl('lists/admin_all.tpl');
         $page->setTitle('Administration - Mailing lists');
 
-        $client = new MMList(S::v('uid'), S::v('password'));
-        $listes = $client->get_all_lists();
+        $this->prepare_client($page);
+        $listes = $this->client->get_all_lists();
         $page->assign_by_ref('listes', $listes);
     }
 }
index 35b0f86..4f6dcb2 100644 (file)
@@ -53,13 +53,15 @@ class XnetListsModule extends ListsModule
         );
     }
 
-    function prepare_client(&$page)
+    function prepare_client(&$page, $user = null)
     {
         global $globals;
         Platal::load('lists', 'lists.inc.php');
 
-        $this->client = new MMList(S::v('uid'), S::v('password'),
-                                   $globals->asso('mail_domain'));
+        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'));