[Fusionforge-commits] r9894 - trunk/gforge/common/include

Roland Mas lolando at libremir.placard.fr.eu.org
Fri May 21 18:06:07 CEST 2010


Author: lolando
Date: 2010-05-21 18:06:07 +0200 (Fri, 21 May 2010)
New Revision: 9894

Modified:
   trunk/gforge/common/include/Group.class.php
   trunk/gforge/common/include/RBAC.php
Log:
Fixed Group::getUsers()

Modified: trunk/gforge/common/include/Group.class.php
===================================================================
--- trunk/gforge/common/include/Group.class.php	2010-05-21 15:53:24 UTC (rev 9893)
+++ trunk/gforge/common/include/Group.class.php	2010-05-21 16:06:07 UTC (rev 9894)
@@ -2543,20 +2543,38 @@
 	 *	@return array of user's objects.
 	 */
 	function getUsers() {
-		$users = Array();
+		$users = array () ;
+
+		if (USE_PFO_RBAC) {
+			$ids = array () ;
+			foreach ($this->getRoles() as $role) {
+				foreach ($role->getUsers() as $user) {
+					$ids[] = $user->getID() ;
+				}
+			}
+			$ids = array_unique ($ids) ;
+			foreach ($ids as $id) {
+				$u = user_get_object ($id) ;
+				if ($u->isActive()) {
+					$users[] = new GFUser ($id) ;
+				}
+			}
+		} else {
 		
-		$users_group_res = db_query_params ('SELECT u.user_id FROM users u, user_group ug WHERE ug.group_id=$1 AND ug.user_id=u.user_id AND u.status=$2',
-					array ($this->getID(),
-					'A'));
-		if (!$users_group_res) {
-			$this->setError('Error: Enable to get users from group '. $this->getID() . ' ' .db_error());
-			return false;
+			$users_group_res = db_query_params ('SELECT u.user_id FROM users u, user_group ug WHERE ug.group_id=$1 AND ug.user_id=u.user_id AND u.status=$2',
+							    array ($this->getID(),
+								   'A'));
+			if (!$users_group_res) {
+				$this->setError('Error: Enable to get users from group '. $this->getID() . ' ' .db_error());
+				return false;
+			}
+			
+			for ($i=0; $i<db_numrows($users_group_res); $i++) {
+				$users[$i] = new GFUser(db_result($users_group_res,$i,'user_id'),false);
+			}
+			
 		}
-		
-		for ($i=0; $i<db_numrows($users_group_res); $i++) {
-			$users[$i] = new GFUser(db_result($users_group_res,$i,'user_id'),false);
-		}
-		
+
 		return $users;
 	}
 }

Modified: trunk/gforge/common/include/RBAC.php
===================================================================
--- trunk/gforge/common/include/RBAC.php	2010-05-21 15:53:24 UTC (rev 9893)
+++ trunk/gforge/common/include/RBAC.php	2010-05-21 16:06:07 UTC (rev 9894)
@@ -223,7 +223,7 @@
 	}
 
 	public function getUsers() {
-		throw new Exception ("Not implemented") ;
+		return array () ;
 	}
 	public function hasUser($user) {
 		throw new Exception ("Not implemented") ;




More information about the Fusionforge-commits mailing list