From f9743cf19cc339b12c8570742e082c6836f102c1 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 4 Jan 2009 23:43:30 +0100 Subject: [PATCH] Add a form to manage the profiles associated with an account. Signed-off-by: Florent Bruneau --- modules/admin.php | 34 ++++++++++++++++++++++- templates/admin/utilisateurs.tpl | 59 +++++++++++++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/modules/admin.php b/modules/admin.php index de8381f..17f2474 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -368,7 +368,7 @@ class AdminModule extends PLModule { global $globals; $page->changeTpl('admin/utilisateurs.tpl'); - $page->setTitle('Administration - Edit/Su/Log'); + $page->setTitle('Administration - Compte'); require_once("emails.inc.php"); if (S::suid()) { @@ -407,6 +407,7 @@ class AdminModule extends PLModule // Fetches user data. $redirect = ($registered ? new Redirect($user) : null); + // Account Form {{{ $to_update = array(); if (Env::has('disable_weak_access')) { S::assert_xsrf_token(); @@ -465,6 +466,33 @@ class AdminModule extends PLModule $page->trigSuccess('Données du compte mise à jour avec succès'); $user = User::getWithUID($user->id()); } + // }}} + // Profile form {{{ + if (Env::has('add_profile') || Env::has('del_profile') || Env::has('owner')) { + S::assert_xsrf_token(); + if (Env::i('del_profile', 0) != 0) { + XDB::execute('DELETE FROM account_profiles + WHERE uid = {?} AND pid = {?}', + $user->id(), Env::i('del_profile')); + } else if (!Env::blank('new_profile')) { + $profile = Profile::get(Env::t('new_profile')); + if (!$profile) { + $page->trigError('Le profil ' . Env::t('new_profile') . ' n\'existe pas'); + } else { + XDB::execute('INSERT IGNORE INTO account_profiles (uid, pid) + VALUES ({?}, {?})', + $user->id(), $profile->id()); + } + } + XDB::execute('UPDATE account_profiles + SET perms = IF(pid = {?}, CONCAT(perms, \',owner\'), REPLACE(perms, \'owner\', \'\')) + WHERE uid = {?}', + Env::i('owner'), $user->id()); + } + + + // }}} + $page->addJsLink('ui.core.js'); $page->addJsLink('ui.tabs.js'); @@ -730,6 +758,10 @@ class AdminModule extends PLModule ORDER BY type != 'a_vie'", $user->id())); $page->assign('account_types', XDB::iterator('SELECT * FROM account_types ORDER BY type')); $page->assign('skins', XDB::iterator('SELECT id, name FROM skins ORDER BY name')); + $page->assign('profiles', XDB::iterator('SELECT p.pid, p.hrpid, FIND_IN_SET(\'owner\', ap.perms) AS owner + FROM account_profiles AS ap + INNER JOIN profiles AS p ON (ap.pid = p.pid) + WHERE ap.uid = {?}', $user->id())); // Displays email redirection and the general profile. if ($registered && $redirect) { diff --git a/templates/admin/utilisateurs.tpl b/templates/admin/utilisateurs.tpl index 94d0662..53f5def 100644 --- a/templates/admin/utilisateurs.tpl +++ b/templates/admin/utilisateurs.tpl @@ -46,6 +46,11 @@ function del_alias(alias) { document.forms.alias.submit(); } +function del_profile(pid) { + document.forms.profiles.del_profile.value = pid; + document.forms.profiles.submit(); +} + function del_fwd(fwd) { document.forms.fwds.del_fwd.value = fwd; document.forms.fwds.submit(); @@ -88,7 +93,7 @@ $(document).ready(function() {
-
+ {xsrf_token_field}

Informations sur le compte

@@ -188,7 +193,7 @@ $(document).ready(function() { {/iterate} - gérer + {icon name=wrench title=Gérer} gérer @@ -217,6 +222,46 @@ $(document).ready(function() {

+ +

Fiches associées au compte

+ +
+ {xsrf_token_field} + + + + + + + {iterate from=$profiles item=profile} + + + + + + {/iterate} + + + + + + + + +
Identifiant de la fiche
{$profile.hrpid} + {icon name=user_edit} + {icon name=user_suit} + {icon name=cross} +
+ + None
+ + + +
+
+