2013-01-11 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* 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.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7440 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2013-01-11 14:32:28 +00:00
parent 16b3467e5d
commit 7677661126
4 changed files with 100 additions and 9 deletions

View File

@ -1,3 +1,13 @@
2013-01-11 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* 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 <sergio.martin@artica.es>
* pandoradb_data.sql

View File

@ -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] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>';
$tabulation = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $group['deep']);
$data[0] = $tabulation . '<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&id='.$group['id_sg'].'">'.$group['name'].'</a>';
$data[1] = network_components_get_group_name ($group['parent']);

View File

@ -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,

View File

@ -0,0 +1,52 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* @package Include
* @subpackage Component groups
*/
/**
* Format components groups in tree way.
*
* @param array $groups The list of groups to create the treefield list.
* @param integer $parent The id_group of parent actual scan branch.
* @param integer $deep The level of profundity in the branch.
*
* @return array The treefield list of components groups.
*/
function component_groups_get_groups_tree_recursive($groups, $parent = 0, $deep = 0) {
$return = array();
foreach ($groups as $key => $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;
}
?>