From: Stéphane Jacob Date: Mon, 7 Mar 2011 13:40:32 +0000 (+0100) Subject: Fixes registration and promo addition. X-Git-Tag: xorg/1.1.0~59 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;ds=sidebyside;h=f0a52f1beb8dc550526ffaddd33144acccfff534;p=platal.git Fixes registration and promo addition. Signed-off-by: Stéphane Jacob --- diff --git a/include/emails.inc.php b/include/emails.inc.php index 4f0e1ba..aac9a25 100644 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@ -596,7 +596,7 @@ class Email } $res = XDB::fetchOneCell('SELECT COUNT(*) FROM email_redirect_account - WHERE uid = {?} AND type = {?} AND flags = \'active\')', + WHERE uid = {?} AND type = {?} AND flags = \'active\'', $user->id(), $storage); return !is_null($res) && $res > 0; } diff --git a/include/reminder/email_backup.inc.php b/include/reminder/email_backup.inc.php index 9bd599b..6336b8b 100644 --- a/include/reminder/email_backup.inc.php +++ b/include/reminder/email_backup.inc.php @@ -60,7 +60,7 @@ class ReminderEmailBackup extends Reminder } require_once 'emails.inc.php'; - $active = Email::is_active_storage($user, 'imap') + $active = Email::is_active_storage($user, 'imap'); if ($active) { Reminder::MarkCandidateAsAccepted($user->id(), $candidate); } diff --git a/modules/admin.php b/modules/admin.php index f97f83a..9c1e108 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -778,9 +778,9 @@ class AdminModule extends PLModule { switch ($sex) { case 'F': - return PlUser::GENDER_FEMALE; + return 'female'; case 'M': - return PlUser::GENDER_MALE; + return 'male'; default: $page->trigError("La ligne $line n'a pas été ajoutée car le sexe $sex n'est pas pris en compte."); return null; @@ -806,7 +806,6 @@ class AdminModule extends PLModule $nameTypes = array_flip($nameTypes); if (Env::t('add_type') == 'promo') { - $type = 'x'; $eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS); $eduSchools = array_flip($eduSchools); $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); @@ -818,6 +817,7 @@ class AdminModule extends PLModule $grad_year = $promotion + 3; $promo = 'X' . $promotion; $hrpromo = $promotion; + $type = 'x'; break; case 'M': $degreeid = $eduDegrees[Profile::DEGREE_M]; @@ -847,7 +847,11 @@ class AdminModule extends PLModule $fullName = $infos[1] . ' ' . $infos[0]; $directoryName = $infos[0] . ' ' . $infos[1]; $birthDate = self::formatBirthDate($infos[2]); - $xorgId = Profile::getXorgId($infos[4]); + if ($type == 'x') { + $xorgId = Profile::getXorgId($infos[4]); + } else { + $xorgId = trim($infos[4]); + } if (is_null($xorgId)) { $page->trigError("La ligne $line n'a pas été ajoutée car le matricule École est mal renseigné."); continue; diff --git a/modules/register.php b/modules/register.php index 95b896f..150da42 100644 --- a/modules/register.php +++ b/modules/register.php @@ -93,8 +93,9 @@ class RegisterModule extends PLModule case 1: if (Post::has('yearpromo')) { - $promo = Post::t('edu_type') . Post::t('yearpromo'); + $edu_type = Post::t('edu_type'); $yearpromo = Post::i('yearpromo'); + $promo = $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)) @@ -109,10 +110,15 @@ class RegisterModule extends PLModule $subState->set('step', 2); $subState->set('promo', $promo); $subState->set('yearpromo', $yearpromo); - if ($yearpromo >= 1996 && $yearpromo < 2000) { - $subState->set('schoolid', ($yearpromo % 100) * 10 . '???'); - } elseif($yearpromo >= 2000) { - $subState->set('schoolid', 100 + ($yearpromo % 100) . '???'); + $subState->set('edu_type', $edu_type); + if ($edu_type == 'X') { + if ($yearpromo >= 1996 && $yearpromo < 2000) { + $subState->set('schoolid', ($yearpromo % 100) * 10 . '???'); + } elseif($yearpromo >= 2000) { + $subState->set('schoolid', 100 + ($yearpromo % 100) . '???'); + } + } else { + $subState->set('schoolid', ''); } } } @@ -306,7 +312,7 @@ class RegisterModule extends PLModule $birthdate, $lastname, $firstname, $promo, $sex, $birthdate_ref, $eduType) = $res->fetchOneRow(); $isX = ($eduType == 'x'); $yearpromo = substr($promo, 1, 4); - $mail_domain = User::$sub_mail_domains[$eduType]; + $mail_domain = User::$sub_mail_domains[$eduType] . $globals->mail->domain; // Prepare the template for display. $page->changeTpl('register/end.tpl'); @@ -358,12 +364,13 @@ class RegisterModule extends PLModule // Add the registration email address as first and only redirection. require_once 'emails.inc.php'; + $user = User::getSilentWithUID($uid); $redirect = new Redirect($user); $redirect->add_email($email); // Try to start a session (so the user don't have to log in); we will use // the password available in Post:: to authenticate the user. - $success = Platal::session()->start(AUTH_MDP); + Platal::session()->start(AUTH_MDP); // Subscribe the user to the services she did request at registration time. foreach (explode(',', $services) as $service) { diff --git a/modules/register/register.inc.php b/modules/register/register.inc.php index 83f5ea2..47e59d2 100644 --- a/modules/register/register.inc.php +++ b/modules/register/register.inc.php @@ -110,11 +110,15 @@ function checkNewUser($subState) $lastname = preg_replace("/''+/", '\'', $lastname); $subState->set('lastname', mb_strtoupper($lastname)); - if ($subState->i('yearpromo') >= 1996) { + if ($subState->i('yearpromo') >= 1996 && $subState->v('edu_type') == 'X') { $res = checkId($subState); } else { $res = checkOldId($subState); } + if ($subState->v('edu_type') != 'X' && + $subState->v('xorgid') != $subState->v('schoolid')) { + return 'Le matricule est incorrect.'; + } if ($res !== true) { return $res; } @@ -132,7 +136,7 @@ function createAliases($subState) $emailXorg = PlUser::makeUserName($subState->t('firstname'), $subState->t('lastname')); $emailXorg2 = $emailXorg . sprintf(".%02u", ($subState->i('yearpromo') % 100)); - $res = XDB::query("SELECT hruid, state + $res = XDB::query("SELECT hruid, state, type FROM accounts WHERE uid = {?} AND hruid != ''", $subState->i('uid')); @@ -141,7 +145,7 @@ function createAliases($subState) . "Envoie un mail à mail->domain}\">" . "support@{$globals->mail->domain} en expliquant ta situation."; } else { - list($forlife, $state) = $res->fetchOneRow(); + list($forlife, $state, $type) = $res->fetchOneRow(); } if ($state == 'active') { return "Tu es déjà inscrit, si tu ne te souviens plus de ton mot de passe d'accès au site, " @@ -152,11 +156,11 @@ function createAliases($subState) . "mail->domain}\">support@{$globals->mail->domain}."; } - $count = XDB::numRows('SELECT uid, expire - FROM email_source_account - WHERE email = {?} AND type != \'alias_aux\'', - $emailXorg); - if ($count) { + $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 @@ -190,6 +194,7 @@ function createAliases($subState) $subState->set('bestalias', $emailXorg); $subState->set('emailXorg2', $emailXorg2); } + $subState->set('main_mail_domain', User::$sub_mail_domains[$type] . Platal::globals()->mail->domain); return true; } diff --git a/templates/register/step2.tpl b/templates/register/step2.tpl index 6ae6a64..b16d516 100644 --- a/templates/register/step2.tpl +++ b/templates/register/step2.tpl @@ -30,14 +30,14 @@
- {if $smarty.session.subState.yearpromo >= 1996} + {if $smarty.session.subState.edu_type neq 'X' || $smarty.session.subState.yearpromo >= 1996} {assign var="promo" value=$smarty.session.subState.yearpromo} - + + {if $smarty.session.subState.edu_type eq 'X'} + {/if} {/if} diff --git a/upgrade/1.1.0/11_xorg_id.sql b/upgrade/1.1.0/11_xorg_id.sql new file mode 100644 index 0000000..041a17b --- /dev/null +++ b/upgrade/1.1.0/11_xorg_id.sql @@ -0,0 +1,4 @@ +ALTER TABLE profiles DROP KEY xorg_id; +ALTER TABLE profiles ADD KEY xorg_id (xorg_id); + +-- vim:set syntax=mysql:
matriculeMatricule
- Matricule X : + Matricule École :
6 chiffres terminant par le numéro d'entrée (ex : @@ -61,6 +62,7 @@ {math equation="((promo + 1) % 100) + 100" promo=$promo}XXX {/if}