X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnet.php;h=9f7e6b324417d0c0c67b3f323af2f46395f8b050;hb=80575e7c2f5df82778663f3b4b85589221995340;hp=be6abfa38266ee439629173088fbb36252ef7119;hpb=831aa467923442f98fd3e794c0b90d69d22659a1;p=platal.git diff --git a/modules/xnet.php b/modules/xnet.php index be6abfa..9f7e6b3 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -24,17 +24,19 @@ class XnetModule extends PLModule function handlers() { return array( - 'index' => $this->make_hook('index', AUTH_PUBLIC), - 'exit' => $this->make_hook('exit', AUTH_PUBLIC), - - 'admin' => $this->make_hook('admin', AUTH_MDP, 'admin'), - 'groups' => $this->make_hook('groups', AUTH_PUBLIC), - 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC), - 'plan' => $this->make_hook('plan', AUTH_PUBLIC), - 'photo' => $this->make_hook('photo', AUTH_MDP), - 'autologin' => $this->make_hook('autologin', AUTH_MDP), - - 'Xnet' => $this->make_wiki_hook(), + 'index' => $this->make_hook('index', AUTH_PUBLIC), + 'exit' => $this->make_hook('exit', AUTH_PUBLIC), + + 'admin' => $this->make_hook('admin', AUTH_PASSWD, 'admin'), + 'groups' => $this->make_hook('groups', AUTH_PUBLIC), + 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC), + 'plan' => $this->make_hook('plan', AUTH_PUBLIC), + // Should be removed in a future release as links will have expired anyway. + 'register/ext' => $this->make_hook('register_ext', AUTH_PUBLIC), + 'photo' => $this->make_hook('photo', AUTH_PASSWD, 'groups'), + 'autologin' => $this->make_hook('autologin', AUTH_PASSWD, 'groups'), + 'edit' => $this->make_hook('edit', AUTH_PASSWD, 'groups'), + 'Xnet' => $this->make_wiki_hook(), ); } @@ -223,6 +225,67 @@ class XnetModule extends PLModule echo '$.ajax({ url: "'.$url.'?forceXml=1", dataType: "xml", success: function(xml) { $("body",xml).insertBefore("body"); $("body:eq(1)").remove(); }});'; exit; } + + function handler_edit($page) + { + global $globals; + + $user = S::user(); + if (empty($user)) { + return PL_NOT_FOUND; + } + if ($user->type != 'xnet') { + pl_redirect('index'); + } + + $page->changeTpl('xnet/edit.tpl'); + if (Post::has('change')) { + S::assert_xsrf_token(); + + // Convert user status to X + if (!Post::blank('login_X')) { + $forlife = $this->changeLogin($page, $user, Post::t('login_X')); + if ($forlife) { + pl_redirect('index'); + } + } + + // Update user info + $full_name = Post::t('firstname') . ' ' . Post::t('lastname'); + $directory_name = mb_strtoupper(Post::t('lastname')) . ' ' . Post::t('firstname'); + XDB::query('UPDATE accounts + SET full_name = {?}, directory_name = {?}, display_name = {?}, + firstname = {?}, lastname = {?}, sex = {?} + WHERE uid = {?}', + $full_name, $directory_name, Post::t('display_name'), + Post::t('firstname'), Post::t('lastname'), + (Post::t('sex') == 'male') ? 'male' : 'female', $user->id()); + + // Updates email. + require_once 'emails.inc.php'; + $new_email = strtolower(Post::t('email')); + if (require_email_update($user, $new_email)) { + XDB::query('UPDATE accounts + SET email = {?} + WHERE uid = {?}', + $new_email, $user->id()); + $listClient = new MMList(S::user()); + $listClient->change_user_email($user->forlifeEmail(), $new_email); + update_alias_user($user->forlifeEmail(), $new_email); + } + $user = User::getWithUID($user->id()); + S::set('user', $user); + $page->trigSuccess('Données mises à jour.'); + } + + $page->addJsLink('password.js'); + $page->assign('user', $user); + } + + function handler_register_ext($page, $hash = null) + { + http_redirect(Platal::globals()->xnet->xorg_baseurl . 'register/ext/' . $hash); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: