diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ec793ac4dd..51a9b0a3c3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-01-11 Juan Manuel Ramon + + * include/functions_component_groups.php + godmode/modules/manage_network_components.php + godmode/modules/manage_nc_groups.php: Added tree format for + component groups and make more restrictive filters in local/network + components. + + Merged from branches. + 2013-01-11 Sergio Martin * pandoradb_data.sql diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index 1748509fbc..e9e54a0f79 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -27,6 +27,7 @@ if (! check_acl ($config['id_user'], 0, "PM")) { enterprise_include_once ('meta/include/functions_components_meta.php'); require_once ($config['homedir'] . '/include/functions_network_components.php'); +require_once ($config['homedir'] . '/include/functions_component_groups.php'); // Header if (defined('METACONSOLE')) { @@ -97,12 +98,13 @@ if ($update) { } if ($delete) { + $parent_id = db_get_value_filter('parent', 'tnetwork_component_group', array('id_sg' => $id)); + + $result1 = db_process_sql_update('tnetwork_component_group', array('parent' => $parent_id), array('parent' => $id)); + $result = db_process_sql_delete ('tnetwork_component_group', array ('id_sg' => $id)); - - $result1 = db_process_sql_update('tnetwork_component_group', array('parent' => 0), array('parent' => $id)); - - + if (($result !== false) and ($result1 !== false)) $result = true; else $result = false; @@ -170,13 +172,22 @@ $url = ui_get_url_refresh (array ('offset' => false, $filter = array (); -$filter['offset'] = (int) get_parameter ('offset'); -$filter['limit'] = (int) $config['block_size']; +//$filter['offset'] = (int) get_parameter ('offset'); +//$filter['limit'] = (int) $config['block_size']; +$filter['order'] = 'parent'; $groups = db_get_all_rows_filter ('tnetwork_component_group', $filter); if ($groups === false) $groups = array (); +$groups_clean = array(); +foreach ($groups as $group_key => $group_val) { + $groups_clean[$group_val['id_sg']] = $group_val; +} + +// Format component groups in tree form +$groups = component_groups_get_groups_tree_recursive($groups_clean,0,0); + $table->width = '98%'; $table->head = array (); $table->head[0] = __('Name'); @@ -196,12 +207,14 @@ $table->data = array (); $total_groups = db_get_all_rows_filter ('tnetwork_component_group', false, 'COUNT(*) AS total'); $total_groups = $total_groups[0]['total']; -ui_pagination ($total_groups, $url); +//ui_pagination ($total_groups, $url); foreach ($groups as $group) { $data = array (); - $data[0] = ''.$group['name'].''; + $tabulation = str_repeat('    ', $group['deep']); + + $data[0] = $tabulation . ''.$group['name'].''; $data[1] = network_components_get_group_name ($group['parent']); diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index e9d5a2117d..5ace2e74d8 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -405,7 +405,23 @@ $table->style[2] = 'font-weight: bold'; $table->data = array (); $table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select (network_components_get_groups (), + +$component_groups = network_components_get_groups (); + +if ($component_groups === false) + $component_groups = array(); + +foreach ($component_groups as $component_group_key => $component_group_val) { + $num_components = db_get_num_rows('SELECT id_nc + FROM tnetwork_component + WHERE id_group = ' . $component_group_key); + + // Only show component groups with local components + if ($num_components == 0) + unset($component_groups[$component_group_key]); +} + +$table->data[0][1] = html_print_select ($component_groups, 'search_id_group', $search_id_group, '', __('All'), 0, true, false, false); $table->data[0][2] = __('Search'); $table->data[0][3] = html_print_input_text ('search_string', $search_string, '', 25, diff --git a/pandora_console/include/functions_component_groups.php b/pandora_console/include/functions_component_groups.php new file mode 100644 index 0000000000..61f4a802a3 --- /dev/null +++ b/pandora_console/include/functions_component_groups.php @@ -0,0 +1,52 @@ + $group) { + if ($group['parent'] == $parent) { + $group['deep'] = $deep; + + $branch = component_groups_get_groups_tree_recursive($groups, $key, $deep + 1); + if (empty($branch)) { + $group['hash_branch'] = false; + } + else { + $group['hash_branch'] = true; + } + $return = $return + array($key => $group) + $branch; + } + } + + return $return; +} + +?>