[Fusionforge-commits] FusionForge branch master updated. e09a82becebcd91fe39534f4b109c43b70257cb8

Franck VILLAUME nerville at fusionforge.org
Tue Apr 23 21:42:39 CEST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  e09a82becebcd91fe39534f4b109c43b70257cb8 (commit)
      from  f8e59dd9bebdaa1838592793477d65893f9e7c0c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e09a82becebcd91fe39534f4b109c43b70257cb8
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Tue Apr 23 21:34:57 2013 +0200

    merge from Branch_5_2

diff --git a/src/plugins/projects-hierarchy/actions/addChild.php b/src/plugins/projects-hierarchy/actions/addChild.php
index 1c7e692..69659b5 100644
--- a/src/plugins/projects-hierarchy/actions/addChild.php
+++ b/src/plugins/projects-hierarchy/actions/addChild.php
@@ -4,6 +4,7 @@
  * action: addChild
  *
  * Copyright 2011, Franck Villaume - Capgemini
+ * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -27,6 +28,8 @@ global $_SERVER;
 global $id;
 
 $sub_project_id = getIntFromRequest('sub_project_id');
+if ($sub_project_id && $projectsHierarchy->is_child($sub_project_id))
+	$projectsHierarchy->redirect($_SERVER['HTTP_REFERER'], 'error_msg', _('This project already has a parent'));
 
 if ($sub_project_id && $projectsHierarchy->addChild($id, $sub_project_id))
 	$projectsHierarchy->redirect($_SERVER['HTTP_REFERER'], 'feedback', _('Successfully added child'));
diff --git a/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php b/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php
index 87baf0e..c82e21e 100644
--- a/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php
+++ b/src/plugins/projects-hierarchy/common/projects-hierarchyPlugin.class.php
@@ -5,6 +5,7 @@
  * Copyright 2006 (c) Fabien Regnier - Sogeti
  * Copyright 2010-2011, Franck Villaume - Capgemini
  * Copyright 2012-2013, Franck Villaume - TrivialDev
+ * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -546,12 +547,12 @@ class projects_hierarchyPlugin extends Plugin {
 					switch ($relation) {
 						case "parent": {
 							$qpa = db_construct_qpa($qpa, 'project_id = $1 AND sub_project_id = $2',
-										array($project_id, $sub_project_id));
+										array($sub_project_id, $project_id));
 							break;
 						}
 						case "child": {
 							$qpa = db_construct_qpa($qpa, 'project_id = $1 AND sub_project_id = $2',
-										array($sub_project_id, $project_id));
+										array($project_id, $sub_project_id));
 							break;
 						}
 						default: {
@@ -833,6 +834,19 @@ class projects_hierarchyPlugin extends Plugin {
 			}
 		}
 		return $used;
+
+	/**
+	 * is_child - to verif if project already has a parent
+	 *
+	 * @param	integer	group_id
+	 * @return	bool	true on success
+	 * @access	public
+	 */
+	function is_child($group_id) {
+		if (count($this->getFamily($group_id, 'parent', true, 'any'))>0)
+			return true;
+		else
+			return false;
 	}
 }
 // Local Variables:

-----------------------------------------------------------------------

Summary of changes:
 src/plugins/projects-hierarchy/actions/addChild.php  |    3 +++
 .../common/projects-hierarchyPlugin.class.php        |   18 ++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list