[Jaws-commits] r12465 - trunk/jaws/html/include/Jaws

afz at jaws-project.com afz at jaws-project.com
Sat Jan 21 21:16:31 UTC 2012


Author: afz
Date: 2012-01-21 21:16:31 +0000 (Sat, 21 Jan 2012)
New Revision: 12465

Modified:
   trunk/jaws/html/include/Jaws/Session.php
Log:
some cosmetics for jaws session

Modified: trunk/jaws/html/include/Jaws/Session.php
===================================================================
--- trunk/jaws/html/include/Jaws/Session.php	2012-01-21 21:16:04 UTC (rev 12464)
+++ trunk/jaws/html/include/Jaws/Session.php	2012-01-21 21:16:31 UTC (rev 12465)
@@ -29,14 +29,6 @@
     var $_AuthMethod;
 
     /**
-     * Logged flag
-     * @var     boolean $_Logged
-     * @access  private
-     * @see     Logged()
-     */
-    var $_Logged = false;
-
-    /**
      * Last error message
      * @var     string $_Error
      * @access  private
@@ -168,7 +160,6 @@
                     empty($result['concurrent_logins']) ||
                     $result['concurrent_logins'] > $existSessions)
                 {
-                    $this->_Logged = true;
                     $this->Create($username, $remember);
 
                     // Update login time
@@ -202,7 +193,7 @@
                 return false;
             }
         }
-        return $this->_Logged;
+        return $this->GetAttribute('logged');
     }
 
     /**
@@ -251,7 +242,6 @@
 
             $this->_SessionID  = $session['sid'];
             $this->_Attributes = unserialize($session['data']);
-            $this->_Logged     = (int) $this->GetAttribute('user') != 0;
 
             if ($session['updatetime'] < ($expTime - $session['longevity'])) {
                 // only reset session data
@@ -280,7 +270,7 @@
                         $referrer = $_SERVER['HTTP_HOST'];
                     }
 
-                    if (!$this->_Logged ||
+                    if (!$this->GetAttribute('logged') ||
                         $referrer == $_SERVER['HTTP_HOST'] ||
                         $session['referrer'] === md5($referrer))
                     {
@@ -352,13 +342,15 @@
 
         $this->_Attributes = array();
         $this->SetAttribute('user',      $info['id']);
+        $this->SetAttribute('salt',      uniqid(mt_rand(), true));
+        $this->SetAttribute('type',      APP_TYPE);
+        $this->SetAttribute('username',  $info['username']);
         $this->SetAttribute('user_type', (int)$info['user_type']);
         $this->SetAttribute('groups',    $groups);
-        $this->SetAttribute('type',      APP_TYPE);
+        $this->SetAttribute('concurrent_logins', $info['concurrent_logins']);
         $this->SetAttribute('longevity', $remember?
                                          (int)$GLOBALS['app']->Registry->Get('/policy/session_remember_timeout')*3600 : 0);
-        $this->SetAttribute('username',  $info['username']);
-        $this->SetAttribute('concurrent_logins', $info['concurrent_logins']);
+        $this->SetAttribute('logged',    $info['id'] !== 0);
         //profile
         $this->SetAttribute('nickname',  $info['nickname']);
         $this->SetAttribute('email',     $info['email']);
@@ -368,7 +360,6 @@
         $this->SetAttribute('theme',     $info['theme']);
         $this->SetAttribute('editor',    $info['editor']);
         $this->SetAttribute('timezone',  (trim($info['timezone']) == "") ? null : $info['timezone']);
-        $this->SetAttribute('salt',      uniqid(mt_rand(), true));
 
         $this->_SessionID = $this->Synchronize($this->_SessionID);
         return true;
@@ -386,8 +377,10 @@
         $this->SetAttribute('type',       APP_TYPE);
         $this->SetAttribute('username',   '');
         $this->SetAttribute('user_type',  0);
-        $this->SetAttribute('concurrent_logins', 0);
         $this->SetAttribute('groups',     array());
+        $this->SetAttribute('concurrent_logins', 0);
+        $this->SetAttribute('longevity',  0);
+        $this->SetAttribute('logged',     false);
         $this->SetAttribute('nickname',   '');
         $this->SetAttribute('email',      '');
         $this->SetAttribute('url',        '');
@@ -395,7 +388,6 @@
         $this->SetAttribute('theme',      '');
         $this->SetAttribute('editor',     '');
         $this->SetAttribute('timezone',   null);
-        $this->_Logged = false;
         return true;
     }
 
@@ -503,7 +495,7 @@
      */
     function IsSuperAdmin()
     {
-        return $this->_Logged && ($this->GetAttribute('user_type') === 0);
+        return $this->GetAttribute('logged') && ($this->GetAttribute('user_type') === 0);
     }
 
     /**



More information about the Jaws-commits mailing list