*
* Copyright 2006 (c) Fabien Regnier - Sogeti
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2012, Franck Villaume - TrivialDev
+ * 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;
break;
}
case "group_delete": {
- if ($params['group']->usesPlugin($this->name)) {
- if ($this->remove($params['group_id'])) {
- $returned = true;
- }
- } else {
- $returned = true;
- }
+ $this->remove($params['group_id']);
+ $returned = true;
break;
}
case "site_admin_option_hook": {
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: {
WHERE status = $1
AND group_id != $2
AND group_id <> ALL ($3)
- AND group_id IN (select group_id from group_plugin,plugins where group_plugin.plugin_id = plugins.plugin_id and plugins.plugin_name = $4);',
+ AND group_id IN (select group_id from group_plugin,plugins where group_plugin.plugin_id = plugins.plugin_id and plugins.plugin_name = $4)
+ AND group_id NOT IN (select sub_project_id from plugin_projects_hierarchy_relationship);',
array('A',
$group_id,
db_int_array_to_any_clause($family),
$this->name));
return html_build_select_box($son, $name, $selected, false);
}
+
+ /**
+ * isUsed - is this plugin used by other projects than the current family ?
+ *
+ * @return bool yes or no
+ */
+ function isUsed($group_id) {
+ $sons = $this->getFamily($group_id, 'child', true, 'any');
+ $parent = $this->getFamily($group_id, 'parent', true, 'any');
+ $family = array_merge($parent, $sons);
+ $used =false;
+ $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
+ AND g.group_id <> ALL ($2)',
+ array($this->name, db_int_array_to_any_clause($family))
+ );
+ if ($res1) {
+ // we want at least more than ourself
+ if (db_numrows($res1) > 1) {
+ $used = true;
+ }
+ }
+ 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:
// mode: php