From: Stéphane Jacob Date: Tue, 29 Nov 2011 10:03:33 +0000 (+0100) Subject: Allows capitalization to be modified by administrators. X-Git-Tag: xorg/1.1.5~71 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=40cc32f61aef8bcf8049d59d774f3cb32c0ca276;hp=57304870a588714b092b7ab53c0f1b3fda75dd83;p=platal.git Allows capitalization to be modified by administrators. Signed-off-by: Stéphane Jacob --- diff --git a/modules/admin.php b/modules/admin.php index a993a9c..7bdd213 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -55,6 +55,7 @@ class AdminModule extends PLModule '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') ); } @@ -2012,6 +2013,107 @@ class AdminModule extends PLModule } } + + 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: diff --git a/templates/admin/admin_name.tpl b/templates/admin/admin_name.tpl new file mode 100644 index 0000000..7317529 --- /dev/null +++ b/templates/admin/admin_name.tpl @@ -0,0 +1,58 @@ +{**************************************************************************} +{* *} +{* 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 *} +{* *} +{**************************************************************************} + +

Gestion des noms{if t($hruid)} de {profile user=$uid promo=true directory=false}{/if}

+ +{if t($hruid)} +
+ + + + + + + {foreach from=$names item=name key=type} + + + + + + {/foreach} +
Version actuelleVersion suggérée
{$name_types.$type}{$name.standard}
+

+ +

+
+

+ Retour à la gestion des noms. +

+{else} +
+

+ Il est possible d'entrer ici n'importe quelle adresse email : redirection, melix ou alias.
+ + +

+
+{/if} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index a29b211..74d07d1 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -103,6 +103,8 @@ Homonymes   |   Décès +   |   + Noms diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index 450fc2d..4ee4407 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -83,6 +83,12 @@ + + + Si la casse de ton nom est erronée et que tu n'arrives pas à la corriger, + contacte-nous. + +