From 0001ba7a34dc3b535407cb1b961781c3c69c0ccd Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 14 Feb 2009 21:04:15 +0100 Subject: [PATCH] Some extra auth_user fixes. Signed-off-by: Florent Bruneau --- modules/googleapps.php | 3 +-- modules/marketing.php | 16 +++++++++------- modules/openid/openid.inc.php | 18 ++++-------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/modules/googleapps.php b/modules/googleapps.php index 05a6990..de3d668 100644 --- a/modules/googleapps.php +++ b/modules/googleapps.php @@ -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é.'); } diff --git a/modules/marketing.php b/modules/marketing.php index 10c8791..52294fb 100644 --- a/modules/marketing.php +++ b/modules/marketing.php @@ -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; } diff --git a/modules/openid/openid.inc.php b/modules/openid/openid.inc.php index 5c3cab0..d5f7c5c 100644 --- a/modules/openid/openid.inc.php +++ b/modules/openid/openid.inc.php @@ -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 +?> -- 2.1.4