From 8338711c653db15f2bf5b7e3df374d13eeeac84e Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 16 Sep 2010 15:58:28 +0200 Subject: [PATCH] Rewrite admin/accounts. This page can now be used as a portal for account management. It provides the following tools: * access to account edition page * list of non-automatic account (currently only 'ax' accounts are listed here) * small form to add an 'ax' account * link to other account-related admin pages. Signed-off-by: Florent Bruneau --- modules/admin.php | 40 ++++++++++++- templates/admin/account_watch.tpl | 58 +++++++++++++++++++ templates/admin/accounts.tpl | 116 ++++++++++++++++++++++++++++---------- templates/admin/index.tpl | 14 ++--- templates/admin/user.tpl | 42 +------------- 5 files changed, 187 insertions(+), 83 deletions(-) create mode 100644 templates/admin/account_watch.tpl diff --git a/modules/admin.php b/modules/admin.php index bde2161..c98c5bc 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -47,6 +47,7 @@ class AdminModule extends PLModule 'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'), 'admin/icons' => $this->make_hook('icons', AUTH_MDP, 'admin'), 'admin/accounts' => $this->make_hook('accounts', AUTH_MDP, 'admin'), + 'admin/account/watch' => $this->make_hook('account_watch', AUTH_MDP, 'admin'), 'admin/account/types' => $this->make_hook('account_types', AUTH_MDP, 'admin'), 'admin/jobs' => $this->make_hook('jobs', AUTH_MDP, 'admin'), ); @@ -381,8 +382,7 @@ class AdminModule extends PLModule $user = User::get($login); } if (empty($user)) { - $page->assign('user', false); - return; + pl_redirect('admin/accounts'); } $login = $user->login(); @@ -1141,6 +1141,40 @@ class AdminModule extends PLModule $table_editor->apply($page, $action, $id); } + function handler_accounts(PlPage $page) + { + $page->changeTpl('admin/accounts.tpl'); + $page->setTitle('Administration - Comptes'); + $page->addJsLink('password.js'); + + if (Post::has('create_account')) { + S::assert_xsrf_token(); + $firstname = Post::t('firstname'); + $lastname = strtoupper(Post::t('lastname')); + $sex = Post::b('sex') ? User::GENDER_FEMALE : User::GENDER_FEMALE; + $email = Post::t('email'); + $login = PlUser::makeHrid($firstname, $lastname, 'ax'); + if (!isvalid_email($email)) { + $page->trigError("Invalid email address: $email"); + } else if (strlen(Post::s('pwhash')) != 40) { + $page->trigError("Invalid password hash"); + } else { + $full_name = $firstname . ' ' . $lastname; + $directory_name = $lastname . ' ' . $firstname; + XDB::execute("INSERT INTO accounts (hruid, type, state, password, + registration_date, email, full_name, + display_name, sex, directory_name) + VALUES ({?}, 'ax', 'active', {?}, NOW(), {?}, {?}, {?}, {?}, {?})", + $login, Post::s('pwhash'), $email, $full_name, $full_name, $sex, + $directory_name); + } + } + + $uf = new UserFilter(new UFC_AccountType('ax')); + $page->assign('users', $uf->iterUsers(new PlLimit(10))); + + } + function handler_account_types(&$page, $action = 'list', $id = null) { $page->setTitle('Administration - Types de comptes'); @@ -1344,7 +1378,7 @@ class AdminModule extends PLModule $page->assign('icons', $icons); } - function handler_accounts(&$page) + function handler_account_watch(&$page) { $page->changeTpl('admin/accounts.tpl'); $page->assign('disabled', XDB::iterator('SELECT a.hruid, FIND_IN_SET(\'watch\', a.flags) AS watch, diff --git a/templates/admin/account_watch.tpl b/templates/admin/account_watch.tpl new file mode 100644 index 0000000..a696a16 --- /dev/null +++ b/templates/admin/account_watch.tpl @@ -0,0 +1,58 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2010 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 *} +{* *} +{**************************************************************************} + +

{$disabled->total()} Comptes désactivés ou surveillés

+ + + + {iterate from=$disabled item=user} + + + + + + + {/iterate} +
NomDisabledSurveilléCommentaire
+ {$user.hruid} + + + + + + {$user.comment} +
+ +

{$admins->total()} Administrateurs du site

+ + + + {iterate from=$admins item=user} + + + + {/iterate} +
Utilisateur
+ {$user.hruid} +
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/admin/accounts.tpl b/templates/admin/accounts.tpl index a696a16..5488d05 100644 --- a/templates/admin/accounts.tpl +++ b/templates/admin/accounts.tpl @@ -20,39 +20,93 @@ {* *} {**************************************************************************} -

{$disabled->total()} Comptes désactivés ou surveillés

+{literal} + +{/literal} - - - {iterate from=$disabled item=user} - - - - - - - {/iterate} -
NomDisabledSurveilléCommentaire
- {$user.hruid} - - - - - - {$user.comment} -
+
+ {icon name=user_edit} Administrer un compte +
+ {xsrf_token_field} +

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

+

+ + + + +

+
+
-

{$admins->total()} Administrateurs du site

+
+ Liste des comptes manuels - - - {iterate from=$admins item=user} - - - - {/iterate} -
Utilisateur
- {$user.hruid} -
+ +
+ +
+ Nouveau compte + + +

+

+ {xsrf_token_field} + + + + + + + + + + + + + + + + + + + + + + + + +
Nom
Prénom
Sexe
Email
Mot de passe +
+ + +
+
+ {checkpasswd prompt="password" submit="create_account" text="Créer le compte"} +
+
+ +
+
+

+
{* 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 e982af0..d8ef364 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -96,21 +96,19 @@ Types de comptes   |   - Ajout de comptes -   |   - Édition + Gestion des comptes   |   Homonymes   |   Décès - + Administration Décédés actifs   |   - Administrateurs/Désactivations + Administrateurs/Désactivations   |   Google Apps @@ -129,7 +127,7 @@ Niveau par formation - + Emploi Secteurs @@ -141,7 +139,7 @@ Grade - + Profil Binets @@ -155,7 +153,7 @@ Networking - + Compte Skins diff --git a/templates/admin/user.tpl b/templates/admin/user.tpl index b743779..a5a790a 100644 --- a/templates/admin/user.tpl +++ b/templates/admin/user.tpl @@ -30,7 +30,7 @@ -{elseif $user} +{else} {literal} -{/literal} -
- {xsrf_token_field} - - - - - - - - - - - - - -
- Administrer -
- Il est possible d'entrer ici n'importe quelle adresse mail : redirection, melix, ou alias. -
- -
-    -    - -
-
{/if} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4