Some extra auth_user fixes.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 14 Feb 2009 20:04:15 +0000 (21:04 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 14 Feb 2009 20:04:15 +0000 (21:04 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/googleapps.php
modules/marketing.php
modules/openid/openid.inc.php

index 05a6990..de3d668 100644 (file)
@@ -198,8 +198,7 @@ class GoogleAppsModule extends PLModule
 
             // Force synchronization of plat/al and Google Apps passwords.
             if ($action == 'forcesync' && $account->sync_password) {
-                $res = XDB::query("SELECT password FROM auth_user_md5 WHERE user_id = {?}", $user->id());
-                $account->set_password($res->fetchOneCell());
+                $account->set_password($user->password());
                 $page->trigSuccess('Le mot de passe a été synchronisé.');
             }
 
index 10c8791..52294fb 100644 (file)
@@ -154,13 +154,15 @@ class MarketingModule extends PLModule
             pl_redirect('emails/redirect');
         }
 
-        $res = XDB::query(
-                "SELECT  u.deces = '0000-00-00' AS alive, e.last,
-                         IF(e.email IS NOT NULL, e.email, IF(FIND_IN_SET('googleapps', u.mail_storage), 'googleapps', NULL)) AS email
-                   FROM  auth_user_md5 AS u
-              LEFT JOIN  emails        AS e ON (e.flags = 'active' AND e.uid = u.user_id)
-                  WHERE  u.user_id = {?}
-               ORDER BY  e.panne_level, e.last", $user->id());
+        $res = XDB::query('SELECT  p.deathdate IS NULL AS alive, e.last,
+                                   IF(e.email IS NOT NULL, e.email,
+                                         IF(FIND_IN_SET(\'googleapps\', eo.storage), \'googleapps\', NULL)) AS email
+                             FROM  email_options AS eo
+                        LEFT JOIN  account_profiles AS ap ON (ap.uid = eo.uid AND FIND_IN_SET(\'owner\', ap.perms))
+                        LEFT JOIN  profiles AS p ON (p.pid = ap.pid)
+                        LEFT JOIN  emails        AS e ON (e.flags = \'active\' AND e.uid = eo.uid)
+                            WHERE  eo.uid = {?}
+                         ORDER BY  e.panne_level, e.last', $user->id());
         if (!$res->numRows()) {
             return PL_NOT_FOUND;
         }
index 5c3cab0..d5f7c5c 100644 (file)
@@ -52,19 +52,9 @@ function get_user_by_alias($x) {
     if (is_null($x)) {
         return null;
     }
-    // TODO such a function should probably be provided in the User class
-    // or at least not here
-    $res = XDB::query('SELECT  u.user_id
-                         FROM  auth_user_md5   AS u
-                   INNER JOIN  auth_user_quick AS q USING(user_id)
-                   INNER JOIN  aliases         AS a ON (a.id = u.user_id AND type != \'homonyme\')
-                        WHERE  u.perms IN(\'admin\', \'user\')
-                          AND  q.emails_alias_pub = \'public\'
-                          AND  a.alias = {?}',
-                               $x);
-    if (list($uid) = $res->fetchOneRow()) {
-        $user = User::getSilent($uid);
-    }
+    global $globals;
+    // Should we check the publicity of the alias?
+    $user = User::getSilent($x . '@' . $globals->mail->alias_dom);
     return $user ? $user : null;
 
 }
@@ -127,4 +117,4 @@ function add_trusted_site($user, $url)
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
\ No newline at end of file
+?>