[pLog-svn] r1738 - plog/branches/plog-1.1-ben/class/dao

ork at devel.plogworld.net ork at devel.plogworld.net
Tue Apr 5 15:32:52 GMT 2005


Author: ork
Date: 2005-04-05 15:32:52 +0000 (Tue, 05 Apr 2005)
New Revision: 1738

Modified:
   plog/branches/plog-1.1-ben/class/dao/users.class.php
Log:
i think that's better :) everything maps to id now.. 


Modified: plog/branches/plog-1.1-ben/class/dao/users.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/dao/users.class.php	2005-04-05 15:20:22 UTC (rev 1737)
+++ plog/branches/plog-1.1-ben/class/dao/users.class.php	2005-04-05 15:32:52 UTC (rev 1738)
@@ -77,9 +77,9 @@
          */
         function getUserInfoFromUsername( $username )
         {
-            $userInfo = $this->_cache->getData( $username, CACHE_USERINFO );
+            $userId = $this->_cache->getData( $username, CACHE_USERIDBYNAME );
 
-            if ( !$userInfo ) {
+            if ( !$userId ) {
                 $prefix = $this->getPrefix();
                 $query = "SELECT u.id AS id, u.user AS user, u.password AS password, u.email AS email,
                                  u.about AS about, u.full_name AS full_name, u.properties AS properties,
@@ -89,13 +89,14 @@
                           FROM {$prefix}users u LEFT JOIN {$prefix}users_permissions p ON u.id = p.user_id
                           WHERE u.user = '".Db::qstr($username)."'";
                  $userInfo = $this->_getUserInfoFromQuery( $query );
-                 $this->_cache->setData( $username, CACHE_USERINFO, $userInfo );
-                 // this method is mainly used by the admin panel login, so update the cache for id
-                 // as well, as all next requests will got for getUserInfoFromId().
-                 $this->_cache->setData( $userInfo->getId(), CACHE_USERINFOBYID, $userInfo );
+
+                 $this->_cache->setData( $userInfo->getUsername(), CACHE_USERIDBYNAME, $userInfo->getId() );
+                 $this->_cache->setData( $userInfo->getId(), CACHE_USERINFO, $userInfo );
+
+                 return $userInfo;
             }
 
-            return $userInfo;
+            return $this->getUserInfoFromId( $userId );
         }
 
         /**
@@ -110,7 +111,7 @@
                 $userInfo = $this->usercache[$userid];
             }
             else {
-                $userInfo = $this->_cache->getData( $userid, CACHE_USERINFOBYID );
+                $userInfo = $this->_cache->getData( $userid, CACHE_USERINFO );
                 if ( !$userInfo ) {
                     $prefix = $this->getPrefix();
                     $query = "SELECT u.id AS id, u.user AS user, u.password AS password, u.email AS email,
@@ -122,7 +123,7 @@
                               WHERE u.id = $userid";
 
                     $userInfo = $this->_getUserInfoFromQuery( $query, $extendedInfo );
-                    $this->_cache->setData( $userid, CACHE_USERINFOBYID, $userInfo );
+                    $this->_cache->setData( $userid, CACHE_USERINFO, $userInfo );
                 }
 
                 $this->usercache[$userid] = $userInfo;
@@ -282,8 +283,8 @@
             $perms = new UserPermissions();
             $perms->updateSiteAdmin( $userInfo->getId(), $userInfo->isSiteAdmin());
 
-            $this->_cache->removeData( $userInfo->getId(), CACHE_USERINFOBYID );
-            $this->_cache->removeData( $userInfo->getUsername(), CACHE_USERINFO );
+            $this->_cache->removeData( $userInfo->getId(), CACHE_USERINFOB );
+            $this->_cache->removeData( $userInfo->getUsername(), CACHE_USERIDBYNAME );
 
             return $result;
         }
@@ -403,6 +404,8 @@
             if( $this->_db->Affected_Rows() == 0 )
                 return false;
 
+            $this->_cache->removeData( $userId, CACHE_USERINFO );
+
             return true;
         }        
 




More information about the pLog-svn mailing list