|| $dom == $globals->mail->alias_dom2;
}
+ /* Tries to find pending accounts with an hruid close to $login. */
+ public static function getPendingAccounts($login, $iterator = false)
+ {
+ global $globals;
+
+ if (strpos($login, '@') === false) {
+ return null;
+ }
+
+ list($login, $domain) = explode('@', $login);
+
+ if ($domain && $domain != $globals->mail->domain && $domain != $globals->mail->domain2) {
+ return null;
+ }
+
+ $sql = "SELECT uid, full_name
+ FROM accounts
+ WHERE state = 'pending' AND REPLACE(hruid, '-', '') LIKE
+ CONCAT('%', REPLACE(REPLACE(REPLACE({?}, ' ', ''), '-', ''), '\'', ''), '%')
+ ORDER BY full_name";
+ if ($iterator) {
+ return XDB::iterator($sql, $login);
+ } else {
+ $res = XDB::query($sql, $login);
+ return $res->fetchAllAssoc();
+ }
+ }
+
+
public static function iterOverUIDs($uids, $respect_order = true)
{
return new UserIterator(self::loadMainFieldsFromUIDs($uids, $respect_order));
{
global $list_unregistered, $globals;
- /* TODO: fixes this call to a removed function. */
- $users = get_not_registered_user($login, true);
+ $users = User::getPendingAccounts($login, true);
if ($users && $users->total()) {
if (!isset($list_unregistered)) {
$list_unregistered = array();
WHERE a.alias = {?}",
$login);
if ($res->numRows() == 0) {
- // TODO: replace this call to a removed function.
- $x = get_not_registered_user($login);
- if (!$x) {
- $page->trigError("Le login $login ne correspond à aucun X.");
+ $accounts = User::getPendingAccounts($login);
+ if (!$accounts) {
+ $page->trigError("L'identifiant $login ne correspond à aucun X.");
return false;
- } else if (count($x) > 1) {
- $page->trigError("Le login $login correspond a plusieurs camarades.");
+ } else if (count($accounts) > 1) {
+ $page->trigError("L'identifiant $login correspond à plusieurs camarades.");
return false;
}
- $uid = $x[0]['uid'];
+ $uid = $accounts[0]['uid'];
$sub = false;
} else {
list($uid, $login) = $res->fetchOneRow();
Camarade :
<select name="mk_uid[{$login}]">
{iterate from=$it item=user}
- <option value="{$user.uid}">{$user.prenom} {$user.nom} (X{$user.promo})</option>
+ <option value="{$user.uid}">{$user.full_name}</option>
{/iterate}
</select><br />
Action* :