From aef87266d036231fdd3f841cf35cc007c80afec9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Sat, 17 Jul 2010 18:23:01 +0200 Subject: [PATCH] Forbids user's name edition if she owns a profile, update profile sex when user has been updated. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- modules/admin.php | 28 +++++++++++++++++----------- templates/admin/user.tpl | 6 +++--- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/modules/admin.php b/modules/admin.php index 9621f21..4d58460 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -413,20 +413,25 @@ class AdminModule extends PLModule if (Post::has('disable_weak_access')) { $to_update['weak_password'] = null; } else if (Post::has('update_account')) { - if (Post::s('full_name') != $user->fullName()) { - // XXX: Update profile if a profile is associated - $to_update['full_name'] = Post::s('full_name'); - } - if (Post::s('display_name') != $user->displayName()) { - // XXX: Update profile if a profile is associated - $to_update['display_name'] = Post::s('display_name'); - } - if (Post::s('directory_name') != $user->directoryName()) { - // XXX: Update profile if a profile is associated - $to_update['directory_name'] = Post::s('directory_name'); + if (!$user->hasProfile()) { + if (Post::s('full_name') != $user->fullName()) { + $to_update['full_name'] = Post::s('full_name'); + } + if (Post::s('display_name') != $user->displayName()) { + $to_update['display_name'] = Post::s('display_name'); + } + if (Post::s('directory_name') != $user->directoryName()) { + $to_update['directory_name'] = Post::s('directory_name'); + } } if (Post::s('sex') != ($user->isFemale() ? 'female' : 'male')) { $to_update['sex'] = Post::s('sex'); + if ($user->hasProfile()) { + XDB::execute('UPDATE profiles + SET sex = {?} + WHERE pid = {?}', + Post::s('sex'), $user->profile()->id()); + } } if (!Post::blank('hashpass')) { $to_update['password'] = Post::s('hashpass'); @@ -669,6 +674,7 @@ class AdminModule extends PLModule } $page->assign('user', $user); + $page->assign('hasProfile', $user->hasProfile()); // Displays forum bans. $res = XDB::query("SELECT write_perm, read_perm, comment diff --git a/templates/admin/user.tpl b/templates/admin/user.tpl index 115b517..7d74d28 100644 --- a/templates/admin/user.tpl +++ b/templates/admin/user.tpl @@ -127,15 +127,15 @@ $(document).ready(function() { Nom complet - + {if $hasProfile}{$user->fullName()}{else}{/if} Nom annuaire - + {if $hasProfile}{$user->directoryName()}{else}{/if} Nom affiché - + {if $hasProfile}{$user->displayName()}{else}{/if} Sexe -- 2.1.4