2013-01-14 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_component_groups.php godmode/modules/manage_network_components.php: Don't remove parent component groups with childs assigned to components. Merged from branches. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7457 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2483ea4a3b
commit
65f0bf0941
|
@ -1,3 +1,11 @@
|
||||||
|
2013-01-14 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
|
* include/functions_component_groups.php
|
||||||
|
godmode/modules/manage_network_components.php: Don't remove
|
||||||
|
parent component groups with childs assigned to components.
|
||||||
|
|
||||||
|
Merged from branches.
|
||||||
|
|
||||||
2013-01-14 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
2013-01-14 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* godmode/modules/manage_nc_groups.php: Parent row removed.
|
* godmode/modules/manage_nc_groups.php: Parent row removed.
|
||||||
|
|
|
@ -28,6 +28,7 @@ if (! check_acl ($config['id_user'], 0, "PM")) {
|
||||||
require_once ($config['homedir'] . '/include/functions_network_components.php');
|
require_once ($config['homedir'] . '/include/functions_network_components.php');
|
||||||
include_once($config['homedir'] . "/include/functions_categories.php");
|
include_once($config['homedir'] . "/include/functions_categories.php");
|
||||||
enterprise_include_once ('meta/include/functions_components_meta.php');
|
enterprise_include_once ('meta/include/functions_components_meta.php');
|
||||||
|
require_once ($config['homedir'].'/include/functions_component_groups.php');
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if (defined('METACONSOLE')) {
|
if (defined('METACONSOLE')) {
|
||||||
|
@ -416,8 +417,24 @@ foreach ($component_groups as $component_group_key => $component_group_val) {
|
||||||
FROM tnetwork_component
|
FROM tnetwork_component
|
||||||
WHERE id_group = ' . $component_group_key);
|
WHERE id_group = ' . $component_group_key);
|
||||||
|
|
||||||
|
$childs = component_groups_get_childrens($component_group_key);
|
||||||
|
|
||||||
|
$num_components_childs = 0;
|
||||||
|
|
||||||
|
if ($childs !== false) {
|
||||||
|
|
||||||
|
foreach ($childs as $child) {
|
||||||
|
|
||||||
|
$num_components_childs += db_get_num_rows('SELECT id
|
||||||
|
FROM tlocal_component
|
||||||
|
WHERE id_network_component_group = ' . $child['id_sg']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Only show component groups with local components
|
// Only show component groups with local components
|
||||||
if ($num_components == 0)
|
if ($num_components == 0 && $num_components_childs == 0)
|
||||||
unset($component_groups[$component_group_key]);
|
unset($component_groups[$component_group_key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,4 +49,29 @@ function component_groups_get_groups_tree_recursive($groups, $parent = 0, $deep
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a array of id_group of childrens (to branches down)
|
||||||
|
*
|
||||||
|
* @param integer $parent The id_group parent to search the childrens.
|
||||||
|
* @param array $groups The groups, its for optimize the querys to DB.
|
||||||
|
*/
|
||||||
|
function component_groups_get_childrens($parent, $groups = null) {
|
||||||
|
if (empty($groups)) {
|
||||||
|
$groups = db_get_all_rows_in_table('tnetwork_component_group');
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = array();
|
||||||
|
|
||||||
|
foreach ($groups as $key => $group) {
|
||||||
|
if ($group['id_sg'] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($group['parent'] == $parent) {
|
||||||
|
$return = $return + array($group['id_sg'] => $group) + component_groups_get_childrens($group['id_sg'], $groups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue