xdb->query("SELECT prenom,nom,a.alias AS forlife,h.alias AS loginbis FROM auth_user_md5 AS u INNER JOIN aliases AS a ON (a.id=u.user_id AND a.type='a_vie') INNER JOIN aliases AS h ON (h.id=u.user_id AND h.expire!='') WHERE user_id = {?}", $uid); return $res->fetchOneRow(); } function send_warning_homonyme($prenom, $nom, $forlife, $loginbis) { require_once("diogenes/diogenes.hermes.inc.php"); $cc = "support+homonyme@polytechnique.org"; $FROM = "\"Support Polytechnique.org\" <$cc>"; $mymail = new HermesMailer(); $mymail->setFrom($FROM); $mymail->setSubject("Dans 2 semaines, suppression de $loginbis@polytechnique.org"); $mymail->addTo("$prenom $nom <$forlife@polytechnique.org>"); $mymail->addCc($cc); $mymail->setTxtBody(Env::get('mailbody')); $mymail->send(); } function send_robot_homonyme($prenom, $nom, $forlife, $loginbis) { require_once("diogenes/diogenes.hermes.inc.php"); $cc = "support+homonyme@polytechnique.org"; $FROM = "\"Support Polytechnique.org\" <$cc>"; $mymail = new HermesMailer(); $mymail->setFrom($FROM); $mymail->setSubject("Mise en place du robot $loginbis@polytechnique.org"); $mymail->addTo("$prenom $nom <$forlife@polytechnique.org>"); $mymail->addCc($cc); $mymail->setTxtBody(Env::get('mailbody')); $mymail->send(); } function switch_bestalias($uid, $loginbis) { global $globals; // check if loginbis was the bestalias $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", $uid); $bestalias = $res->fetchOneCell(); if ($bestalias && $bestalias != $loginbis) return false; // select the shortest alias still alive $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id = {?} AND alias != {?} AND expire IS NULL ORDER BY LENGTH(alias) LIMIT 1", $uid, $loginbis); $newbest = $res->fetchOneCell(); // change the bestalias flag $globals->xdb->execute("UPDATE aliases SET flags = (flags & (255 - 1)) | IF(alias = {?}, 1, 0) WHERE id = {?}", $newbest, $uid); return $newbest; } ?>