[Fusionforge-commits] r14001 - trunk/src/plugins/projects_hierarchy/common

Franck VILLAUME nerville at fusionforge.org
Fri Jul 29 10:26:20 CEST 2011


Author: nerville
Date: 2011-07-29 10:26:20 +0200 (Fri, 29 Jul 2011)
New Revision: 14001

Modified:
   trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php
Log:
fix public/private projects in tree

Modified: trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php
===================================================================
--- trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php	2011-07-28 21:18:13 UTC (rev 14000)
+++ trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php	2011-07-29 08:26:20 UTC (rev 14001)
@@ -111,7 +111,7 @@
 			<script type="text/javascript" src="/plugins/projects_hierarchy/dtree.js"></script>';
 	}
 
-	function buildTree() {
+	function buildTree($private = false) {
 		global $project_name;
 		$res = db_query_params('select p1.group_id as father_id,p1.unix_group_name as father_unix_name,p1.group_name as father_name,p2.group_id as son_id,p2.unix_group_name as son_unix_name,p2.group_name as son_name
 					from groups as p1,groups as p2,plugin_projects_hierarchy_relationship
@@ -126,12 +126,14 @@
 		// value = list of sons
 		$tree = array();
 		while ($row = db_fetch_array($res)) {
-			$tree[$row['father_id']][] = $row['son_id'];
-			//get the unix name of the project
-			$project_name[$row['father_id']][0] = $row['father_name'];
-			$project_name[$row['son_id']][0] = $row['son_name'];
-			$project_name[$row['father_id']][1] = $row['father_unix_name'];
-			$project_name[$row['son_id']][1] = $row['son_unix_name'];
+			if (forge_check_perm('project_read', $row['father_id'])) {
+				$tree[$row['father_id']][] = $row['son_id'];
+				//get the unix name of the project
+				$project_name[$row['father_id']][0] = $row['father_name'];
+				$project_name[$row['son_id']][0] = $row['son_name'];
+				$project_name[$row['father_id']][1] = $row['father_unix_name'];
+				$project_name[$row['son_id']][1] = $row['son_unix_name'];
+			}
 		}
 		return $tree;
 	}
@@ -154,19 +156,21 @@
 			}
 		}
 
-		$returnTree .= '<table ><tr><td>';
-		$returnTree .= '<script type="text/javascript">';
-		$returnTree .= 'd = new dTree(\'d\');';
-		$returnTree .= 'd.add(0,-1,\'Project Tree\');';
-		reset($arbre);
-		//construction automatique de l'arbre format : (num_fils, num_pere,nom,nom_unix)
-		while (list($key2, $sons2) = each($arbre)) {
-			$returnTree .= "d.add('".$key2."','".$sons2."','".$project_name[$key2][0]."','".util_make_url( '/projects/'.$project_name[$key2][1] .'/', $project_name[$key2][1] ) ."');";
+		if (sizeof($arbre)) {
+			$returnTree .= '<table ><tr><td>';
+			$returnTree .= '<script type="text/javascript">';
+			$returnTree .= 'd = new dTree(\'d\');';
+			$returnTree .= 'd.add(0,-1,\'Project Tree\');';
+			reset($arbre);
+			//construction automatique de l'arbre format : (num_fils, num_pere,nom,nom_unix)
+			while (list($key2, $sons2) = each($arbre)) {
+				$returnTree .= "d.add('".$key2."','".$sons2."','".$project_name[$key2][0]."','".util_make_url( '/projects/'.$project_name[$key2][1] .'/', $project_name[$key2][1] ) ."');";
+			}
+
+			$returnTree .= 'document.write(d);';
+			$returnTree .= '</script>';
+			$returnTree .= '</td></tr></table>';
 		}
-
-		$returnTree .= 'document.write(d);';
-		$returnTree .= '</script>';
-		$returnTree .= '</td></tr></table>';
 		return $returnTree;
 	}
 




More information about the Fusionforge-commits mailing list