protected static function loadMainFieldsFromUIDs(array $uids, $respect_order = true) { if (empty($uids)) { return PlIteratorUtils::emptyIterator(); } global $globals; $joins = ''; $fields = array(); if ($globals->asso('id')) { $joins .= XDB::format("LEFT JOIN group_members AS gpm ON (gpm.uid = a.uid AND gpm.asso_id = {?})\n", $globals->asso('id')); $fields[] = 'gpm.perms AS group_perms'; $fields[] = 'gpm.comm AS group_comm'; $fields[] = 'gpm.position AS group_position'; } if (count($fields) > 0) { $fields = ', ' . implode(', ', $fields); } else { $fields = ''; } if ($respect_order) { $order = 'ORDER BY ' . XDB::formatCustomOrder('a.uid', $uids); } else { $order = ''; } $uids = array_map(array('XDB', 'escape'), $uids); return XDB::iterator('SELECT a.uid, a.hruid, a.registration_date, h.uid IS NOT NULL AS homonym, a.firstname, a.lastname, IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', mf.name)) AS forlife, IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', df.name)) AS forlife_alternate, IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', mb.name)) AS bestalias, (er.redirect IS NULL AND a.state = \'active\' AND FIND_IN_SET(\'mail\', at.perms)) AS lost, a.email, a.full_name, a.directory_name, a.display_name, a.sort_name, a.sex = \'female\' AS gender, IF(a.state = \'active\', CONCAT(at.perms, \',\', IF(a.user_perms IS NULL, \'\', a.user_perms)), \'\') AS perms, a.user_perms, a.email_format, a.is_admin, a.state, a.type, at.description AS type_description, a.skin, FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment, a.weak_password IS NOT NULL AS weak_access, g.g_account_name IS NOT NULL AS googleapps, a.token IS NOT NULL AS token_access, a.token, a.last_version, s.start AS lastlogin, s.host, fp.last_seen AS banana_last ' . $fields . ' FROM accounts AS a INNER JOIN account_types AS at ON (at.type = a.type) LEFT JOIN email_source_account AS ef ON (ef.uid = a.uid AND ef.type = \'forlife\') LEFT JOIN email_virtual_domains AS mf ON (ef.domain = mf.id) LEFT JOIN email_virtual_domains AS df ON (df.aliasing = mf.id AND df.name LIKE CONCAT(\'%\', {?}) AND df.name NOT LIKE \'alumni.%\') LEFT JOIN email_source_account AS eb ON (eb.uid = a.uid AND FIND_IN_SET(\'bestalias\',eb.flags)) LEFT JOIN email_virtual_domains AS mb ON (a.best_domain = mb.id) LEFT JOIN email_redirect_account AS er ON (er.uid = a.uid AND er.flags = \'active\' AND er.broken_level < 3 AND er.type != \'imap\' AND er.type != \'homonym\') LEFT JOIN homonyms_list AS h ON (h.uid = a.uid) LEFT JOIN gapps_accounts AS g ON (a.uid = g.l_userid AND g.g_status = \'active\') LEFT JOIN log_last_sessions AS ls ON (ls.uid = a.uid) LEFT JOIN log_sessions AS s ON (s.id = ls.id) LEFT JOIN forum_profiles AS fp ON (fp.uid = a.uid) ' . $joins . ' WHERE a.uid IN (' . implode(', ', $uids) . ') GROUP BY a.uid ' . $order, $globals->mail->domain2, $globals->mail->domain2); }
/** Fetches data from the database for the given pids, compatible with * the visibility context. * @param $pids An array of pids * @param $visibility The level of visibility fetched fields must have * @return a PlIterator yielding data suitable for a "new ProfileBlah($data)" * * MUST be reimplemented for each kind of ProfileField. */ public static function fetchData(array $pids, Visibility $visibility) { return PlIteratorUtils::emptyIterator(); }