'admin/jobs' => $this->make_hook('jobs', AUTH_PASSWD, 'admin,edit_directory'),
'admin/profile' => $this->make_hook('profile', AUTH_PASSWD, 'admin,edit_directory'),
'admin/phd' => $this->make_hook('phd', AUTH_PASSWD, 'admin'),
+ 'admin/name' => $this->make_hook('admin_name', AUTH_PASSWD, 'admin'),
'admin/add_secondary_edu' => $this->make_hook('add_secondary_edu', AUTH_PASSWD, 'admin')
);
}
}
}
+
+ function handler_admin_name($page, $hruid = null)
+ {
+ $page->changeTpl('admin/admin_name.tpl');
+
+ if (Post::has('id')) {
+ $user = User::get(Post::t('id'));
+ if (is_null($user)) {
+ $page->trigError("L'identifiant donné ne correspond à personne ou est ambigu.");
+ exit();
+ }
+ pl_redirect('admin/name/' . $user->hruid);
+ }
+
+ $user = User::getSilent($hruid);
+ if (!is_null($user)) {
+ require_once 'name.func.inc.php';
+
+ if ($user->hasProfile()) {
+ $name_types = array(
+ 'lastname_main' => 'Nom patronymique',
+ 'lastname_marital' => 'Nom marital',
+ 'lastname_ordinary' => 'Nom usuel',
+ 'firstname_main' => 'Prénom',
+ 'firstname_ordinary' => 'Prénom usuel',
+ 'pseudonym' => 'Pseudonyme'
+ );
+ $names = XDB::fetchOneAssoc('SELECT lastname_main, lastname_marital, lastname_ordinary,
+ firstname_main, firstname_ordinary, pseudonym
+ FROM profile_public_names
+ WHERE pid = {?}',
+ $user->profile()->id());
+ } else {
+ $name_types = array(
+ 'lastname' => 'Nom',
+ 'firstname' => 'Prénom'
+ );
+ $names = XDB::fetchOneAssoc('SELECT lastname, firstname
+ FROM accounts
+ WHERE uid = {?}',
+ $user->id());
+ }
+
+ if (Post::has('correct')) {
+ $new_names = array();
+ $update = true;
+ foreach ($name_types as $key => $fullname) {
+ $new_names[$key] = Post::t($key);
+ if (mb_strtolower($new_names[$key]) != mb_strtolower($names[$key])) {
+ $update = false;
+ }
+ }
+
+ if ($update) {
+ if ($user->hasProfile()) {
+ update_public_names($user->profile()->id(), $new_names);
+ update_display_names($user->profile(), $new_names);
+ } else {
+ $new_names['full_name'] = build_full_name($new_names['firstname'], $new_names['lastname']);
+ $new_names['directory_name'] = build_directory_name($new_names['firstname'], $new_names['lastname']);
+ $new_names['sort_name'] = build_sort_name($new_names['firstname'], $new_names['lastname']);
+ XDB::execute('UPDATE accounts
+ SET lastname = {?}, firstname = {?}, full_name = {?},
+ directory_name = {?}, sort_name = {?}
+ WHERE uid = {?}',
+ $new_names['lastname'], $new_names['firstname'], $new_names['full_name'],
+ $new_names['directory_name'], $new_names['sort_name'], $user->id());
+ }
+ $page->trigSuccess('Mise à jour réussie.');
+ } else {
+ $page->trigError('Seuls des changements de casse sont autorisés ici.');
+ }
+ }
+
+ if ($user->hasProfile()) {
+ $names = XDB::fetchOneAssoc('SELECT lastname_main, lastname_marital, lastname_ordinary,
+ firstname_main, firstname_ordinary, pseudonym
+ FROM profile_public_names
+ WHERE pid = {?}',
+ $user->profile()->id());
+ } else {
+ $names = XDB::fetchOneAssoc('SELECT lastname, firstname
+ FROM accounts
+ WHERE uid = {?}',
+ $user->id());
+ }
+
+ foreach ($names as $key => $name) {
+ $names[$key] = array(
+ 'value' => $name,
+ 'standard' => capitalize_name($name)
+ );
+ $names[$key]['different'] = ($names[$key]['value'] != $names[$key]['standard']);
+ }
+
+ $page->assign('uid', $user->id());
+ $page->assign('hruid', $user->hruid);
+ $page->assign('names', $names);
+ $page->assign('name_types', $name_types);
+ }
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 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>Gestion des noms{if t($hruid)} de {profile user=$uid promo=true directory=false}{/if}</h1>
+
+{if t($hruid)}
+<form method="post" action="{$platal->ns}admin/name/{$hruid}">
+ <table class="bicol">
+ <tr>
+ <th></th>
+ <th>Version actuelle</th>
+ <th>Version suggérée</th>
+ </tr>
+ {foreach from=$names item=name key=type}
+ <tr>
+ <th>{$name_types.$type}</th>
+ <td><input type="text" size="40" name="{$type}" value="{$name.value}" {if $name.different}class="warning"{/if} /></td>
+ <td>{$name.standard}</td>
+ </tr>
+ {/foreach}
+ </table>
+ <p class="center">
+ <input type="submit" name="correct" value="Corriger" />
+ </p>
+</form>
+<p>
+ <a href="admin/name">Retour à la gestion des noms.</a>
+</p>
+{else}
+<form method="post" action="{$platal->ns}admin/name">
+ <p>
+ Il est possible d'entrer ici n'importe quelle adresse email : redirection, melix ou alias.<br />
+ <input type="text" size="60" name="id" />
+ <input type="submit" value="Chercher" />
+ </p>
+</form>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}