From e4860774e45eac2d62cf80d4fd70fac2e0cf1da1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Fri, 22 Apr 2011 16:15:18 +0200 Subject: [PATCH] Improves registration's first part to properly take into account master and doctorate students. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- classes/profile.php | 5 +++++ modules/register.php | 24 +++++++++++++++--------- modules/register/register.inc.php | 29 +++++++++++++---------------- templates/register/step1.tpl | 6 +++--- templates/register/step2.tpl | 21 ++++----------------- templates/register/step3.tpl | 2 +- 6 files changed, 41 insertions(+), 46 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index dffc869..249de86 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -53,6 +53,11 @@ class Profile implements PlExportable self::DEGREE_M => 'master', self::DEGREE_D => 'docteur' ); + static public $cycle_prefixes = array( + self::DEGREE_X => 'X', + self::DEGREE_M => 'M', + self::DEGREE_D => 'D' + ); static public $name_variants = array( self::LASTNAME => array(self::VN_MARITAL, self::VN_ORDINARY), diff --git a/modules/register.php b/modules/register.php index 8dd0a53..1a88393 100644 --- a/modules/register.php +++ b/modules/register.php @@ -51,7 +51,8 @@ class RegisterModule extends PLModule if ($hash) { $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES); $nameTypes = array_flip($nameTypes); - $res = XDB::query("SELECT a.uid, a.hruid, pnl.name AS lastname, pnf.name AS firstname, p.xorg_id AS xorgid, pd.promo, pe.promo_year AS yearpromo + $res = XDB::query("SELECT a.uid, a.hruid, pnl.name AS lastname, pnf.name AS firstname, p.xorg_id AS xorgid, + pd.promo, pe.promo_year AS yearpromo, pde.degree AS edu_type, p.birthdate_ref AS birthdateRef, FIND_IN_SET('watch', a.flags) AS watch, m.hash, a.type FROM register_marketing AS m INNER JOIN accounts AS a ON (m.uid = a.uid) @@ -59,6 +60,7 @@ class RegisterModule extends PLModule INNER JOIN profiles AS p ON (p.pid = ap.pid) INNER JOIN profile_display AS pd ON (p.pid = pd.pid) INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET('primary', pe.flags)) + INNER JOIN profile_education_degree_enum AS pde ON (pde.id = pe.degreeid) INNER JOIN profile_name AS pnl ON (p.pid = pnl.pid AND pnl.typeid = {?}) INNER JOIN profile_name AS pnf ON (p.pid = pnf.pid AND pnf.typeid = {?}) WHERE m.hash = {?} AND a.state = 'pending'", @@ -95,8 +97,7 @@ class RegisterModule extends PLModule if (Post::has('yearpromo')) { $edu_type = Post::t('edu_type'); $yearpromo = Post::i('yearpromo'); - $promo = $edu_type . $yearpromo; - $year = ($edu_type == 'X') ? 'entry_year' : 'grad_year'; + $promo = Profile::$cycle_prefixes[$edu_type] . $yearpromo; $res = XDB::query("SELECT COUNT(*) FROM accounts AS a INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms)) @@ -112,14 +113,16 @@ class RegisterModule extends PLModule $subState->set('promo', $promo); $subState->set('yearpromo', $yearpromo); $subState->set('edu_type', $edu_type); - if ($edu_type == 'X') { + if ($edu_type == Profile::DEGREE_X) { if ($yearpromo >= 1996 && $yearpromo < 2000) { $subState->set('schoolid', ($yearpromo % 100) * 10 . '???'); + $subState->set('schoolid_exemple', ($yearpromo % 100) * 10000 + 532); + $subState->set('schoolid_exemple_ev2', (($yearpromo + 1) % 100) * 10000 + 532); } elseif($yearpromo >= 2000) { $subState->set('schoolid', 100 + ($yearpromo % 100) . '???'); + $subState->set('schoolid_exemple', (100 + ($yearpromo % 100)) * 1000 + 532); + $subState->set('schoolid_exemple_ev2', (100 + (($yearpromo + 1) % 100)) * 1000 + 532); } - } else { - $subState->set('schoolid', ''); } } } @@ -130,7 +133,9 @@ class RegisterModule extends PLModule $this->load('register.inc.php'); $subState->set('firstname', Post::t('firstname')); $subState->set('lastname', Post::t('lastname')); - $subState->set('schoolid', Post::i('schoolid')); + if (Post::has('schoolid')) { + $subState->set('schoolid', Post::i('schoolid')); + } $error = checkNewUser($subState); if ($error !== true) { @@ -169,8 +174,9 @@ class RegisterModule extends PLModule if ($birth[2] < 100) { $birth[2] += 1900; } - $year = $birth[2]; - if ($year > $subState->i('yearpromo') - 15 || $subState->i('yearpromo') < $promo - 30) { + $year = $birth[2]; + $ref_year = substr($subState->v('birthdateRef'), 0, 4); + if (abs($ref_year - $year) > 2) { $error[] = "La 'Date de naissance' n'est pas correcte."; $alert = "Date de naissance incorrecte à l'inscription - "; $subState->set('wrong_birthdate', $birth); diff --git a/modules/register/register.inc.php b/modules/register/register.inc.php index 17f9789..9393bd6 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')) { @@ -55,13 +55,13 @@ function checkId($subState) } // }}} -// {{{ 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()) { @@ -80,7 +80,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()) { @@ -112,14 +112,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 +131,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 +151,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\'', diff --git a/templates/register/step1.tpl b/templates/register/step1.tpl index 87251c5..2feeace 100644 --- a/templates/register/step1.tpl +++ b/templates/register/step1.tpl @@ -48,9 +48,9 @@ diff --git a/templates/register/step2.tpl b/templates/register/step2.tpl index b16d516..308ca9c 100644 --- a/templates/register/step2.tpl +++ b/templates/register/step2.tpl @@ -30,8 +30,7 @@
- {if $smarty.session.subState.edu_type neq 'X' || $smarty.session.subState.yearpromo >= 1996} - {assign var="promo" value=$smarty.session.subState.yearpromo} + {if t($smarty.session.subState.schoolid)} @@ -45,24 +44,12 @@ - {if $smarty.session.subState.edu_type eq 'X'} - {/if} {/if} diff --git a/templates/register/step3.tpl b/templates/register/step3.tpl index ab97b27..71b8b03 100644 --- a/templates/register/step3.tpl +++ b/templates/register/step3.tpl @@ -115,7 +115,7 @@
de recevoir les informations importantes de l'AX.
- {if $smarty.session.subState.edu_type eq 'X'} + {if $smarty.session.subState.edu_type eq #Profile::DEGREE_X#}
de recevoir les informations plus spécifiques de ta promotion pour pouvoir participer plus facilement aux événements -- 2.1.4
Matricule
- 6 chiffres terminant par le numéro d'entrée (ex : - {if $promo < 2000} - {math equation="promo % 100" promo=$promo}0532)
- {else} - {math equation="(promo % 100) + 100" promo=$promo}532)
- {/if} - Voir sur le GU ou un bulletin de solde pour trouver cette information

- Pour les élèves étrangers voie 2, il peut être aussi du type : - {if $promo < 1999} - {math equation="(promo + 1) % 100" promo=$promo}0XXX - {else} - {math equation="((promo + 1) % 100) + 100" promo=$promo}XXX - {/if} + 6 chiffres terminant par le numéro d'entrée (ex : {$smarty.session.subState.schoolid_exemple}). + Voir sur le GU ou un bulletin de solde pour trouver cette information.

+ Pour les élèves étrangers voie 2, il peut être aussi du type : {$smarty.session.subState.schoolid_exemple_ev2}.