$sub['tous les groupes'] = 'plan';
$sub['documentation'] = 'Xnet';
if (S::user()->type == 'xnet') {
- $sub['mot de passe'] = 'https://www.polytechnique.org/password';
+ $sub['mon compte'] = 'member/edit';
}
$sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600');
$menu["no_title"] = $sub;
function hashResponse(password1, password2, hasConfirmation) {
pw1 = $('[name=' + password1 + ']').val();
+ if (pw1 == '********') {
+ return true;
+ }
if (hasConfirmation) {
pw2 = $('[name=' + password2 + ']').val();
if (pw1 != pw2) {
return false;
}
$('[name=' + password2 + ']').val('');
- } else if (pw1 == '********') {
- return true;
}
if (pw1.length < 6) {
'plan' => $this->make_hook('plan', AUTH_PUBLIC),
'photo' => $this->make_hook('photo', AUTH_MDP),
'autologin' => $this->make_hook('autologin', AUTH_MDP),
+ 'edit' => $this->make_hook('edit', AUTH_MDP, 'user'),
'Xnet' => $this->make_wiki_hook(),
);
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
+ XDB::query('UPDATE accounts
+ SET full_name = {?}, directory_name = {?}, display_name = {?},
+ sex = {?}, email = {?}
+ WHERE uid = {?}',
+ Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'),
+ (Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'), $user->id());
+ // If user is of type xnet and new password is given.
+ if (!Post::blank('pwhash')) {
+ XDB::query('UPDATE accounts
+ SET password = {?}
+ WHERE uid = {?}',
+ Post::t('pwhash'), $user->id());
+ }
+ if (XDB::affectedRows()) {
+ $page->trigSuccess('Données mises à jour.');
+ }
+ }
+
+ $page->addJsLink('password.js');
+ $page->assign('user', $user);
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2010 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+<h1>
+ Édition de tes données dans l'annuaire
+</h1>
+
+<form method="post" action="{$platal->ns}edit">
+ {xsrf_token_field}
+ <table cellpadding="0" cellspacing="0" class='tinybicol'>
+ <tr id="prenom" class="impair">
+ <td class="titre">
+ Nom affiché :
+ </td>
+ <td>
+ <input type="text" value="{$user->displayName()}" name="display_name" size="40" />
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">
+ Nom complet :
+ </td>
+ <td>
+ <input type="text" value="{$user->fullName()}" name="full_name" size="40" />
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">
+ Nom annuaire :
+ </td>
+ <td>
+ <input type="text" value="{$user->directoryName()}" name="directory_name" size="40" />
+ </td>
+ </tr>
+ <tr id="sexe" class="impair">
+ <td class="titre">
+ Sexe :
+ </td>
+ <td>
+ <select name="sex">
+ <option value="male"{if !$user->isFemale()} selected="selected"{/if}>Homme</option>
+ <option value="female"{if $user->isFemale()} selected="selected"{/if}>Femme</option>
+ </select>
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">
+ Email :
+ </td>
+ <td>
+ <input type="text" value="{$user->forlifeEmail()}" name="email" size="40" />
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">Mot de passe :</td>
+ <td>
+ <input type="text" name="password1" size="10" maxlength="256" value="********" />
+ <input type="hidden" name="pwhash" value="" />
+ </td>
+ </tr>
+ <tr class="impair">
+ <td class="titre">Retape-le une fois :</td>
+ <td>
+ <input type="text" name="password2" size="10" maxlength="256" value="" />
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>{checkpasswd prompt="password1" submit="dummy_none"}</td>
+ </tr>
+ <tr id="make_X">
+ <td colspan="2">
+ <span id="make_X_cb">
+ <input type="checkbox" name="is_x" id="is_x" onclick="$('#make_X_cb').hide(); $('#make_X_login').show()" />
+ <label for="is_x">coche cette case si tu es en fait un X</label>
+ </span>
+ <span id="make_X_login" style="display: none">
+ <span class="titre">Identifiant (prenom.nom.promo) :</span>
+ <input type="text" name="login_X" value="" />
+ </span>
+ </td>
+ </tr>
+ </table>
+
+ <div class="center">
+ <br />
+ <input type="submit" name='change' value="Valider ces changements" onclick="return hashResponse('password1', 'password2', true);" />
+
+ <input type="reset" value="Annuler ces changements" />
+ </div>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}