X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fregister%2Fregister.inc.php;h=1ccb04176fadf37b904a78cb177b3c928a25a6bb;hb=a037f0a822d44e1fd79e5fe488092b0ab8dbc1ab;hp=17f9789a2de27a5376bd78083c5f29a5b1203038;hpb=9756357a151d461e49699938c8baee6ec81f1611;p=platal.git diff --git a/modules/register/register.inc.php b/modules/register/register.inc.php index 17f9789..1ccb041 100644 --- a/modules/register/register.inc.php +++ b/modules/register/register.inc.php @@ -19,9 +19,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -// {{{ function checkId +// {{{ function strongCheckId -function checkId($subState) +function strongCheckId($subState) { $subState->set('xorgid', Profile::getXorgId($subState->i('schoolid'))); if (!$subState->v('xorgid')) { @@ -50,18 +50,19 @@ function checkId($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; } // }}} -// {{{ function checkOldId +// {{{ function weakCheckId -function checkOldId($subState) +function weakCheckId($subState) { $uf = new UserFilter(new PFC_And( new PFC_Not(new UFC_Dead()), - new UFC_Promo('=', UserFilter::DISPLAY, $subState->s('promo')), + new UFC_Promo('=', $subState->s('edu_type'), $subState->s('yearpromo')), new PFC_Not(new UFC_Registered(true)) )); if ($it = $uf->iterProfiles()) { @@ -71,6 +72,7 @@ function checkOldId($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; @@ -80,7 +82,7 @@ function checkOldId($subState) $uf = new UserFilter(new PFC_And( new PFC_Not(new UFC_Dead()), - new UFC_Promo('=', UserFilter::DISPLAY, $subState->s('promo')), + new UFC_Promo('=', $subState->s('edu_type'), $subState->s('yearpromo')), new UFC_Registered(true) )); if ($it = $uf->iterProfiles()) { @@ -88,6 +90,7 @@ function checkOldId($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 !'; @@ -112,14 +115,10 @@ function checkNewUser($subState) $lastname = preg_replace("/''+/", '\'', $lastname); $subState->set('lastname', mb_strtoupper($lastname)); - if ($subState->i('yearpromo') >= 1996 && $subState->v('edu_type') == 'X') { - $res = checkId($subState); + if ($subState->v('edu_type') == Profile::DEGREE_X && $subState->i('yearpromo') >= 1996) { + $res = strongCheckId($subState); } else { - $res = checkOldId($subState); - } - if ($subState->v('edu_type') != 'X' && - $subState->v('xorgid') != $subState->v('schoolid')) { - return 'Le matricule est incorrect.'; + $res = weakCheckId($subState); } if ($res !== true) { return $res; @@ -135,9 +134,6 @@ function createAliases($subState) { global $globals; - $emailXorg = PlUser::makeUserName($subState->t('firstname'), $subState->t('lastname')); - $emailXorg2 = $emailXorg . sprintf(".%02u", ($subState->i('yearpromo') % 100)); - $res = XDB::query("SELECT hruid, state, type FROM accounts WHERE uid = {?} AND hruid != ''", @@ -158,6 +154,10 @@ function createAliases($subState) . "mail->domain}\">support@{$globals->mail->domain}."; } + + $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; $res = XDB::query('SELECT uid, expire FROM email_source_account WHERE email = {?} AND type != \'alias_aux\'',