From d47dcad7cd97a90d35bbf923764e7b8afe7e64bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Tue, 20 Jul 2010 11:39:26 +0200 Subject: [PATCH] Uses some profile informations (pormotions) to retrieve a login. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- classes/user.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/classes/user.php b/classes/user.php index dcfe34e..f4f68c3 100644 --- a/classes/user.php +++ b/classes/user.php @@ -91,16 +91,20 @@ class User extends PlUser return $res->fetchOneCell(); } - /** TODO: implements this by inspecting the profile. if (preg_match('/^(.*)\.([0-9]{4})$/u', $mbox, $matches)) { $res = XDB::query('SELECT a.uid - FROM accounts AS a - INNER JOIN aliases AS al ON (al.id = a.uid AND al.type IN ('alias', 'a_vie')) - WHERE al.alias = {?} AND a.promo = {?}', $matches[1], $matches[2]); + FROM accounts AS a + INNER JOIN aliases AS al ON (al.uid = a.uid AND al.type IN (\'alias\', \'a_vie\')) + INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET(\'owner\', ap.perms)) + INNER JOIN profiles AS p ON (p.pid = ap.pid) + INNER JOIN profile_education AS pe ON (p.pid = pe.pid AND FIND_IN_SET(\'primary\', pe.flags)) + WHERE p.hrpid = {?} OR ((pe.entry_year <= {?} AND pe.grad_year >= {?}) AND al.alias = {?}) + GROUP BY a.uid', + $matches[0], $matches[2], $matches[2], $matches[1]); if ($res->numRows() == 1) { return $res->fetchOneCell(); } - }*/ + } throw new UserNotFoundException(); } -- 2.1.4