From 8f2104cbd0adbdf2d0147cbfa2241b697e1c37aa Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Wed, 31 Dec 2008 14:45:45 +0100 Subject: [PATCH] Stub for a account administration form (admin/user). Signed-off-by: Florent Bruneau --- classes/user.php | 48 +++++++-- include/validations.inc.php | 5 +- modules/admin.php | 27 +++-- templates/admin/utilisateurs.tpl | 215 ++++++++++++++++++++++++--------------- 4 files changed, 188 insertions(+), 107 deletions(-) diff --git a/classes/user.php b/classes/user.php index f97db1d..2e23ff0 100644 --- a/classes/user.php +++ b/classes/user.php @@ -132,7 +132,7 @@ class User extends PlUser { if ($this->hruid !== null && $this->forlife !== null && $this->bestalias !== null && $this->display_name !== null - && $this->full_name !== null && $this->promo !== null && $this->perms !== null + && $this->full_name !== null && $this->perms !== null && $this->gender !== null && $this->email_format !== null) { return; } @@ -140,15 +140,17 @@ class User extends PlUser global $globals; /** TODO: promo stuff again */ /** TODO: fix perms field to fit new perms system */ - $res = XDB::query("SELECT a.hruid, d.promo, + $res = XDB::query("SELECT a.hruid, a.registration_date, CONCAT(af.alias, '@{$globals->mail->domain}') AS forlife, CONCAT(ab.alias, '@{$globals->mail->domain}') AS bestalias, a.full_name, a.display_name, a.sex = 'female' AS gender, IF(a.state = 'active', at.perms, '') AS perms, - a.email_format, a.is_admin + a.email_format, a.is_admin, a.state, a.type, a.skin, + FIND_IN_SET('watch', a.flags) AS watch, a.comment, + a.weak_password IS NOT NULL AS weak_access, + a.token IS NOT NULL AS token_access FROM accounts AS a INNER JOIN account_types AS at ON (at.type = a.type) - INNER JOIN profile_display AS d ON (d.pid = a.uid) LEFT JOIN aliases AS af ON (af.id = a.uid AND af.type = 'a_vie') LEFT JOIN aliases AS ab ON (ab.id = a.uid AND FIND_IN_SET('bestalias', ab.flags)) WHERE a.uid = {?}", $this->user_id); @@ -214,6 +216,17 @@ class User extends PlUser WHERE a.uid = {?}', $this->id()); } + /** Overload PlUser::promo(): there no promo defined for a user in the current + * schema. The promo is a field from the profile. + */ + public function promo() + { + if (!$this->hasProfile()) { + return ''; + } + return $this->profile()->promo(); + } + /** Return the main profile attached with this account if any. */ public function profile() @@ -237,12 +250,27 @@ class User extends PlUser public function emailAlias() { global $globals; - return XDB::fetchOneCell("SELECT v.alias - FROM virtual AS v - INNER JOIN virtual_redirect AS vr ON (v.vid = vr.vid) - WHERE (vr.redirect = {?} OR vr.redirect = {?}) - AND alias LIKE '%@{$globals->mail->alias_dom}'", - $this->forlifeEmail(), $this->m4xForlifeEmail(), $this->id()); + $data = $this->emailAliases($globals->mail->alias_dom); + if (count($data) > 0) { + return array_pop($data); + } + return null; + } + + /** Get all the aliases the user belongs to. + */ + public function emailAliases($domain = null) + { + $where = ''; + if (!is_null($domain)) { + $where = XDB::format(' AND alias LIKE CONCAT("%@", {?})', $domain); + } + return XDB::fetchColumn('SELECT v.alias + FROM virtual AS v + INNER JOIN virtual_redirect AS vr ON (v.vid = vr.vid) + WHERE (vr.redirect = {?} OR vr.redirect = {?}) + ' . $where, + $this->forlifeEmail(), $this->m4xForlifeEmail()); } /** Get the alternative forlife email diff --git a/include/validations.inc.php b/include/validations.inc.php index ce0b12d..3ab4f0f 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -85,10 +85,7 @@ abstract class Validate $this->stamp = date('YmdHis'); $this->unique = $_unique; $this->type = $_type; - $res = XDB::query("SELECT promo - FROM profile_display - WHERE pid={?}", $this->user->id()); - $this->promo = $res->fetchOneCell(); + $this->promo = $this->user->promo(); } // }}} diff --git a/modules/admin.php b/modules/admin.php index 4a9350e..b7d3c02 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -49,6 +49,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/types' => $this->make_hook('account_types', AUTH_MDP, 'admin'), ); } @@ -668,21 +669,14 @@ class AdminModule extends PLModule $page->assign('host', $host); // Display active aliases. - $page->assign('virtuals', XDB::iterator( - "SELECT alias - FROM virtual - INNER JOIN virtual_redirect USING (vid) - WHERE type = 'user' AND (redirect = {?} OR redirect = {?})", - $user->forlifeEmail(), - // TODO: remove this über-ugly hack. The issue is that you need - // to remove all @m4x.org addresses in virtual_redirect first. - $user->login() . '@' . $globals->mail->domain2)); - + $page->assign('virtuals', $user->emailAliases()); $page->assign('aliases', XDB::iterator( "SELECT alias, type='a_vie' AS for_life,FIND_IN_SET('bestalias',flags) AS best,expire FROM aliases WHERE id = {?} AND type != 'homonyme' 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')); // Displays email redirection and the general profile. if ($registered && $redirect) { @@ -1070,7 +1064,8 @@ class AdminModule extends PLModule $table_editor->apply($page, $action, $id); } - function handler_downtime(&$page, $action = 'list', $id = null) { + function handler_downtime(&$page, $action = 'list', $id = null) + { $page->setTitle('Administration - Coupures'); $page->assign('title', 'Gestion des coupures'); $table_editor = new PLTableEditor('admin/downtime','coupures','id'); @@ -1082,6 +1077,16 @@ class AdminModule extends PLModule $table_editor->apply($page, $action, $id); } + function handler_account_types(&$page, $action = 'list', $id = null) + { + $page->setTitle('Administration - Types de comptes'); + $page->assign('title', 'Gestion des types de comptes'); + $table_editor = new PLTableEditor('admin/account/types', 'account_types', 'type', true); + $table_editor->describe('type', 'Catégorie', true); + $table_editor->describe('perms', 'Permissions associées', true); + $table_editor->apply($page, $action, $id); + } + function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null) { if (S::hasAuthToken()) { diff --git a/templates/admin/utilisateurs.tpl b/templates/admin/utilisateurs.tpl index 5d3c207..4ed0a4e 100644 --- a/templates/admin/utilisateurs.tpl +++ b/templates/admin/utilisateurs.tpl @@ -21,11 +21,6 @@ {**************************************************************************} -

- Gestion des utilisateurs -

- - {if $smarty.post.u_kill_conf}
{xsrf_token_field} @@ -35,46 +30,7 @@
-{else} - -
- {xsrf_token_field} - - - - - {if !$smarty.request.login && !$mr.hruid} - - - - {/if} - - - - - - -
- Administrer -
- Il est possible d'entrer ici n'importe quelle adresse email : redirection, melix, ou alias. -
- -
- -    -    -    - -
-
- -{if $mr} - -

-Dernière connexion le {$lastlogin|date_format:"%d %B %Y, %T"} -depuis {$host}. -

+{elseif $user} {literal} {/literal} -
+ {xsrf_token_field} - +

Informations sur le compte

+

+ Dernière connexion le {$lastlogin|date_format:"%d %B %Y, %T"} + depuis {$host}. +

+ +
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- Matricule = {$mr.matricule}
- Matricule AX = {$mr.matricule_ax} + Inscrit le {$user->registration_date|date_format}
- UID = {$mr.user_id}
- Inscription = {$mr.date_ins|date_format} + {icon name=user_gray} {$mr.hruid} (uid {$user->id()})
- +
- Mot de passe +
Nom complet
Nom affiché
Sexe + +
Mot de passe
- - +
@@ -149,6 +121,104 @@ function ban_read()
Mot de passe SMTP +
+ + {if $user->weak_access} + + {/if} +
+
Accès RSS + +
Skin + +
Etat du compte +
+ +
Type de compte + + gérer +
+ Surveillance + +
+ Cette option permet d'avoir des logs complets de l'activité + du compte via le logger, et d'être alerté lors des connexions de l'utilisateur. +
+ Commentaire + + +
+
+
+ + +
+ +

* à ne modifier qu'avec l'accord express de l'utilisateur !!!

- + {xsrf_token_field} @@ -377,7 +429,7 @@ Pour ceci changer ses permissions en 'disabled'. {javascript name="ajax"} {test_email hruid=$user->login()} - + {xsrf_token_field}
@@ -465,6 +517,5 @@ Pour ceci changer ses permissions en 'disabled'. {/if} {/if} -{/if} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4