[Fusionforge-commits] r9821 - in trunk/gforge/common: forum pm tracker

Roland Mas lolando at libremir.placard.fr.eu.org
Fri May 21 09:52:30 CEST 2010


Author: lolando
Date: 2010-05-21 09:52:29 +0200 (Fri, 21 May 2010)
New Revision: 9821

Modified:
   trunk/gforge/common/forum/ForumFactory.class.php
   trunk/gforge/common/pm/ProjectGroupFactory.class.php
   trunk/gforge/common/tracker/ArtifactTypeFactory.class.php
Log:
RBAC for forum/tracker/pm factories (it even makes the code simpler)

Modified: trunk/gforge/common/forum/ForumFactory.class.php
===================================================================
--- trunk/gforge/common/forum/ForumFactory.class.php	2010-05-21 07:52:14 UTC (rev 9820)
+++ trunk/gforge/common/forum/ForumFactory.class.php	2010-05-21 07:52:29 UTC (rev 9821)
@@ -82,46 +82,11 @@
 			return $this->forums;
 		}
 
-		
-		if (session_loggedin()) {
-			$perm =& $this->Group->getPermission ();
-			if (!$perm || !is_object($perm) || !$perm->isMember()) {
-				$result = db_query_params ('SELECT * FROM forum_group_list_vw
+		$result = db_query_params ('SELECT * FROM forum_group_list_vw
 WHERE group_id=$1
-AND is_public=1
 ORDER BY group_forum_id',
-							   array ($this->Group->getID())) ;
-			} else {
-				if (forge_check_perm ('forum_admin', $this->Group->getID())) {
-					$result = db_query_params ('SELECT * FROM forum_group_list_vw
-WHERE group_id=$1
-AND is_public < 3
-ORDER BY group_forum_id',
-								   array ($this->Group->getID())) ;
-				} else {
-					$result = db_query_params ('SELECT * FROM forum_group_list_vw
-WHERE group_id=$1
-AND is_public < 3
-AND group_forum_id IN (SELECT role_setting.ref_id
-                         FROM role_setting, user_group
-                         WHERE role_setting.section_name = $2
-                         AND role_setting.value::integer >= 0
-                         AND role_setting.ref_id=forum_group_list_vw.group_forum_id
-			 AND user_group.role_id = role_setting.role_id
-			 AND user_group.user_id=$3)
-ORDER BY group_forum_id',
-								   array ($this->Group->getID(),
-									  'forum',
-									  user_getid())) ;
-				}
-			}
-		} else {
-			$result = db_query_params ('SELECT * FROM forum_group_list_vw
-WHERE group_id=$1
-AND is_public=1
-ORDER BY group_forum_id',
-						   array ($this->Group->getID())) ;
-		}
+					   array ($this->Group->getID())) ;
+	}
 		
 		$rows = db_numrows($result);
 		
@@ -130,7 +95,9 @@
 			$this->forums = false;
 		} else {
 			while ($arr = db_fetch_array($result)) {
-				$this->forums[] = new Forum($this->Group, $arr['group_forum_id'], $arr);
+				if (forge_check_perm ('forum', $arr['group_forum_id'], 'read')) {
+					$this->forums[] = new Forum($this->Group, $arr['group_forum_id'], $arr);
+				}
 			}
 		}
 		return $this->forums;

Modified: trunk/gforge/common/pm/ProjectGroupFactory.class.php
===================================================================
--- trunk/gforge/common/pm/ProjectGroupFactory.class.php	2010-05-21 07:52:14 UTC (rev 9820)
+++ trunk/gforge/common/pm/ProjectGroupFactory.class.php	2010-05-21 07:52:29 UTC (rev 9821)
@@ -82,34 +82,8 @@
 		if ($this->projectGroups) {
 			return $this->projectGroups;
 		}
