2013-04-11 Miguel de Dios <miguel.dedios@artica.es>

* godmode/groups/group_list.php, include/functions_groups.php:
	optimize the access to the groups in systems with a huge groups.
	
	* include/functions_snmp_browser.php, include/functions_users.php:
	clean source code style.
	
	* pandoradb.sql: added key for the parent group.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7963 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-04-11 15:02:22 +00:00
parent 56399280be
commit 0efb6f843b
6 changed files with 46 additions and 21 deletions

View File

@ -1,3 +1,13 @@
2013-04-11 Miguel de Dios <miguel.dedios@artica.es>
* godmode/groups/group_list.php, include/functions_groups.php:
optimize the access to the groups in systems with a huge groups.
* include/functions_snmp_browser.php, include/functions_users.php:
clean source code style.
* pandoradb.sql: added key for the parent group.
2013-04-11 Sergio Martin <sergio.martin@artica.es>
* operation/visual_console/render_view.php

View File

@ -245,7 +245,7 @@ if ($delete_group) {
}
}
db_clean_cache();
$groups = users_get_groups_tree ($config['id_user'], "AR", true);
$groups = users_get_groups_tree ($config['id_user'], "AR", true);
$table->width = '98%';
if (!empty($groups)) {

View File

@ -458,6 +458,21 @@ function groups_get_id_recursive($id_parent, $all = false) {
return $return;
}
function groups_flatten_tree_groups($tree, $deep) {
foreach ($tree as $key => $group) {
$return[$key] = $group;
unset($return[$key]['branch']);
$return[$key]['deep'] = $deep;
if (!empty($group['branch'])) {
$return = $return +
groups_flatten_tree_groups($group['branch'], $deep + 1);
}
}
return $return;
}
/**
* Make with a list of groups a treefied list of groups.
*
@ -467,30 +482,29 @@ function groups_get_id_recursive($id_parent, $all = false) {
*
* @return array The treefield list of groups.
*/
function groups_get_groups_tree_recursive($groups, $parent = 0, $deep = 0) {
function groups_get_groups_tree_recursive($groups, $trash = 0, $trash2 = 0) {
$return = array();
$pointer_to_parent = array();
$tree = array();
foreach ($groups as $key => $group) {
if (($key === 0 || $key === __('All')) && ($parent === 0 || $parent === __('All'))) {
//When the groups is the all group
$group['deep'] = $deep;
$group['hash_branch'] = true;
$deep ++;
$return = $return + array($key => $group);
if (!isset($pointer_to_parent[$group['parent']])) {
$group['branch'] = array();
$group['hash_branch'] = false;
$tree[$key] = $group;
$pointer_to_parent[$key] = &$tree[$key];
}
else if ($group['parent'] == $parent) {
$group['deep'] = $deep;
$branch = 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;
else {
$group['branch'] = array();
$pointer_to_parent[$group['parent']]['branch'][$key] = $group;
$pointer_to_parent[$group['parent']]['hash_branch'] = true;
$pointer_to_parent[$key] = &$pointer_to_parent[$group['parent']]['branch'][$key];
}
}
$return = groups_flatten_tree_groups($tree, 0);
return $return;
}

View File

@ -207,7 +207,7 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.') {
$sub_oid = "";
}
return$oid_tree;
return $oid_tree;
}
/**

View File

@ -117,7 +117,7 @@ function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGro
foreach ($user_groups_tree as $group) {
$groupName = ui_print_truncate_text($group['nombre'], GENERIC_SIZE_TEXT, false, true, false);
$fields[$group[$keys_field]] = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", $group['deep']) . $groupName;
}

View File

@ -528,7 +528,8 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
`description` text,
`contact` text,
`other` text,
PRIMARY KEY (`id_grupo`)
PRIMARY KEY (`id_grupo`),
KEY `parent_index` (`parent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------