From dded9176a52d8449191d046172d2dbbc2dd8ffae Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Wed, 19 Dec 2012 14:04:47 +0000 Subject: [PATCH] 2012-12-19 Juan Manuel Ramon * extensions/module_groups.php: Fixed view, colors in cells were bad printed and alert popup also had sql errors. Merged from branches. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7310 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++++ pandora_console/extensions/module_groups.php | 44 ++++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 691298557a..16f8e2765e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-12-19 Juan Manuel Ramon + + * extensions/module_groups.php: Fixed view, colors in cells were + bad printed and alert popup also had sql errors. + + Merged from branches. + 2012-12-19 Hirofumi Kosaka * include/functions_api.php: Added function diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 1bc643745c..a726929650 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -45,12 +45,38 @@ if (is_ajax ()) { $template = db_get_row('talert_templates', 'id' , $alert['id_alert_template']); echo '' . __('Alert template') . ': '; echo io_safe_output($template['name']) . '
'; - $sql = 'SELECT * + + // This prevent from templates without predefined actions + if (empty($template['id_alert_action'])) + $template_id_alert_action = "''"; + else + $template_id_alert_action = $template['id_alert_action']; + + // True if the alert only has the default template action + $default_action = false; + // Try to get actions for the current alert + $sql = 'SELECT t2.name FROM talert_template_module_actions AS t1 - INNER JOIN talert_actions AS t2 ON t1.id_alert_action = t2.id - WHERE t1.id_alert_template_module = ' . $template['id'] . ' - OR t2.id = ' . $template['id_alert_action'] . ';'; + INNER JOIN talert_actions AS t2 + INNER JOIN talert_template_modules AS t3 + ON t3.id = t1.id_alert_template_module + AND t1.id_alert_action = t2.id + WHERE (t3.id_alert_template = ' . $template['id'] . ' AND + t3.id_agent_module = ' . $module['id_agente_modulo'] . ');'; + $actions = db_get_all_rows_sql($sql); + + // If this alert doesn't have actions try to get default action from template + if ($actions === false) { + $sql = 'SELECT name + FROM talert_actions + WHERE (id = ' . $template_id_alert_action . ');'; + + $default_action = true; + + $actions = db_get_all_rows_sql($sql); + } + if ($actions === false) { $actions = array(); } @@ -58,7 +84,10 @@ if (is_ajax ()) { echo '' . __('Actions') . ': ' . '
'; echo '
    '; foreach ($actions as $action) { - echo '
  • ' . $action['name'] . '
  • '; + echo '
  • '; + if ($default_action) + echo 'Default: '; + echo $action['name'] . '
  • '; } echo '
'; if ($alert != end($alerts)) { @@ -163,16 +192,15 @@ function mainModuleGroups() { //The content of table $tableData = array(); - $fired = false; - //Create rows and cells foreach ($agentGroups as $idAgentGroup => $name) { - + $fired = false; $row = array(); array_push($row, ui_print_truncate_text($name, GENERIC_SIZE_TEXT)); foreach ($modelGroups as $idModelGroup => $modelGroup) { + $fired = false; $query = sprintf($sql,$idAgentGroup, $idModelGroup); $rowsDB = db_get_all_rows_sql ($query);