Add User::category().
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 1 Oct 2010 12:04:10 +0000 (14:04 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 1 Oct 2010 12:09:54 +0000 (14:09 +0200)
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 <florent.bruneau@polytechnique.org>
classes/user.php
upgrade/1.0.1/02_accounts.sql

index fcd4fb5..82c41f4 100644 (file)
@@ -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()) {
index 6d694df..5e5593f 100644 (file)
@@ -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: