Rewrite FlagSet in order to run flag operation in constant time.
[platal.git] / include / xorg / session.inc.php
index 3e368e4..b3f66bf 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -180,7 +180,7 @@ class XorgSession
 
     public static function &make_perms($perm)
     {
-        $flags = new FlagSet();
+        $flags = new PlFlagSet();
         if ($perm == 'disabled' || $perm == 'ext') {
             return $flags;
         }
@@ -261,11 +261,11 @@ function start_connexion ($uid, $identified)
     $suid = S::v('suid');
 
     if ($suid) {
-        $logger = new CoreLogger($uid, $suid['uid']);
+        $logger = new PlLogger($uid, $suid['uid']);
         $logger->log("suid_start", S::v('forlife')." by {$suid['uid']}");
         $sess['suid'] = $suid;
     } else {
-        $logger = S::v('log', new CoreLogger($uid));
+        $logger = S::v('log', new PlLogger($uid));
         $logger->log("connexion", Env::v('n'));
         setcookie('ORGuid', $uid, (time()+25920000), '/', '', 0);
     }
@@ -286,7 +286,7 @@ function start_connexion ($uid, $identified)
         if (check_ip('ban')) {
             send_warning_mail($mail_subject);
             $_SESSION = array();
-            $_SESSION['perms'] = new FlagSet();
+            $_SESSION['perms'] = new PlFlagSet();
             global $page;
             $newpage = false;
             if (!$page) {
@@ -294,7 +294,7 @@ function start_connexion ($uid, $identified)
                 new_skinned_page('platal/index.tpl');
                 $newpage = true;
             }
-            $page->trig("Une erreur est survenue lors de la procédure d'authentification. "
+            $page->trigError("Une erreur est survenue lors de la procédure d'authentification. "
                        ."Merci de contacter au plus vite "
                        ."<a href='mailto:support@polytechnique.org'>support@polytechnique.org</a>");
             if ($newpage) {
@@ -307,6 +307,7 @@ function start_connexion ($uid, $identified)
         send_warning_mail($mail_subject);
     }
     set_skin();
+    update_NbNotifs();
     check_redirect();
     return true;
 }
@@ -316,13 +317,13 @@ function start_connexion ($uid, $identified)
 function set_skin()
 {
     global $globals;
-    if (S::logged() && !S::has('skin')) {
+    if (S::logged() && (!S::has('skin') || S::has('suid'))) {
         $uid = S::v('uid');
-    $res = XDB::query("SELECT  skin_tpl
-                             FROM  auth_user_quick AS a
-                       INNER JOIN  skins           AS s ON a.skin = s.id
-                            WHERE  user_id = {?} AND skin_tpl != ''", $uid);
-    if ($_SESSION['skin'] = $res->fetchOneCell()) {
+        $res = XDB::query("SELECT  skin_tpl
+                          FROM  auth_user_quick AS a
+                          INNER JOIN  skins           AS s ON a.skin = s.id
+                          WHERE  user_id = {?} AND skin_tpl != ''", $uid);
+        if ($_SESSION['skin'] = $res->fetchOneCell()) {
             return;
         }
     }