X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=bde1cf20b0f758f72e0e219699779d6d88244dc3;hb=f8eb84b77cc8c0df0105f63faa7544b12c758096;hp=0559e6c7b56f1119642ba95b1c2844a7149bd9fe;hpb=46ae38a91773bca3645e78488aa0dae55d5dd574;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index 0559e6c..bde1cf2 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -1,6 +1,6 @@ assign('submited', $sql->fetchOneCell()); $page->assign('has_trombi_x', file_exists($trombi_x)); @@ -186,27 +190,29 @@ class ProfileModule extends PLModule WHERE matricule={?}", $x); $login = $res->fetchOneCell(); } else { - $login = get_user_forlife($x); + $login = get_user_forlife($x, S::logged() ? '_default_user_callback' + : '_silent_user_callback'); } if (empty($login)) { - if (preg_match('/([-a-z]+)\.([-a-z]+)\.([0-9]{4})/i', $x, $matches)) { - $matches = str_replace('-', '_', $matches); - $res = XDB::query("SELECT user_id - FROM auth_user_md5 - WHERE prenom LIKE {?} AND nom LIKE {?} AND promo = {?} - AND perms = 'pending'", - $matches[1], $matches[2], $matches[3]); - if ($res->numRows() == 1) { - $uid = $res->fetchOneCell(); - pl_redirect('marketing/public/' . $uid); - } + $user = get_not_registered_user($x, true); + if ($user->total() != 1) { + return PL_NOT_FOUND; } - return PL_NOT_FOUND; + $user = $user->next(); + if (S::logged()) { + pl_redirect('marketing/public/' . $user['user_id']); + } + $user['forlife'] = $x; + } else { + $new = Env::v('modif') == 'new'; + $user = get_user_details($login, S::v('uid'), $view); + } + + if (S::logged()) { + $_SESSION['log']->log('view_profile', $login); } - $new = Env::v('modif') == 'new'; - $user = get_user_details($login, S::v('uid'), $view); $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'] ); $page->assign('xorg_title', $title); @@ -251,6 +257,7 @@ class ProfileModule extends PLModule $user['forlife'].'@'.$globals->mail->domain, $user['forlife'].'@'.$globals->mail->domain2); $page->assign('virtualalias', $res->fetchOneCell()); + $page->assign('view', $view); $page->addJsLink('close_on_esc.js'); header('Last-Modified: ' . date('r', strtotime($user['date']))); @@ -278,44 +285,6 @@ class ProfileModule extends PLModule { global $globals; - // Finish registration procedure - if (Post::v('register_from_ax_question')) { - XDB::execute('UPDATE auth_user_quick - SET profile_from_ax = 1 - WHERE user_id = {?}', - S::v('uid')); - } - if (Post::v('add_to_nl')) { - require_once 'newsletter.inc.php'; - NewsLetter::subscribe(); - } - if (Post::v('add_to_ax')) { - require_once dirname(__FILE__) . '/axletter/axletter.inc.php'; - AXLetter::subscribe(); - } - if (Post::v('add_to_promo')) { - $r = XDB::query('SELECT id FROM groupex.asso WHERE diminutif = {?}', - S::v('promo')); - $asso_id = $r->fetchOneCell(); - XDB::execute('REPLACE INTO groupex.membres (uid,asso_id) - VALUES ({?}, {?})', - S::v('uid'), $asso_id); - $mmlist = new MMList(S::v('uid'), S::v('password')); - $mmlist->subscribe("promo".S::v('promo')); - } - if (Post::v('sub_ml')) { - $subs = array_keys(Post::v('sub_ml')); - $current_domain = null; - foreach ($subs as $list) { - list($sub, $domain) = explode('@', $list); - if ($domain != $current_domain) { - $current_domain = $domain; - $client = new MMList(S::v('uid'), S::v('password'), $domain); - } - $client->subscribe($sub); - } - } - // AX Synchronization require_once 'synchro_ax.inc.php'; if (is_ax_key_missing()) { @@ -326,9 +295,7 @@ class ProfileModule extends PLModule $page->trig('Ton profil a été synchronisé avec celui du site polytechniciens.com'); } - // Misc checks - // TODO: Block if birth date is missing ? - + // Build the page $page->addJsLink('ajax.js'); $page->addJsLink('profile.js'); $page->addJsLink('applis.js'); @@ -344,7 +311,16 @@ class ProfileModule extends PLModule $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor'); $wiz->apply($page, 'profile/edit', $opened_tab, $mode); - $page->assign('xorg_title', 'Polytechnique.org - Mon Profil'); + // Misc checks + $res = XDB::query("SELECT user_id + FROM auth_user_md5 + WHERE user_id = {?} AND naissance = '0000-00-00'", S::i('uid')); + if ($res->numRows()) { + $page->trig("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser" + . " la procédure de récupération de mot de passe si un jour tu le perdais"); + } + + $page->assign('xorg_title', 'Polytechnique.org - Mon Profil'); } function handler_applis_js(&$page)