From a9a239b5b37890111933a72d5b49ad03842632fb Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 24 Jan 2014 12:45:09 +0000 Subject: [PATCH] 2014-01-24 Sergio Martin * include/functions_alerts.php: Fix forgotten cases on actions escalation git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9368 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++ pandora_console/include/functions_alerts.php | 44 +++++++++++--------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d1c42ab1ec..d4d7380f5f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2014-01-24 Sergio Martin + + * include/functions_alerts.php: Fix forgotten cases on + actions escalation + 2014-01-24 Sergio Martin * godmode/alerts/alert_list.list.php diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 5fc5675cd4..8f58075f8c 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1938,32 +1938,37 @@ function alerts_get_default_action_escalation($default_action, $escalation) { $busy_times[$k] = 1; } } + + // Fill gaps from last busy to greater than + if ($busy_greater_than != -1) { + for($i=(count($busy_times)+1);$i<=$busy_greater_than;$i++) { + $busy_times[$i] = 0; + } + $busy_times[$i] = 2; + } // Set as default execution the not busy times $default_escalation = array(); foreach($busy_times as $k => $v) { + switch($v) { + case 0: + $default_escalation[$k] = 1; + break; + default: + $default_escalation[$k] = 0; + break; + } + // Last element if ($k == count($busy_times)) { switch($v) { - case 0: - $default_escalation[$k] = 1; - $default_escalation[$k+1] = 2; - break; - case 1: - $default_escalation[$k] = 0; - $default_escalation[$k] = 2; - break; case 2: + if ($default_escalation[$k] == 0) { + unset($default_escalation[$k]); + } break; - } - } - else { - switch($v) { - case 0: - $default_escalation[$k] = 1; - break; - case 1: - $default_escalation[$k] = 0; + default: + $default_escalation[$k+1] = 1; break; } } @@ -1993,7 +1998,7 @@ function alerts_get_default_action_escalation($default_action, $escalation) { * */ function alerts_normalize_actions_escalation($escalation) { $max_elements = 0; - + $any_greater_than = false; foreach($escalation as $k => $v) { if (is_array($v) && isset($v['greater_than'])) { $escalation[$k] = array(); @@ -2001,6 +2006,7 @@ function alerts_normalize_actions_escalation($escalation) { $escalation[$k][$i] = 0; } $escalation[$k][$v['greater_than']] = 2; + $any_greater_than = true; } $n = count($escalation[$k]); @@ -2009,7 +2015,7 @@ function alerts_normalize_actions_escalation($escalation) { } } - if ($max_elements == 1) { + if ($max_elements == 1 || !$any_greater_than) { $nelements = $max_elements; } else {