From: Florent Bruneau Date: Fri, 1 Oct 2010 12:04:10 +0000 (+0200) Subject: Add User::category(). X-Git-Tag: xorg/1.0.1~123 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=f60c3d1feb8de16647adba971b84c2e5ec14ab37;p=platal.git Add User::category(). The category is: * the promotion if the user have one * the description of the type of the user's account. Add default description for already defined user account types (this description can be edited through the admin/account/types page). Signed-off-by: Florent Bruneau --- diff --git a/classes/user.php b/classes/user.php index fcd4fb5..82c41f4 100644 --- a/classes/user.php +++ b/classes/user.php @@ -194,7 +194,7 @@ class User extends PlUser IF (ab.alias IS NULL, NULL, CONCAT(ab.alias, \'@' . $globals->mail->domain2 . '\')) AS bestalias_alternate, a.email, a.full_name, a.directory_name, a.display_name, a.sex = \'female\' AS gender, IF(a.state = \'active\', CONCAT(at.perms, \',\', IF(a.user_perms IS NULL, \'\', a.user_perms)), \'\') AS perms, - a.user_perms, a.email_format, a.is_admin, a.state, a.type, a.skin, + a.user_perms, a.email_format, a.is_admin, a.state, a.type, at.description AS type_description, a.skin, FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment, a.weak_password IS NOT NULL AS weak_access, g.g_account_name IS NOT NULL AS googleapps, a.token IS NOT NULL AS token_access, a.token, a.last_version, @@ -269,6 +269,16 @@ class User extends PlUser return $this->profile()->promo(); } + public function category() + { + $promo = $this->promo(); + if (!empty($promo)) { + return $promo; + } else { + return $this->type_description; + } + } + public function firstName() { if (!$this->hasProfile()) { diff --git a/upgrade/1.0.1/02_accounts.sql b/upgrade/1.0.1/02_accounts.sql index 6d694df..5e5593f 100644 --- a/upgrade/1.0.1/02_accounts.sql +++ b/upgrade/1.0.1/02_accounts.sql @@ -10,19 +10,20 @@ UPDATE accounts AS a INNER JOIN account_profiles AS ap ON (ap.uid = pd.pid AND FIND_IN_SET('owner', perms)) WHERE a.uid = ap.uid); -ALTER TABLE account_types + ALTER TABLE account_types CHANGE COLUMN perms perms SET('groups', 'mail', 'directory_ax', 'directory_private', - 'edit_directory', 'forums', 'lists', 'payment') NOT NULL; + 'edit_directory', 'forums', 'lists', 'payment') NOT NULL, + ADD COLUMN description TEXT DEFAULT NULL; -REPLACE INTO account_types VALUES ('x', 'groups,mail,directory_private,forums,lists,payment'), - ('master', 'groups,directory_private,forums,lists,payment'), - ('phd', 'groups,directory_private,forums,lists,payment'), - ('pi', 'groups,forums,lists'), - ('ax', 'groups,directory_ax,edit_directory'), - ('xnet', 'groups'), - ('school', 'groups,directory_ax'), - ('fx', 'groups,directory_ax'), - ('virtual', ''); +REPLACE INTO account_types VALUES ('x', 'groups,mail,directory_private,forums,lists,payment', 'Polytechnicien'), + ('master', 'groups,directory_private,forums,lists,payment', 'Master de l\'X'), + ('phd', 'groups,directory_private,forums,lists,payment', 'Docteur de l\'X'), + ('pi', 'groups,forums,lists', 'Elève du programme international'), + ('ax', 'groups,directory_ax,edit_directory', 'Secrétariat de l\'AX'), + ('xnet', 'groups', NULL), + ('school', 'groups,directory_ax', 'Personnel de l\'X'), + ('fx', 'groups,directory_ax', 'Personnel de la FX'), + ('virtual', '', NULL); -- vim:set syntax=mysql: