[Fusionforge-commits] r12351 - in trunk/src: common/include plugins/projects_hierarchy/common www/admin

Franck VILLAUME nerville at fusionforge.org
Thu Feb 24 13:42:01 CET 2011


Author: nerville
Date: 2011-02-24 13:42:01 +0100 (Thu, 24 Feb 2011)
New Revision: 12351

Modified:
   trunk/src/common/include/Group.class.php
   trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php
   trunk/src/www/admin/groupdelete.php
Log:
remove delete_link hook: use group_delete

Modified: trunk/src/common/include/Group.class.php
===================================================================
--- trunk/src/common/include/Group.class.php	2011-02-22 19:44:15 UTC (rev 12350)
+++ trunk/src/common/include/Group.class.php	2011-02-24 12:42:01 UTC (rev 12351)
@@ -1863,7 +1863,6 @@
 //echo 'rep_group_act_daily'.db_error();
 		unset($this->data_array);
 		return true;
-
 	}
 
 	/*

Modified: trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php
===================================================================
--- trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php	2011-02-22 19:44:15 UTC (rev 12350)
+++ trunk/src/plugins/projects_hierarchy/common/projects_hierarchyPlugin.class.php	2011-02-24 12:42:01 UTC (rev 12351)
@@ -32,10 +32,10 @@
 		$this->_addHook('groupisactivecheckboxpost');
 		$this->_addHook('hierarchy_views'); // include specific views
 		$this->_addHook('display_hierarchy'); // to see the tree of projects
-		$this->_addHook('delete_link'); // to delete link
+		$this->_addHook('group_delete'); // clean tables on delete
 	}
 
-	function CallHook ($hookname, &$params) {
+	function CallHook($hookname, &$params) {
 		global $G_SESSION, $HTML;
 		$returned = false;
 		switch($hookname) {
@@ -66,16 +66,26 @@
 				}
 				break;
 			}
-			case "delete_link": {
-				$res_son = db_query_params('DELETE FROM plugin_projects_hierarchy WHERE project_id = $1 OR sub_project_id = $1 ',
-							array($params));
-				$returned = true;
+			case "group_delete": {
+				if ($params['group']->usesPlugins($this->name)) {
+					if ($this->delete($params['group_id'])) {
+						$returned = true;
+					}
+				} else {
+					$returned = true;
+				}
 				break;
 			}
 		}
 		return $returned;
 	}
 
+	function delete($group_id) {
+		$res_son = db_query_params('DELETE FROM plugin_projects_hierarchy WHERE project_id = $1 OR sub_project_id = $1 ',
+						array($group_id));
+		return true;
+	}
+
 	function displayHierarchy() {
 		$tree = $this->buildTree();
 		$displayTree = $this->affTree($tree, 0);
@@ -147,15 +157,39 @@
 	}
 
 	/**
-	 * getChildren - find the children group_id of this project.
+	 * getFamily - find the children or parent group_id of this project.
 	 *
-	 * @param	bool	search children of the children
-	 * @return	array	the children id group by parent id.
+	 * @param	integer	group_id to serach for
+	 * @param	string	parent or child ?
+	 * @param	boolean	recurvice or not ?
 	 * @access	public
 	 */
-	function getChildren($deep = false) {
-		$children = array();
-		return $children;
+	function getFamily($group_id, $order, $deep = false) {
+		$localFamily = array();
+		switch ($order) {
+			case "parent": {
+				$res = db_query_params('SELECT project_id as id FROM plugin_projects_hierarchy WHERE sub_project_id = $1',
+							array($group_id));
+			}
+			case "child": {
+				$res = db_query_params('SELECT sub_project_id as id FROM plugin_projects_hierarchy WHERE project_id = $1',
+							array($group_id));
+			}
+			default: {
+				return $localFamily;
+			}
+		}
+		if ($res || db_numrows($res) > 1) {
+			while ($arr = db_fetch_array($res)) {
+				$localFamily[] = $arr['id'];
+			}
+		}
+		if ($deep) {
+			for ( $i = 0; $i < count($localFamily); $i++) {
+				$localFamily[$i] = $this->getChildren($localFamily[$i], $order, $deep);
+			}
+		}
+		return $localFamily;
 	}
 }
 // Local Variables:

Modified: trunk/src/www/admin/groupdelete.php
===================================================================
--- trunk/src/www/admin/groupdelete.php	2011-02-22 19:44:15 UTC (rev 12350)
+++ trunk/src/www/admin/groupdelete.php	2011-02-24 12:42:01 UTC (rev 12351)
@@ -3,7 +3,7 @@
  * Site Admin group properties editing page
  *
  * Copyright 1999-2001 (c) VA Linux Systems
- * Copyright 2010 (c) Franck Villaume - Capgemini
+ * Copyright 2010-2011, Franck Villaume - Capgemini
  * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
  *
  * This file is part of FusionForge.
@@ -45,7 +45,6 @@
 	if (!$group->delete($sure, $reallysure, $reallyreallysure)) {
 		exit_error($group->getErrorMessage(), 'admin');
 	} else {
-		plugin_hook('delete_link',$group_id);
 		$feedback = _('Project successfully deleted');
 		session_redirect('/admin/?feedback='.urlencode($feedback));
 	}




More information about the Fusionforge-commits mailing list