[pLog-svn] r5827 - plog/branches/lifetype-1.2/class/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Aug 15 15:54:57 EDT 2007


Author: oscar
Date: 2007-08-15 15:54:57 -0400 (Wed, 15 Aug 2007)
New Revision: 5827

Modified:
   plog/branches/lifetype-1.2/class/dao/userpermissions.class.php
Log:
Implemented method UserPermissions::getUsersWithPermission(), which had been left empty since LT 1.2.0 and implemented UserPermissions::getUsersWithPermissionByName()


Modified: plog/branches/lifetype-1.2/class/dao/userpermissions.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/userpermissions.class.php	2007-08-15 18:39:15 UTC (rev 5826)
+++ plog/branches/lifetype-1.2/class/dao/userpermissions.class.php	2007-08-15 19:54:57 UTC (rev 5827)
@@ -223,8 +223,42 @@
 		 */
 		function getUsersWithPermission( $permId, $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
 		{
-			// tbd
+			$query = "SELECT user_id FROM ".$this->getPrefix()."users_permissions WHERE permission_id = '".Db::qstr( $permId )."'";
+			
+			$result = $this->Execute( $query );
+			
+			if( !$result ) 
+				return( Array());
+				
+			$users = Array();
+			lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+			$users = new Users();
+			while( $row = $result->FetchRow()) {
+				// we'll get them one by one so that we can make proper usage of the cache
+				$results[] = $users->getUserInfoFromId( $row["user_id"] );
+			}
+			
+			return( $results );
 		}        
+		
+		/**
+		 * Returns all users who have the given permission, identified by its name
+		 *
+		 * @param permName
+		 * @param page
+		 * @param itemsPerPage
+		 * Return an Array of UserInfo objects or an empty array if no users have this
+		 * permission.
+		 */
+		function getUsersWithPermissionByName( $permName, $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+		{
+			$perms = new Permissions();
+			$perm = $perms->getPermissionByName( $permName );
+			if( !$perm )
+				return Array();
+				
+			return( $this->getUsersWithPermission( $perm->getId(), $page, $itemsPerPage ));
+		}		
 
         /**
          * @private



More information about the pLog-svn mailing list