Bye bye auth_user_quick...
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 28 Dec 2008 15:33:40 +0000 (16:33 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 28 Dec 2008 15:48:52 +0000 (16:48 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/xorgsession.php
modules/platal.php
upgrade/account/00_account.sql
upgrade/account/03_carnet.sql [new file with mode: 0644]
upgrade/account/99_insertion.sql
upgrade/account/README

index a397106..61490d1 100644 (file)
@@ -184,18 +184,17 @@ class XorgSession extends PlSession
         // Retrieves main user properties.
         /** TODO: Move needed informations to account tables */
         /** TODO: Currently suppressed data are matricule, promo */
-        /** TODO: Data to move are: banana_last, watch_last, last_version */
         /** TODO: Use the User object to fetch all this */
         $res  = XDB::query("SELECT  a.uid, a.hruid, a.display_name, a.full_name, a.password,
                                     a.sex = 'female' AS femme, a.email_format,
                                     a.token, FIND_IN_SET('watch', a.flags) AS watch_account,
-                                    UNIX_TIMESTAMP(fp.last_seen) AS banana_last, q.watch_last,
-                                    q.last_version, g.g_account_name IS NOT NULL AS googleapps,
+                                    UNIX_TIMESTAMP(fp.last_seen) AS banana_last, w.last AS watch_last,
+                                    a.last_version, g.g_account_name IS NOT NULL AS googleapps,
                                     UNIX_TIMESTAMP(s.start) AS lastlogin, s.host,
                                     a.is_admin, at.perms
                               FROM  accounts        AS a
                         INNER JOIN  account_types   AS at ON(a.type = at.type)
-                        INNER JOIN  auth_user_quick AS q  ON(a.uid = q.user_id)
+                        INNER JOIN  watch           AS w  ON(w.uid = a.uid)
                          LEFT JOIN  forum_profiles  AS fp ON(fp.uid = a.uid)
                          LEFT JOIN  gapps_accounts  AS g  ON(a.uid = g.l_userid AND g.g_status = 'active')
                          LEFT JOIN  logger.last_sessions AS ls ON (ls.uid = a.uid)
index 76d77ec..23031f5 100644 (file)
@@ -261,24 +261,22 @@ class PlatalModule extends PLModule
 
         if (Env::v('op') == "Valider" && strlen($pass) >= 6
             &&  Env::v('smtppass1') == Env::v('smtppass2')) {
-            // FIXME: Put smtppass somewhere
-            XDB::execute('UPDATE  auth_user_md5
-                             SET  smtppass = {?}
-                           WHERE  user_id = {?}', $pass, $uid);
+            XDB::execute('UPDATE  accounts
+                             SET  weak_password = {?}
+                           WHERE  uid = {?}', $pass, $uid);
             $page->trigSuccess('Mot de passe enregistrĂ©');
             S::logger()->log("passwd_ssl");
         } elseif (Env::v('op') == "Supprimer") {
-            // FIXME: Put smtppass somewhere
-            XDB::execute('UPDATE  auth_user_md5
-                             SET  smtppass = ""
-                           WHERE  user_id = {?}', $uid);
+            XDB::execute('UPDATE  accounts
+                             SET  weak_password = NULL
+                           WHERE  uid = {?}', $uid);
             $page->trigSuccess('Compte SMTP et NNTP supprimĂ©');
             S::logger()->log("passwd_del");
         }
 
-        $res = XDB::query("SELECT IF(smtppass != '', 'actif', '')
-                                       FROM auth_user_md5
-                                      WHERE user_id = {?}", $uid);
+        $res = XDB::query("SELECT  weak_password IS NOT NULL
+                             FROM  accounts
+                            WHERE  uid = {?}", $uid);
         $page->assign('actif', $res->fetchOneCell());
     }
 
index 1a4bc9c..cc19b83 100644 (file)
@@ -11,6 +11,7 @@ CREATE TABLE accounts (
   # Access
   password char(40) default null,
   token varchar(32) default null,
+  weak_password varchar(256) default null,
   registration_date datetime not null,
 
   # Administrative tools
@@ -23,6 +24,7 @@ CREATE TABLE accounts (
   sex enum('female', 'male') not null default 'male',
   email_format enum('text', 'html') not null default 'html',
   skin varchar(32) default null,
+  last_version varchar(16) not null,
 
   primary key uid (uid),
   unique key hruid (hruid),
diff --git a/upgrade/account/03_carnet.sql b/upgrade/account/03_carnet.sql
new file mode 100644 (file)
index 0000000..3d3d4fd
--- /dev/null
@@ -0,0 +1,10 @@
+create table watch (
+  uid   int(6) not null auto_increment,
+  flags set('contacts', 'mail') not null default 'contacts',
+  last  timestamp not null default '0000-00-00',
+
+  primary key uid (uid),
+  key flags (flags)
+);
+
+# vim:set syntax=mysql:
index f4512d5..0c87792 100644 (file)
@@ -9,6 +9,7 @@ insert into accounts
             IF(perms = 'admin' or perms = 'user', 'active', perms) AS state,
             IF(LENGTH(password) = 40, password, NULL) AS password,
             IF(LENGTH(q.core_rss_hash) > 0, q.core_rss_hash, NULL) AS token,
+            IF(LENGTH(smtppass) = 0, NULL, smtppass) AS weak_password,
             date_ins AS registration_date,
             IF(FIND_IN_SET('watch', flags), 'watch', '') AS flags,
             IF(LENGTH(comment) > 0, comment, NULL) AS comment,
@@ -16,11 +17,17 @@ insert into accounts
             prenom AS display_name,
             IF(FIND_IN_SET('femme', flags), 'female', 'male') AS sex,
             IF(q.core_mail_fmt = 'html', 'html', 'text') AS email_format,
-            q.skin AS skin
+            q.skin AS skin,
+            q.last_version AS last_version
        from auth_user_md5 as u
   left join auth_user_quick as q on (q.user_id = u.user_id)
       where hruid is not null;
 
+# Insert carnet-relative data
+insert into watch
+     select user_id as uid, watch_flags as flags, watch_last as last
+       from auth_user_quick;
+
 # Insert all existing profiles
 insert into profiles
      select user_id AS pid, hruid AS hrpid, matricule AS xorg_id,
index 15e599c..fc9da52 100644 (file)
@@ -17,3 +17,7 @@ Affected services:
 News:
 * authentication must use account + account_types with weakpass.
 * forums base dropped and moved to forum_ namespace.
+
+
+Email:
+* auth_user_md5.smtppass -> accounts.weak_password. This password is NULL when empty, but a check must be added for empty passwords.