From 14fa3116f0cd9e0530f1b74debb33b90173310a1 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 16 Sep 2014 15:35:28 +0200 Subject: [PATCH] Fixed the group count for to show delete icon in the list --- pandora_console/godmode/groups/group_list.php | 11 +++++---- pandora_console/include/functions_groups.php | 23 +++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 791c571473..ceef6326e8 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -105,7 +105,7 @@ if (is_ajax ()) { $filter[$_sql_post] = '1'; } - + if ( $id_group == 0 && $privilege != '') { // if group ID doesn't matter and $privilege is specified (like 'AW'), // retruns all agents that current user has $privilege privilege for. @@ -116,7 +116,7 @@ if (is_ajax ()) { $agents = agents_get_group_agents($id_group, $filter, "none", false, $recursion); } - + // Add keys prefix if ($keys_prefix !== "") { foreach($agents as $k => $v) { @@ -294,7 +294,9 @@ $table->width = '98%'; $all_parents = array(); $groups_count = 0; $sons = array(); -$groups_aux = array(); + + + foreach ($groups as $k => $g) { if ($g['parent'] != 0) { $all_parents[$g['parent']] = $g['parent']; @@ -310,7 +312,8 @@ foreach ($all_parents as $parent) { } } -$groups_count = count($groups_aux); + +$groups_count = count($groups); if (check_acl($config['id_user'], 0, "PM")) { echo '
'; diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index be30f89cea..ca3e9b4e4f 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -519,7 +519,7 @@ function groups_get_groups_tree_recursive($groups, $trash = 0, $trash2 = 0) { } $return = groups_flatten_tree_groups($tree, 0); - + return $return; } @@ -749,7 +749,7 @@ function groups_get_group_row_data($id_group, $group_all, $group, &$printed_grou $row[__('Agents')] = ""; $row[__('Agents')] .= $row['counts'][__('Agents')]; $row[__('Agents')] .= ""; - + // Agents unknown $row['links'][__('Agents unknown')] = "index.php?" . @@ -1105,7 +1105,7 @@ function groups_create_group($group_name, $rest_values){ // Get agents NOT INIT function groups_agent_not_init ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { @@ -1160,7 +1160,7 @@ function groups_agent_ok ($group_array) { $group_clause = "(" . $group_clause . ")"; $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND normal_count=total_count AND id_grupo IN $group_clause"); - + return $count > 0 ? $count : 0; } @@ -1278,7 +1278,7 @@ function groups_monitor_critical ($group_array) { // Get monitor WARNING, except disabled and non-init function groups_monitor_warning ($group_array) { - + // If there are not groups to query, we jump to nextone if (empty ($group_array)) { @@ -1488,6 +1488,11 @@ function groups_get_group_to_list($group, $groups_count, &$symbolBranchs) { 'id_group=' . $group['id_grupo'] . '&' . 'delete_group=1" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "border" => '0')); } + else { + $data[5] .= '  ' . + ui_print_help_tip( + __('You can not delete the last group in Pandora. A common installation must has almost one group.'), true); + } } return $data; @@ -1509,7 +1514,7 @@ function groups_print_group_sons($group, $sons, &$branch_classes, $groups_count, if (isset($sons[$group['id_grupo']])) { foreach($sons[$group['id_grupo']] as $key => $g) { $symbolBranchs .= ' symbol_branch_' . $g['parent']; - + $data = groups_get_group_to_list($g, $groups_count, $symbolBranchs); array_push ($table->data, $data); @@ -1524,7 +1529,7 @@ function groups_print_group_sons($group, $sons, &$branch_classes, $groups_count, $table->rowstyle[$iterator] = 'display: none;'; } } - + $iterator++; groups_print_group_sons($g, $sons, $branch_classes, $groups_count, $table, $iterator, $symbolBranchs); @@ -1548,7 +1553,7 @@ function groups_get_tree(&$groups, $parent = false) { $return[$id] = $group; unset($groups[$id]); $children = groups_get_tree($groups, $id); - + if (!empty($children)) { $return[$id]['children'] = $children; } @@ -1557,7 +1562,7 @@ function groups_get_tree(&$groups, $parent = false) { $return[$id] = $group; unset($groups[$id]); $children = groups_get_tree($groups, $id); - + if (!empty($children)) { $return[$id]['children'] = $children; }