- "SELECT u.user_id, count(e.email) AS nb_mails, u.nom, u.prenom, u.promo
- FROM aliases AS a
- INNER JOIN auth_user_md5 AS u ON a.id = u.user_id
- LEFT JOIN emails AS e ON (e.uid = u.user_id
- AND FIND_IN_SET('active', e.flags) AND e.panne = 0)
- WHERE a.alias = {?}
- GROUP BY u.user_id", $alias);
+ 'SELECT a.uid, count(DISTINCT(r.redirect)) AS nb_mails,
+ IFNULL(pd.public_name, a.full_name) AS fullname,
+ IFNULL(pd.promo, 0) AS promo, IFNULL(pce.name, \'Aucun\') AS corps,
+ IFNULL(pje.name, \'Aucun\') AS job, GROUP_CONCAT(pn.address SEPARATOR \', \') AS networking
+ FROM email_source_account AS s
+ INNER JOIN accounts AS a ON (s.uid = a.uid)
+ LEFT JOIN email_redirect_account AS r ON (a.uid = r.uid AND r.broken_level = 0 AND r.flags = \'active\' AND
+ (r.type = \'smtp\' OR r.type = \'googleapps\'))
+ LEFT JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET(\'owner\', ap.perms))
+ LEFT JOIN profile_display AS pd ON (pd.pid = ap.pid)
+ LEFT JOIN profile_corps AS pc ON (pc.pid = ap.pid)
+ LEFT JOIN profile_corps_enum AS pce ON (pc.current_corpsid = pce.id)
+ LEFT JOIN profile_job AS pj ON (pj.pid = ap.pid)
+ LEFT JOIN profile_job_enum AS pje ON (pj.jobid = pje.id)
+ LEFT JOIN profile_networking AS pn ON (pn.pid = ap.pid)
+ WHERE s.email = {?}
+ GROUP BY a.uid', $alias);