X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fuser.func.inc.php;h=93244a4c19a1d9ecc0f8349dc249ac31985ca9a2;hb=7586ae0b2187c222701143b4ac8b74f13282bcba;hp=09ffcc1b0487bb2b00b79af015d87a413dea9295;hpb=22801bd99c3622a107c7fa0b4338b1447b169973;p=platal.git diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 09ffcc1..93244a4 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -32,9 +32,9 @@ function user_clear_all_subs($user_id, $really_del=true) // + delete maillists global $globals; - $uid = intval($user_id); - $res = XDB::query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $uid); - $alias = $res->fetchOneCell(); + $uid = intval($user_id); + $user = User::getSilent($uid); + list($alias) = explode('@', $user->forlifeEmail()); $tables_to_clear = array('uid' => array('competences_ins', 'entreprises', 'langues_ins', 'mentor_pays', 'mentor_secteurs', 'mentor', 'perte_pass', 'watch_sub'), @@ -75,7 +75,7 @@ function user_clear_all_subs($user_id, $really_del=true) if ($globals->mailstorage->googleapps_domain) { require_once 'googleapps.inc.php'; if (GoogleAppsAccount::account_status($uid)) { - $account = new GoogleAppsAccount($uid, $alias); + $account = new GoogleAppsAccount($user); $account->suspend(); } } @@ -87,8 +87,7 @@ function user_clear_all_subs($user_id, $really_del=true) // Defaut callback to call when a login is not found function _default_user_callback($login) { - global $page; - $page->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login"); + Platal::page()->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login"); return; } @@ -104,7 +103,7 @@ function _silent_user_callback($login) // When no user is found, calls @p callback, and eventually returns false. function get_user_login($data, $get_forlife = false, $callback = '_default_user_callback') { - global $globals, $page; + global $globals; // In order to reduce the code size & complexity, we define once for all the // field to be returned. By convention if will be "u.hruid" for the hruid @@ -210,7 +209,7 @@ function get_user_login($data, $get_forlife = false, $callback = '_default_user_ return $res->fetchOneCell(); } else if ($res->numRows() > 0) { if (S::has_perms()) { - $page->trigError("Il y a $user_count utilisateurs avec cette adresse mail : " . join(', ', $res->fetchColumn())); + Platal::page()->trigError("Il y a $user_count utilisateurs avec cette adresse mail : " . join(', ', $res->fetchColumn())); } else { $res->free(); } @@ -242,16 +241,28 @@ function get_users_login_list($members, $strict = false, $get_forlife = false, $ if (strlen(trim($members)) == 0) { return null; } - $members = explode(' ', $members); + $members = split("[; ,\r\n\|]+", $members); } if ($members) { $list = array(); foreach ($members as $i => $alias) { + $alias = trim($alias); + if (empty($alias)) { + continue; + } if (($login = get_user_login($alias, $get_forlife, $callback)) !== false) { $list[$i] = $login; - } else if(!$strict) { + } else if (!$strict) { $list[$i] = $alias; + } else { + global $globals; + if (strpos($alias, '@') !== false) { + list($user, $dom) = explode('@', $alias); + if ($dom != $globals->mail->domain && $dom != $globals->mail->domain2) { + $list[$i] = $alias; + } + } } } return $list; @@ -260,22 +271,6 @@ function get_users_login_list($members, $strict = false, $get_forlife = false, $ } // }}} -// {{{ function get_user_forlife() - -function get_user_forlife($data, $callback = '_default_user_callback') -{ - return get_user_login($data, true, $callback); -} - -// }}} -// {{{ function get_users_forlife_list() - -function get_users_forlife_list($members, $strict = false, $callback = '_default_user_callback') -{ - return get_users_login_list($members, $strict, true, $callback); -} - -// }}} // {{{ function get_user_hruid() function get_user_hruid($data, $callback = '_default_user_callback') @@ -324,7 +319,7 @@ function get_not_registered_user($login, $iterator = false) } $sql = "SELECT user_id, nom, prenom, promo FROM auth_user_md5 - WHERE $where + WHERE $where AND perms = 'pending' ORDER BY promo, nom, prenom"; if ($iterator) { return XDB::iterator($sql, $nom, $prenom, $promo);