- $res = XDB::query('SELECT u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
- matricule, password, FIND_IN_SET(\'femme\', u.flags) AS femme,
- a.alias AS forlife, a2.alias AS bestalias,
- q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
- FIND_IN_SET(\'watch\', u.flags) AS watch_account, q.last_version, g.g_account_name IS NOT NULL AS googleapps
- FROM auth_user_md5 AS u
- INNER JOIN auth_user_quick AS q USING(user_id)
- INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = \'a_vie\')
- INNER JOIN aliases AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags))
- LEFT JOIN gapps_accounts AS g ON (u.user_id = g.l_userid AND g.g_status = \'active\')
- WHERE u.user_id = {?} AND u.perms IN(\'admin\', \'user\')', $uid);
+ /** TODO: Move needed informations to account tables */
+ /** TODO: Currently suppressed data are matricule, promo */
+ /** TODO: Use the User object to fetch all this */
+ $res = XDB::query("SELECT a.uid, a.hruid, a.display_name, a.full_name,
+ a.sex = 'female' AS femme, a.email_format,
+ a.token, FIND_IN_SET('watch', a.flags) AS watch_account,
+ UNIX_TIMESTAMP(fp.last_seen) AS banana_last, UNIX_TIMESTAMP(w.last) AS watch_last,
+ a.last_version, g.g_account_name IS NOT NULL AS googleapps,
+ UNIX_TIMESTAMP(s.start) AS lastlogin, s.host,
+ a.is_admin, at.perms
+ FROM accounts AS a
+ INNER JOIN account_types AS at ON(a.type = at.type)
+ INNER JOIN watch AS w ON(w.uid = a.uid)
+ LEFT JOIN forum_profiles AS fp ON(fp.uid = a.uid)
+ LEFT JOIN gapps_accounts AS g ON(a.uid = g.l_userid AND g.g_status = 'active')
+ LEFT JOIN logger.last_sessions AS ls ON (ls.uid = a.uid)
+ LEFT JOIN logger.sessions AS s ON(s.id = ls.id)
+ WHERE a.uid = {?} AND a.state = 'active'", $user->id());
+ if ($res->numRows() != 1) {
+ return false;
+ }
+