[pLog-svn] r2194 - plog/trunk/class/dao/userdata

oscar at devel.plogworld.net oscar at devel.plogworld.net
Fri Jun 10 12:23:17 GMT 2005


Author: oscar
Date: 2005-06-10 12:23:17 +0000 (Fri, 10 Jun 2005)
New Revision: 2194

Modified:
   plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
Log:
moved some common code to this class


Modified: plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/baseuserdataprovider.class.php	2005-06-10 12:22:44 UTC (rev 2193)
+++ plog/trunk/class/dao/userdata/baseuserdataprovider.class.php	2005-06-10 12:23:17 UTC (rev 2194)
@@ -1,6 +1,7 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+	include_once( PLOG_CLASS_PATH."class/dao/userstatus.class.php" );
 
 	/**
 	 * This is the base class that defines the methods that all user-data providers must implement.
@@ -99,7 +100,7 @@
             $owner = "SELECT * FROM {$prefix}blogs WHERE owner_id = ".$userid;			
 			if( $status != BLOG_STATUS_ALL ) 
 				$owner .= " AND status = '".Db::qstr( $status )."'";
-            
+           
 			$result = $this->Execute( $owner );
 
             while( $row = $result->FetchRow($result)) {
@@ -126,7 +127,36 @@
 
             return $usersBlogs;
         }
+        
+        /**
+         * @private
+         */
+        function _mapUserInfoObject( $query_result, $extendedInfo = false )
+        {
+            $userInfo = new UserInfo( $query_result["user"], $query_result["password"],
+                                      $query_result["email"],
+                                      $query_result["about"],
+                                      $query_result["full_name"],
+                                      $query_result["resource_picture_id"],
+                                      unserialize($query_result["properties"]),
+                                      $query_result["id"]);
 
+                                      
+                                      
+            if( $extraInfo ) {
+                // load this data if explicitely required!
+                $userBlogs = $this->getUsersBlogs($userInfo->getId());
+                $userInfo->setBlogs($userBlogs);
+            }
+
+            // set some permissions
+            //$userInfo->setSiteAdmin($this->perms->isSiteAdmin( $userInfo->getId()));
+            $userInfo->setSiteAdmin( $query_result["site_admin"] );
+            $userInfo->setStatus( $query_result["status"] );
+
+            return $userInfo;
+        }        
+
         /**
          * Returns an array with all the users available in the database
          *
@@ -141,7 +171,8 @@
         }
 
         /**
-         * Updates the information related to a user
+         * Updates the information related to a user. This method should be called by child classes
+         * so the user permissions (which are plog-specific) can be updated at the same time!
          *
          * @param userInfo An UserInfo object containing the <b>already udpated</b> information of the
          * user we would like to update.
@@ -149,6 +180,13 @@
          */
         function updateUser( $userInfo )
         {
+			include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );	        
+	        
+            // and now update the permissions, if there has been any change
+            $perms = new UserPermissions();
+            $perms->updateSiteAdmin( $userInfo->getId(), $userInfo->isSiteAdmin());
+            
+            return( true );
         }
 
         /**
@@ -201,16 +239,6 @@
         function getNumUsers( $status = USER_STATUS_ALL )
         {
         }
-        
-        /**
-         * returns true if the given username exists
-         *
-         * @param userName
-         * @return true if it exists or false otherwise
-         */
-        function userExists( $userName )
-        {  
-        }
 
         /**
          * get the blogid of user own




More information about the pLog-svn mailing list