[Fusionforge-commits] r14264 - in trunk/src: plugins/projects-hierarchy/common www/softwaremap

Franck VILLAUME nerville at fusionforge.org
Mon Aug 29 09:33:56 CEST 2011


Author: nerville
Date: 2011-08-29 09:33:56 +0200 (Mon, 29 Aug 2011)
New Revision: 14264

Modified:
   trunk/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php
   trunk/src/www/softwaremap/trove_list.php
Log:
fix TODO flag: move code to plugin projects-hierarchy

Modified: trunk/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php
===================================================================
--- trunk/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php	2011-08-26 16:15:34 UTC (rev 14263)
+++ trunk/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php	2011-08-29 07:33:56 UTC (rev 14264)
@@ -33,7 +33,8 @@
 		$this->_addHook('display_hierarchy'); // to see the tree of projects
 		$this->_addHook('group_delete'); // clean tables on delete
 		$this->_addHook('project_admin_plugins'); // to show up in the admin page fro group
-		$this->_addHook('site_admin_option_hook');  // to provide a link to the site wide administrative pages of plugin
+		$this->_addHook('site_admin_option_hook'); // to provide a link to the site wide administrative pages of plugin
+		$this->_addHook('display_hierarchy_submenu'); // to display a submenu in software map if projects-hierarchy plugin is used
 	}
 
 	function CallHook($hookname, &$params) {
@@ -95,6 +96,33 @@
 				$returned = true;
 				break;
 			}
+			case "display_hierarchy_submenu": {
+				// Use to display a submenu in software map page if at least one project has a valid relationship
+				$res1 = db_query_params('SELECT g.group_name FROM plugins p, group_plugin gp, groups g WHERE plugin_name = $1 and gp.group_id = g.group_id and p.plugin_id = gp.plugin_id',
+							array($this->name));
+				if ($res1) {
+					if (db_numrows($res1) > 0) {
+						$res2 = db_query_params('SELECT count(*) as used FROM plugin_projects_hierarchy_relationship where status = $1',
+									array('t'));
+						if ($res2)
+							$row = db_fetch_array($res2);
+						if ($row['used']) {
+							$hierarchy_used = true;
+						}
+					}
+				}
+				if (isset($hierarchy_used)) {
+					$hierarMenuTitle[] = _('Per Category');
+					$hierarMenuTitle[] = _('Per Hierarchy');
+					$hierarMenuAttr[] = array('title' => _('Browse per category the available projects. Some projects might not appear here they do not choose any categories'), 'class' => 'tabtitle-nw');
+					$hierarMenuAttr[] = array('title' => _('Browse per hierarchy. Projects can share relationship between projects, as father and sons'), 'class' => 'tabtitle');
+					$hierarMenuUrl[] = '/softwaremap/trove_list.php?cat=c';
+					$hierarMenuUrl[] = '/softwaremap/trove_list.php?cat=h';
+					echo ($HTML->subMenu($hierarMenuTitle, $hierarMenuUrl, $hierarMenuAttr));
+				}
+				$returned = true;
+				break;
+			}
 		}
 		return $returned;
 	}

Modified: trunk/src/www/softwaremap/trove_list.php
===================================================================
--- trunk/src/www/softwaremap/trove_list.php	2011-08-26 16:15:34 UTC (rev 14263)
+++ trunk/src/www/softwaremap/trove_list.php	2011-08-29 07:33:56 UTC (rev 14264)
@@ -59,29 +59,7 @@
 echo '<div id="project-tree" class="underline-link">' . "\n";
 echo '<h2>' . _('Project tree') . '</h2>' . "\n";
 
-// TODO : move part of this code to a proper hook managed by projects-hierarchy plugin instead of having such checks in the general code
-// display_hierarchy hook seems to be ready just for this
-$res1 = db_query_params('SELECT g.group_name FROM plugins p, group_plugin gp, groups g WHERE plugin_name = $1 and gp.group_id = g.group_id and p.plugin_id = gp.plugin_id',
-	array('projects-hierarchy'));
-if ($res1) {
-	if (db_numrows($res1) > 0) {
-		$res2 = db_query_params('SELECT count(*) as used FROM plugin_projects_hierarchy_relationship',array());
-		if ($res2)
-			$row = db_fetch_array($res2);
-			if ($row['used']) {
-				$hierarchy_used = true;
-			}
-	}
-}
-if (isset($hierarchy_used)) {
-	$hierarMenuTitle[] = _('Per Category');
-	$hierarMenuTitle[] = _('Per Hierarchy');
-	$hierarMenuAttr[] = array('title' => _('Browse per category the available projects. Some projects might not appear here they do not choose any categories'), 'class' => 'tabtitle-nw');
-	$hierarMenuAttr[] = array('title' => _('Browse per hierarchy. Projects can share relationship between projects, as father and sons'), 'class' => 'tabtitle');
-	$hierarMenuUrl[] = '/softwaremap/trove_list.php?cat=c';
-	$hierarMenuUrl[] = '/softwaremap/trove_list.php?cat=h';
-	echo ($HTML->subMenu($hierarMenuTitle, $hierarMenuUrl, $hierarMenuAttr));
-}
+plugin_hook('display_hierarchy_submenu');
 
 if ( $cat === 'c' ) {
 	$row_trove_cat = db_fetch_array($res_trove_cat);




More information about the Fusionforge-commits mailing list