[Fusionforge-commits] r11132 - trunk/src/common/tracker

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Oct 22 13:42:21 CEST 2010


Author: lolando
Date: 2010-10-22 13:42:21 +0200 (Fri, 22 Oct 2010)
New Revision: 11132

Modified:
   trunk/src/common/tracker/ArtifactWorkflow.class.php
Log:
Use RBAC for artifact workflow checking

Modified: trunk/src/common/tracker/ArtifactWorkflow.class.php
===================================================================
--- trunk/src/common/tracker/ArtifactWorkflow.class.php	2010-10-22 11:19:14 UTC (rev 11131)
+++ trunk/src/common/tracker/ArtifactWorkflow.class.php	2010-10-22 11:42:21 UTC (rev 11132)
@@ -59,16 +59,23 @@
 				return true;
 
 			// There is a transition, now check if current role is allowed.
-
+			$rids = array () ;
+			$available_roles = RBACEngine::getInstance()->getAvailableRoles() ;
+			$project_role_ids = $this->ath->Group->getRolesId () ;
+			foreach ($available_roles as $role) {
+				if (in_array($role->getID(),$project_role_ids)) {
+					$rids[] = $role->getID() ;
+				}
+			}
+			
 			$res = db_query_params ('SELECT event_id 
-					FROM user_group, artifact_workflow_roles 
-					WHERE user_id=$1
-					AND group_id=$2
-					AND event_id=$3 
-					AND user_group.role_id=artifact_workflow_roles.role_id',
-			array(user_getid(),
-				$this->ath->Group->getID(),
-				$event_id));
+					FROM artifact_workflow_roles 
+					WHERE group_id=$1
+					AND event_id=$2
+					AND role_id=ANY($3)',
+						array ($this->ath->Group->getID(),
+						       $event_id,
+						       db_int_array_to_any_clause($rids)));
 			return db_result($res, 0, 'event_id') ? true : false;
 		}
 		return false;




More information about the Fusionforge-commits mailing list