[pLog-svn] r4209 - plog/trunk/class/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Oct 29 18:09:28 GMT 2006


Author: oscar
Date: 2006-10-29 18:09:27 +0000 (Sun, 29 Oct 2006)
New Revision: 4209

Modified:
   plog/trunk/class/dao/userpermissions.class.php
Log:
added the revokePermissions() method use to remove all permissions granted to a user in a given blog, and a small fix


Modified: plog/trunk/class/dao/userpermissions.class.php
===================================================================
--- plog/trunk/class/dao/userpermissions.class.php	2006-10-29 18:08:49 UTC (rev 4208)
+++ plog/trunk/class/dao/userpermissions.class.php	2006-10-29 18:09:27 UTC (rev 4209)
@@ -48,7 +48,7 @@
 				
 			foreach( $userPerms as $perm ) {
 				if( $perm->getBlogId() == $blogId )
-					$perms[] = $perm;
+					$perms[$perm->getPermissionId()] = $perm;
 			}
 										
             return( $perms );
@@ -125,6 +125,28 @@
 			return( $result );
         }
 
+		/**
+		 * Removes all the user permissions from a given blog
+		 *
+		 * @param userId
+		 * @param blogId
+		 * @return True if successful or false otherwise
+		 */
+		function revokePermissions( $userId, $blogId ) 
+		{
+			// build the query to remove the row
+			$query = "DELETE FROM ".$this->getPrefix()."users_permissions WHERE user_id = '".Db::qstr( $userId )."'
+			          AND blog_id = '".Db::qstr( $blogId )."'";
+			
+			// and execute it
+			$result = $this->Execute( $query );
+			if( $result ) {
+				$this->_cache->removeData( $userId, CACHE_USER_PERMISSIONS );
+			}
+			
+			return( $result );			
+		}
+
         /**
          * removes all the permissions for a given blog, useful when we're removing
          * the blog from the database.



More information about the pLog-svn mailing list