From: Stéphane Jacob Date: Sat, 17 Jul 2010 16:23:01 +0000 (+0200) Subject: Forbids user's name edition if she owns a profile, update profile sex when user has... X-Git-Tag: xorg/1.0.1~326 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=aef87266d036231fdd3f841cf35cc007c80afec9;p=platal.git Forbids user's name edition if she owns a profile, update profile sex when user has been updated. Signed-off-by: Stéphane Jacob --- 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