[Jaws-commits] r12478 - in branches/0.8/html/include/Jaws: . Auth

afz at jaws-project.com afz at jaws-project.com
Mon Jan 23 07:57:25 UTC 2012


Author: afz
Date: 2012-01-23 07:57:25 +0000 (Mon, 23 Jan 2012)
New Revision: 12478

Modified:
   branches/0.8/html/include/Jaws/Auth/Default.php
   branches/0.8/html/include/Jaws/Session.php
Log:
- Added avatar to user session data
- Added GetAttributes method to return mass session attributes
- Added internal attribute for determine user is internal user(in jaws user table) or not 

Modified: branches/0.8/html/include/Jaws/Auth/Default.php
===================================================================
--- branches/0.8/html/include/Jaws/Auth/Default.php	2012-01-23 07:51:34 UTC (rev 12477)
+++ branches/0.8/html/include/Jaws/Auth/Default.php	2012-01-23 07:57:25 UTC (rev 12478)
@@ -64,7 +64,9 @@
             }
 
             $info['groups'] = $groups;
+            $info['avatar'] = $this->_Model->GetAvatar($info['username'], $info['email']);
             $info['superadmin'] = $info['user_type'] === 0;
+            $info['internal']   = true;
             // Update login time
             $this->_Model->updateLoginTime($this->_AuthID);
         }

Modified: branches/0.8/html/include/Jaws/Session.php
===================================================================
--- branches/0.8/html/include/Jaws/Session.php	2012-01-23 07:51:34 UTC (rev 12477)
+++ branches/0.8/html/include/Jaws/Session.php	2012-01-23 07:57:25 UTC (rev 12478)
@@ -291,6 +291,7 @@
     {
         if (empty($info)) {
             $info['id']         = 0;
+            $info['internal']   = false;
             $info['username']   = '';
             $info['superadmin'] = false;
             $info['groups']     = array();
@@ -298,6 +299,7 @@
             $info['concurrent_logins'] = 0;
             $info['email']      = '';
             $info['url']        = '';
+            $info['avatar']     = '';
             $info['language']   = '';
             $info['theme']      = '';
             $info['editor']     = '';
@@ -306,6 +308,7 @@
 
         $this->_Attributes = array();
         $this->SetAttribute('user',       $info['id']);
+        $this->SetAttribute('internal',   $info['internal']);
         $this->SetAttribute('salt',       uniqid(mt_rand(), true));
         $this->SetAttribute('type',       APP_TYPE);
         $this->SetAttribute('username',   $info['username']);
@@ -319,6 +322,7 @@
         $this->SetAttribute('nickname',   $info['nickname']);
         $this->SetAttribute('email',      $info['email']);
         $this->SetAttribute('url',        $info['url']);
+        $this->SetAttribute('avatar',     $info['avatar']);
         //preferences
         $this->SetAttribute('language',   $info['language']);
         $this->SetAttribute('theme',      $info['theme']);
@@ -339,6 +343,7 @@
         $this->SetAttribute('user',       0);
         $this->SetAttribute('salt',       uniqid(mt_rand(), true));
         $this->SetAttribute('type',       APP_TYPE);
+        $this->SetAttribute('internal',   false);
         $this->SetAttribute('username',   '');
         $this->SetAttribute('superadmin', false);
         $this->SetAttribute('groups',     array());
@@ -348,6 +353,7 @@
         $this->SetAttribute('nickname',   '');
         $this->SetAttribute('email',      '');
         $this->SetAttribute('url',        '');
+        $this->SetAttribute('avatar',     '');
         $this->SetAttribute('language',   '');
         $this->SetAttribute('theme',      '');
         $this->SetAttribute('editor',     '');
@@ -399,6 +405,31 @@
     }
 
     /**
+     * Get a session attributes
+     *
+     * @return  array value of the attributes
+     */
+    function GetAttributes()
+    {
+        $names = func_get_args();
+        // for support array of keys array
+        if (isset($names[0][0]) && is_array($names[0][0])) {
+            $names = $names[0];
+        }
+
+        if (empty($reg_keys)) {
+            return $this->_Attributes;
+        }
+
+        $attributes = array();
+        foreach ($names as $name) {
+            $attributes[$name] = $this->GetAttribute($name);
+        }
+
+        return $attributes;
+    }
+
+    /**
      * Delete a session attribute
      *
      * @param   string $name attribute name



More information about the Jaws-commits mailing list