<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'xorg.misc.inc.php';
-
// {{{ function user_cmp
function user_cmp($prenom, $nom, $_prenom, $_nom)
global $globals;
extract ($sub);
- require_once "xorg.misc.inc.php";
- $mailorg = make_username($prenom, $nom);
+ $mailorg = make_username($prenom, $nom);
$mailorg2 = $mailorg.sprintf(".%02u", ($promo%100));
- $forlife = make_forlife($prenom, $nom, $promo);
- $res = XDB::query('SELECT COUNT(*) FROM aliases WHERE alias={?}', $forlife);
- if ($res->fetchOneCell() > 0) {
- return "Tu as un homonyme dans ta promo, il faut traiter ce cas manuellement.<br />".
- "envoie un mail à <a href=\"mailto:support@{$globals->mail->domain}</a>\">" .
- "support@{$globals->mail->domain}</a> en expliquant ta situation.";
+ $res = XDB::query("SELECT hruid FROM auth_user_md5 WHERE user_id = {?}", $uid);
+ if ($res->numRows() == 0) {
+ return "Tu n'as pas d'adresse à vie pré-attribuée.<br />"
+ . "Envoie un mail à <a href=\"mailto:support@{$globals->mail->domain}</a>\">"
+ . "support@{$globals->mail->domain}</a> en expliquant ta situation.";
+ } else {
+ // TODO: at the moment forlife == hruid, however we'll have to change
+ // that behaviour when masters will be on plat/al.
+ $forlife = $res->fetchOneCell();
}
- $res = XDB::query('SELECT id, type, expire FROM aliases WHERE alias={?}', $mailorg);
-
- if ( $res->numRows() ) {
-
+ $res = XDB::query('SELECT id, type, expire FROM aliases WHERE alias={?}', $mailorg);
+ if ($res->numRows()) {
list($h_id, $h_type, $expire) = $res->fetchOneRow();
-
- if ( $h_type != 'homonyme' and empty($expire) ) {
+ if ($h_type != 'homonyme' and empty($expire)) {
XDB::execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg);
XDB::execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $h_id);
XDB::execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $uid);
"Bonjour,\n\n".
"Un homonyme vient de s'inscrire. La politique de Polytechnique.org est de fournir des\n".
- "adresses mail devinables, nous ne pouvons donc pas conserver ton alias '$mailorg' qui\n".
+ "adresses email devinables, nous ne pouvons donc pas conserver ton alias '$mailorg' qui\n".
"correspond maintenant à deux personnes.\n\n".
"Tu gardes tout de même l'usage de cet alias pour un mois encore à compter de ce jour.\n\n".
{
global $globals;
extract($sub_state);
- require_once('secure_hash.inc.php');
$pass = rand_pass();
- $pass_encrypted = hash_encrypt($pass);
+ $pass_encrypted = sha1($pass);
$hash = rand_url_id(12);
XDB::execute('UPDATE auth_user_md5 SET last_known_email={?} WHERE matricule = {?}', $email, $mat);