Fixed problems with strict users. Tiquet: #3308
This commit is contained in:
parent
94af41f00c
commit
f766bef9bb
|
@ -14,8 +14,8 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
include_once ("include/functions_groups.php");
|
||||
include_once ("include/functions_tags.php");
|
||||
include_once ($config['homedir'] . "/include/functions_groups.php");
|
||||
include_once ($config['homedir'] . "/include/functions_tags.php");
|
||||
|
||||
function groupview_get_all_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $agent_filter = array(), $module_filter = array()) {
|
||||
global $config;
|
||||
|
@ -490,10 +490,8 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$groups_without_tags = array();
|
||||
foreach ($acltags as $group => $tags) {
|
||||
if ($user_strict) { //Remove groups with tags
|
||||
if ($tags == '') {
|
||||
$groups_without_tags[$group] = $group;
|
||||
}
|
||||
}
|
||||
$user_groups[$group] = groups_get_name($group);
|
||||
if ($tags != '') {
|
||||
$tags_group = explode(',', $tags);
|
||||
|
@ -504,14 +502,16 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
}
|
||||
|
||||
$user_groups_ids = '0,';
|
||||
if (!$user_strict)
|
||||
$acltags[0] = 0;
|
||||
|
||||
if ($user_strict) {
|
||||
$user_groups_ids .= implode(',', array_keys($groups_without_tags));
|
||||
$user_groups_ids = implode(',', array_keys($groups_without_tags));
|
||||
}
|
||||
else {
|
||||
$user_groups_ids .= implode(',', array_keys($acltags));
|
||||
$user_groups_ids = implode(',', array_keys($acltags));
|
||||
}
|
||||
|
||||
if (!empty($user_groups_ids)) {
|
||||
if (is_metaconsole()) {
|
||||
switch ($config["dbtype"]) {
|
||||
|
@ -570,6 +570,8 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$user_strict) {
|
||||
//Add the group "All" at first
|
||||
$group_all = array('id_grupo'=>0, 'nombre'=>'All', 'icon'=>'', 'parent'=>'', 'propagate'=>0, 'disabled'=>0,
|
||||
'custom_id'=>'', 'id_skin'=>0, 'description'=>'', 'contact'=>'', 'other'=>'', 'password'=>'');
|
||||
|
@ -625,11 +627,13 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
|
||||
$list_groups = $final_list;
|
||||
}
|
||||
|
||||
$list = array();
|
||||
foreach ($list_groups as $group) {
|
||||
$list[$group['id_grupo']]['_name_'] = $group['nombre'];
|
||||
$list[$group['id_grupo']]['_id_'] = $group['id_grupo'];
|
||||
$list[$group['id_grupo']]['icon'] = $group['icon'];
|
||||
$list[$group['id_grupo']]['_monitors_critical_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_warning_'] = 0;
|
||||
$list[$group['id_grupo']]['_monitors_unknown_'] = 0;
|
||||
|
@ -664,6 +668,9 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
|
||||
$list[$group['id_grupo']]["_monitor_checks_"] = $list[$group['id_grupo']]["_monitors_not_init_"] + $list[$group['id_grupo']]["_monitors_unknown_"] + $list[$group['id_grupo']]["_monitors_warning_"] + $list[$group['id_grupo']]["_monitors_critical_"] + $list[$group['id_grupo']]["_monitors_ok_"];
|
||||
|
||||
if ($group['icon'])
|
||||
$list[$group['id_grupo']]["_iconImg_"] = html_print_image ("images/".$group['icon'].".png", true, array ("style" => 'vertical-align: middle;'));
|
||||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
|
||||
|
@ -761,7 +768,9 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$list["_server_sanity_"] = format_numeric (100 - $list["_module_sanity_"], 1);
|
||||
}
|
||||
else {
|
||||
if (!$user_strict) {
|
||||
foreach ($list_groups as $group) {
|
||||
|
||||
$group_agents = db_get_row_sql("SELECT SUM(warning_count) AS _monitors_warning_,
|
||||
SUM(critical_count) AS _monitors_critical_,
|
||||
SUM(normal_count) AS _monitors_ok_,
|
||||
|
@ -785,6 +794,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
|
||||
// Calculate not_normal monitors
|
||||
$list[$group['id_grupo']]["_monitor_not_normal_"] = $list["_monitor_checks_"] - $list["_monitors_ok_"];
|
||||
$list[$group['id_grupo']]["_iconImg_"] = html_print_image ("images/".$group['icon'].".png", true, array ("style" => 'vertical-align: middle;'));
|
||||
|
||||
$total_agents = $list[$group['id_grupo']]['_total_agents_'];
|
||||
|
||||
|
@ -812,11 +822,9 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($user_strict) {
|
||||
$i = 0;
|
||||
else {
|
||||
$i = 1;
|
||||
foreach ($user_tags as $group_id => $tag_name) {
|
||||
$id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
|
||||
|
||||
|
@ -835,17 +843,6 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$list[$i]['_monitors_unknown_'] = (int) tags_get_unknown_monitors ($id, $acltags, $agent_filter, $module_filter);
|
||||
$list[$i]['_monitors_alerts_fired_'] = tags_monitors_fired_alerts($id, $acltags);
|
||||
|
||||
if ($returnAllGroup) {
|
||||
$list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_'];
|
||||
$list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_'];
|
||||
$list[0]['_total_agents_'] += $list[$i]['_total_agents_'];
|
||||
$list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_'];
|
||||
$list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_'];
|
||||
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
|
||||
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
|
||||
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
|
||||
$list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_'];
|
||||
}
|
||||
if (! defined ('METACONSOLE')) {
|
||||
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0) && ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0) && ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0) && ($list[$i]['_monitors_unknown_'] == 0) && ($list[$i]['_monitors_not_init_'] == 0) && ($list[$i]['_agents_not_init_'] == 0)) {
|
||||
unset($list[$i]);
|
||||
|
@ -859,6 +856,7 @@ function groupview_get_data ($id_user = false, $user_strict = false, $acltags, $
|
|||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue