+
+ 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 = {?}, email = {?}
+ WHERE uid = {?}',
+ $full_name, $directory_name, Post::t('display_name'),
+ Post::t('firstname'), Post::t('lastname'),
+ (Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'), $user->id());
+ if (XDB::affectedRows()) {
+ require_once 'emails.inc.php';
+ if (require_email_update($user, Post::t('email'))) {
+ $listClient = new MMList(S::user());
+ $listClient->change_user_email($user->forlifeEmail(), Post::t('email'));
+ update_alias_user($user->forlifeEmail(), Post::t('email'));
+ }
+ $user = User::getWithUID($user->id());
+ S::set('user', $user);
+ $page->trigSuccess('Données mises à jour.');
+ }
+ }
+
+ $page->addJsLink('password.js');
+ $page->assign('user', $user);
+ }
+