-		if (session_loggedin()) {
-			$perm =& $this->Group->getPermission ();
-			if (!$perm || !is_object($perm) || !$perm->isMember()) {
-				$result = db_query_params ('SELECT * FROM project_group_list_vw WHERE group_id=$1 AND is_public=1 ORDER BY group_project_id',
+		$result = db_query_params ('SELECT * FROM project_group_list_vw WHERE group_id=$1 ORDER BY group_project_id',
 							   array ($this->Group->getID())) ;
-			} else {
-				if ($perm->isPMAdmin()) {
-					$result = db_query_params ('SELECT * FROM project_group_list_vw WHERE group_id=$1 AND is_public<3 ORDER BY group_project_id',
-								   array ($this->Group->getID())) ;
-				} else {
-					$result = db_query_params ('SELECT * FROM project_group_list_vw
-	WHERE group_id=$1 AND is_public<3
-	  AND group_project_id IN (SELECT role_setting.ref_id
-			           FROM role_setting, user_group
-                                   WHERE role_setting.section_name = $2
-				     AND role_setting.value::integer >= 0
-                                     AND role_setting.ref_id=project_group_list_vw.group_project_id
-				     AND user_group.role_id = role_setting.role_id
-				     AND user_group.user_id=$3)
-        ORDER BY group_project_id',
-								   array ($this->Group->getID(),
-									  'pm',
-									  user_getid())) ;
-				}
-			}
-		} else {
-				$result = db_query_params ('SELECT * FROM project_group_list_vw WHERE group_id=$1 AND is_public=1 ORDER BY group_project_id',
-							   array ($this->Group->getID())) ;
 		}
 		$rows = db_numrows($result);
 
@@ -118,7 +92,9 @@
 			$this->projectGroups=NULL;
 		} else {
 			while ($arr = db_fetch_array($result)) {
-				$this->projectGroups[] = new ProjectGroup($this->Group, $arr['group_project_id'], $arr);
+				if (forge_check_perm ('pm', $arr['group_project_id'], 'read')) {
+					$this->projectGroups[] = new ProjectGroup($this->Group, $arr['group_project_id'], $arr);
+				}
 			}
 		}
 		return $this->projectGroups;

Modified: trunk/gforge/common/tracker/ArtifactTypeFactory.class.php
===================================================================
--- trunk/gforge/common/tracker/ArtifactTypeFactory.class.php	2010-05-21 07:52:14 UTC (rev 9820)
+++ trunk/gforge/common/tracker/ArtifactTypeFactory.class.php	2010-05-21 07:52:29 UTC (rev 9821)
@@ -88,46 +88,10 @@
 		if ($this->ArtifactTypes) {
 			return $this->ArtifactTypes;
 		}
-		if (session_loggedin()) {
-			$perm =& $this->Group->getPermission ();
-			if (!$perm || !is_object($perm) || !$perm->isMember()) {
-				$result = db_query_params ('SELECT * FROM artifact_group_list_vw
+		$result = db_query_params ('SELECT * FROM artifact_group_list_vw
 			WHERE group_id=$1
-			AND is_public=1
 			ORDER BY group_artifact_id ASC',
-							   array ($this->Group->getID())) ;
-			} else {
-				if ($perm->isArtifactAdmin()) {
-					$result = db_query_params ('SELECT * FROM artifact_group_list_vw
-			WHERE group_id=$1
-			AND is_public<3
-			ORDER BY group_artifact_id ASC',
-								   array ($this->Group->getID())) ;
-				} else {
-					$result = db_query_params ('SELECT * FROM artifact_group_list_vw
-			WHERE group_id=$1
-			AND is_public<3
-                        AND group_artifact_id IN (SELECT role_setting.ref_id
-					FROM role_setting, user_group
-					WHERE role_setting.value::integer >= 0
-                                          AND role_setting.section_name = $2
-                                          AND role_setting.ref_id=artifact_group_list_vw.group_artifact_id
-                                          
-   					  AND user_group.role_id = role_setting.role_id
-					  AND user_group.user_id = $3 )
-			ORDER BY group_artifact_id ASC',
-								   array ($this->Group->getID(),
-									  'tracker',
-									  user_getid ())) ;
-				}
-			}
-		} else {
-			$result = db_query_params ('SELECT * FROM artifact_group_list_vw
-			WHERE group_id=$1
-			AND is_public=1
-			ORDER BY group_artifact_id ASC',
-						   array ($this->Group->getID())) ;
-		}
+					   array ($this->Group->getID())) ;
 
 		$rows = db_numrows($result);
 
@@ -136,11 +100,13 @@
 			$this->ArtifactTypes=NULL;
 		} else {
 			while ($arr =& db_fetch_array($result)) {
-				$artifactType = new ArtifactType($this->Group, $arr['group_artifact_id'], $arr);
-				if($artifactType->isError()) {
-					$this->setError($artifactType->getErrorMessage());
-				} else {
-					$this->ArtifactTypes[] = $artifactType;
+				if (forge_check_perm ('tracker', $arr['group_artifact_id'], 'read')) {
+					$artifactType = new ArtifactType($this->Group, $arr['group_artifact_id'], $arr);
+					if($artifactType->isError()) {
+						$this->setError($artifactType->getErrorMessage());
+					} else {
+						$this->ArtifactTypes[] = $artifactType;
+					}
 				}
 			}
 		}




More information about the Fusionforge-commits mailing list