X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fregister%2Fregister.inc.php;h=a4980a956620911ec249f537b9a853b0cc6453d6;hb=92ac93ec91a6e7b0f00fd21c6d19c31d46fe9f52;hp=9393bd67d0b630feeffe079d2dba615ff5926902;hpb=e4860774e45eac2d62cf80d4fd70fac2e0cf1da1;p=platal.git diff --git a/modules/register/register.inc.php b/modules/register/register.inc.php index 9393bd6..a4980a9 100644 --- a/modules/register/register.inc.php +++ b/modules/register/register.inc.php @@ -50,6 +50,7 @@ function strongCheckId($subState) $subState->set('firstname', $profile->firstName()); $subState->set('uid', $profile->owner()->id()); $subState->set('watch', $profile->owner()->watch); + $subState->set('comment', $profile->owner()->comment); $subState->set('birthdateRef', $profile->__get('birthdate_ref')); return true; } @@ -71,6 +72,7 @@ function weakCheckId($subState) $subState->set('firstname', $profile->firstName()); $subState->set('uid', $profile->owner()->id()); $subState->set('watch', $profile->owner()->watch); + $subState->set('comment', $profile->owner()->comment); $subState->set('birthdateRef', $profile->__get('birthdate_ref')); $subState->set('xorgid', $profile->__get('xorg_id')); return true; @@ -88,6 +90,7 @@ function weakCheckId($subState) if ($profile->compareNames($subState->s('firstname'), $subState->s('lastname'))) { $subState->set('uid', $profile->owner()->id()); $subState->set('watch', $profile->owner()->watch); + $subState->set('comment', $profile->owner()->comment); $subState->set('birthdateRef', $profile->__get('birthdate_ref')); $subState->set('xorgid', $profile->__get('xorg_id')); return 'Tu es vraisemblablement déjà inscrit !'; @@ -155,34 +158,48 @@ function createAliases($subState) $emailXorg = PlUser::makeUserName($subState->t('firstname'), $subState->t('lastname')); $suffix = (User::$sub_mail_domains[$type] ? substr(User::$sub_mail_domains[$type], 0, 1) : '') . substr($subState->v('yearpromo'), -2); $emailXorg2 = $emailXorg . '.' . $suffix; + // Search for homonyms: + // * first case: only one homonym already registered. $res = XDB::query('SELECT uid, expire FROM email_source_account WHERE email = {?} AND type != \'alias_aux\'', $emailXorg); - if ($res->numRows()) { - list($h_id, $expire) = $res->fetchOneRow(); - if (empty($expire)) { - XDB::execute('UPDATE email_source_account - SET expire = ADDDATE(NOW(), INTERVAL 1 MONTH) - WHERE email = {?} AND type != \'alias_aux\'', + // * second case: at least two homonyms registerd. + $result = XDB::query("SELECT hrmid + FROM email_source_other + WHERE type = 'homonym' AND email = {?}", $emailXorg); - $hrmid = User::makeHomonymHrmid($emailXorg); + if ($res->numRows() || $result->numRows()) { + if ($res->numRows()) { + list($h_id, $expire) = $res->fetchOneRow(); + if (empty($expire)) { + XDB::execute('UPDATE email_source_account + SET expire = ADDDATE(NOW(), INTERVAL 1 MONTH) + WHERE email = {?} AND type != \'alias_aux\'', + $emailXorg); + $hrmid = User::makeHomonymHrmid($emailXorg); + XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid) + VALUES ({?}, {?}), ({?}, {?})', + $hrmid, $h_id, $hrmid, $subState->i('uid')); + $als = XDB::fetchColumn('SELECT email + FROM email_source_account + WHERE uid = {?} AND type != \'alias_aux\' AND expire IS NULL', + $h_id); + + $homonym = User::getSilentWithUID($h_id); + $mailer = new PlMailer('register/lostalias.mail.tpl'); + $mailer->addTo($homonym); + $mailer->setSubject("Perte de ton alias $emailXorg dans un mois !"); + $mailer->assign('emailXorg', $emailXorg); + $mailer->assign('als', join(', ', $als)); + $mailer->SetTxtBody(wordwrap($msg,72)); + $mailer->send(); + } + } else { + $hrmid = $result->fetchOneCell(); XDB::execute('INSERT IGNORE INTO homonyms_list (hrmid, uid) - VALUES ({?}, {?}), ({?}, {?})', - $hrmid, $h_id, $hrmid, $subState->i('uid')); - $als = XDB::fetchColumn('SELECT email - FROM email_source_account - WHERE uid = {?} AND type != \'alias_aux\' AND expire IS NULL', - $h_id); - - $homonym = User::getSilentWithUID($h_id); - $mailer = new PlMailer('register/lostalias.mail.tpl'); - $mailer->addTo($homonym); - $mailer->setSubject("Perte de ton alias $emailXorg dans un mois !"); - $mailer->assign('emailXorg', $emailXorg); - $mailer->assign('als', join(', ', $als)); - $mailer->SetTxtBody(wordwrap($msg,72)); - $mailer->send(); + VALUES ({?}, {?})', + $hrmid, $subState->i('uid')); } $subState->set('forlife', $forlife);