diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 97c51eb75d..41df1f25f4 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2013-01-29 Miguel de Dios + + * godmode/alerts/alert_compounds.php, + godmode/alerts/configure_alert_compound.php: delete old files for + deprecated alert compounds. + 2013-01-29 Miguel de Dios * general/shortcut_bar.php, godmode/alerts/alert_actions.php, diff --git a/pandora_console/godmode/alerts/alert_compounds.php b/pandora_console/godmode/alerts/alert_compounds.php deleted file mode 100644 index 9eb7fcc141..0000000000 --- a/pandora_console/godmode/alerts/alert_compounds.php +++ /dev/null @@ -1,267 +0,0 @@ - 0 && isset ($groups[$id_group])) - $agents = agents_get_group_agents ($id_group, false, "none"); -else - $agents = agents_get_group_agents (array_keys ($groups), false, "none"); - -$update_compound = (bool) get_parameter ('update_compound'); -$delete_alert = (int) get_parameter ('delete_alert'); -$enable_alert = (int) get_parameter ('enable_alert'); -$disable_alert = (int) get_parameter ('disable_alert'); - -// Header -ui_print_page_header (__('Alerts').' » '.__('Correlated alerts'), "images/god2.png", false, "alert_compound", true); - -if ($update_compound) { - $id = (int) get_parameter ('id'); - - $recovery_notify = (bool) get_parameter ('recovery_notify'); - $field2_recovery = (string) get_parameter ('field2_recovery'); - $field3_recovery = (string) get_parameter ('field3_recovery'); - - $result = alerts_update_alert_compound ($id, - array ('recovery_notify' => $recovery_notify, - 'field2_recovery' => $field2_recovery, - 'field3_recovery' => $field3_recovery)); - - ui_print_result_message ($result, - __('Successfully updated'), - __('Could not be updated')); -} - -if ($delete_alert) { - $id = (int) get_parameter ('id'); - $result = alerts_delete_alert_compound ($id); - ui_print_result_message ($result, - __('Successfully deleted'), - __('Could not be deleted')); - if (is_ajax ()) - return; -} - -if ($enable_alert) { - $id = (int) get_parameter ('id'); - $result = alerts_set_alerts_compound_disable ($id, false); - ui_print_result_message ($result, - __('Successfully enabled'), - __('Could not be enabled')); - if (is_ajax ()) - return; -} - -if ($disable_alert) { - $id = (int) get_parameter ('id'); - $result = alerts_set_alerts_compound_disable ($id, true); - ui_print_result_message ($result, - __('Successfully disabled'), - __('Could not be disabled')); - if (is_ajax ()) - return; -} - -$table->id = 'filter_compound_table'; -$table->width = '98%'; -$table->data = array (); -$table->style = array (); -$table->style[0] = 'font-weight: bold; vertical-align:top'; -$table->style[2] = 'font-weight: bold'; -$table->size = array (); -$table->colspan = array (); -$table->size[0] = '15%'; -$table->size[1] = '35%'; -$table->size[2] = '15%'; -$table->size[3] = '35%'; - -$table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups(0, "LM", true, 'id_group', $id_group, false, '', - '', true); -$table->data[0][2] = __('Agent'); -$table->data[0][2] .= ' '; -$table->data[0][3] = html_print_select ($agents, 'id_agent', $id_agent, false, - __('All'), 0, true); - -$table->data[1][0] = __('Free search'); -$table->data[1][1] = html_print_input_text ('search', $search, '', 20, 40, true); -$table->colspan[1][1] = 3; - -echo '
'; -html_print_table ($table); -echo '
'; -html_print_input_hidden ('do_search', 1); -html_print_submit_button (__('Search'), 'search_btn', false, 'class="sub search"'); -echo '
'; -echo '
'; -unset ($table); - -$where = ''; -if ($search != '') { - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - $where = sprintf (' AND (description LIKE "%%%s%%" OR name LIKE "%%%s%%")', - $search, $search); - break; - case "oracle": - $where = sprintf (' AND (description LIKE \'%%%s%%\' OR name LIKE \'%%%s%%\')', - $search, $search); - break; - } -} -if ($id_agent) - $agents = array ($id_agent => $id_agent); - -$total = 0; -if (count($agents) > 0) { - $sql = sprintf ('SELECT COUNT(*) FROM talert_compound - WHERE id_agent in (%s)%s', - implode (',', array_keys ($agents)), $where); - $total = (int) db_get_sql ($sql); -} -ui_pagination ($total, $url); - -$table->id = 'alert_list'; -$table->class = 'alert_list databox'; -$table->width = '98%'; -$table->data = array (); -$table->head = array (); -$table->style = array (); -$table->style[1] = 'font-weight: bold'; -$table->align = array (); -$table->align[3] = 'center'; -$table->size = array (); -$table->size[0] = '20px'; -$table->size[3] = '20px'; -$table->head[0] = ''; -$table->head[1] = __('Name'); -$table->head[2] = __('Agent'); -$table->head[3] = __('Delete'); - -$id_alerts = false; -if (count($agents)) { - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - $sql = sprintf ('SELECT id FROM talert_compound - WHERE id_agent in (%s)%s LIMIT %d OFFSET %d', - implode (',', array_keys ($agents)), $where, - $config['block_size'], get_parameter ('offset')); - break; - case "oracle": - $set = array(); - $set['offset'] = get_parameter ('offset'); - $set['limit'] = $config['block_size']; - $sql = sprintf ('SELECT id FROM talert_compound - WHERE id_agent in (%s)%s', - implode (',', array_keys ($agents)), $where); - $sql = oracle_recode_query($sql, $set); - break; - } - $id_alerts = db_get_all_rows_sql ($sql); - - if (($config["dbtype"] == 'oracle') && ($id_alerts !== false)) { - for ($i=0; $i < count($id_alerts); $i++) { - unset($id_alerts[$i]['rnum']); - } - } -} - -if ($id_alerts === false) - $id_alerts = array (); - -foreach ($id_alerts as $alert) { - $alert = alerts_get_alert_compound ($alert['id']); - if ($alert === false) - continue; - - $data = array (); - - $data[0] = '
'; - if ($alert['disabled']) { - $data[0] .= html_print_input_image ('enable', 'images/lightbulb_off.png', 1, '', true); - $data[0] .= html_print_input_hidden ('enable_alert', 1, true); - } - else { - $data[0] .= html_print_input_image ('disable', 'images/lightbulb.png', 1, '', true); - $data[0] .= html_print_input_hidden ('disable_alert', 1, true); - } - $data[0] .= html_print_input_hidden ('id', $alert['id'], true); - $data[0] .= '
'; - - $data[1] = ''; - $data[1] .= $alert['name']; - $data[1] .= ''; - $data[2] = agents_get_name ($alert['id_agent']); - $data[3] = ''; - $data[3] .= html_print_image("images/cross.png", true, array("title" => __('Delete'))); - $data[3] .= ''; - - array_push ($table->data, $data); -} - -if (isset($data)){ - html_print_table ($table); -} -else { - echo "
".__('No alerts found')."
"; -} - -echo '
'; -echo '
'; -html_print_submit_button (__('Create'), 'crtbtn', false, 'class="sub next"'); -html_print_input_hidden ('new_compound', 1); -echo '
'; -echo '
'; - -ui_require_jquery_file ('pandora.controls'); -?> - - diff --git a/pandora_console/godmode/alerts/configure_alert_compound.php b/pandora_console/godmode/alerts/configure_alert_compound.php deleted file mode 100644 index f837d2ecc2..0000000000 --- a/pandora_console/godmode/alerts/configure_alert_compound.php +++ /dev/null @@ -1,962 +0,0 @@ -'; - - /* Step 1 */ - if ($step == 1) - echo '
  • '; - elseif ($step > 1) - echo '
  • '; - else - echo '
  • '; - - if ($id) { - echo ''; - echo __('Step').' 1 » '; - echo ''.__('Conditions').''; - echo ''; - } - else { - echo __('Step').' 1 » '; - echo ''.__('Conditions').''; - } - echo '
  • '; - - /* Step 2 */ - if ($step == 2) - echo '
  • '; - elseif ($step > 2) - echo '
  • '; - else - echo '
  • '; - - if ($id) { - echo ''; - echo __('Step').' 2 » '; - echo ''.__('Firing').''; - echo ''; - } - else { - echo __('Step').' 2 » '; - echo ''.__('Firing').''; - } - - /* Step 3 */ - if ($step == 3) - echo '
  • '; - elseif ($step > 3) - echo '
  • '; - else - echo '
  • '; - - if ($id) { - echo ''; - echo __('Step').' 3 » '; - echo ''.__('Recovery').''; - echo ''; - } - else { - echo __('Step').' 3 » '; - echo ''.__('Recovery').''; - } - - echo ''; - echo '
    '; -} - -function update_compound ($step) { - global $config; - - $id = (int) get_parameter ('id'); - - if (empty ($id)) - return false; - - if ($step == 1) { - $id_agent = (int) get_parameter ('id_agent'); - $name = (string) get_parameter ('name'); - $description = (string) get_parameter ('description'); - - $result = alerts_update_alert_compound ($id, - array ('name' => $name, - 'description' => $description, - 'id_agent' => $id_agent)); - /* Temporary disable the alert for update all elements */ - alerts_set_alerts_compound_disable ($id, true); - /* Delete all elements of the alert and create them again */ - alerts_delete_alert_compound_elements ($id); - $alerts = (array) get_parameter ('conditions'); - $operations = (array) get_parameter ('operations'); - - foreach ($alerts as $id_alert) { - alerts_add_alert_compound_element ($id, (int) $id_alert, $operations[$id_alert]); - } - - alerts_set_alerts_compound_disable ($id, false); - } - elseif ($step == 2) { - $monday = (bool) get_parameter ('monday'); - $tuesday = (bool) get_parameter ('tuesday'); - $wednesday = (bool) get_parameter ('wednesday'); - $thursday = (bool) get_parameter ('thursday'); - $friday = (bool) get_parameter ('friday'); - $saturday = (bool) get_parameter ('saturday'); - $sunday = (bool) get_parameter ('sunday'); - $special_day = (bool) get_parameter ('special_day'); - $time_from = (string) get_parameter ('time_from'); - $time_from = date ("H:s:00", strtotime ($time_from)); - $time_to = (string) get_parameter ('time_to'); - $time_to = date ("H:s:00", strtotime ($time_to)); - $threshold = (int) get_parameter ('threshold'); - $max_alerts = (int) get_parameter ('max_alerts'); - $min_alerts = (int) get_parameter ('min_alerts'); - if ($threshold == -1) - $threshold = (int) get_parameter ('other_threshold'); - - switch ($config['dbtype']){ - case "mysql": - case "postgresql": - $values = array ('monday' => $monday, - 'tuesday' => $tuesday, - 'wednesday' => $wednesday, - 'thursday' => $thursday, - 'friday' => $friday, - 'saturday' => $saturday, - 'sunday' => $sunday, - 'special_day' => $special_day, - 'time_from' => $time_from, - 'time_to' => $time_to, - 'time_threshold' => $threshold, - 'max_alerts' => $max_alerts, - 'min_alerts' => $min_alerts - ); - break; - case "oracle": - $values = array ('monday' => $monday, - 'tuesday' => $tuesday, - 'wednesday' => $wednesday, - 'thursday' => $thursday, - 'friday' => $friday, - 'saturday' => $saturday, - 'sunday' => $sunday, - 'special_day' => $special_day, - 'time_from' => "#to_date('" . $time_from . "', 'hh24:mi:ss')", - 'time_to' => "#to_date('" . $time_to . "', 'hh24:mi:ss')", - 'time_threshold' => $threshold, - 'max_alerts' => $max_alerts, - 'min_alerts' => $min_alerts - ); - break; - } - - $result = alerts_update_alert_compound ($id, $values); - - /* Update actions */ - $remove_actions = alerts_get_alert_compound_actions ($id); - $add_actions = (array) get_parameter ('actions'); - - if (!empty ($remove_actions)) { - foreach ($remove_actions as $key => $action) { - alerts_delete_alert_compound_action ($key); - } - } - - foreach ($add_actions as $id_action) { - /* TODO: fires_min and fires_max missing */ - alerts_add_alert_compound_action ($id, (int) $id_action); - } - } - elseif ($step == 3) { - $recovery_notify = (bool) get_parameter ('recovery_notify'); - $field2_recovery = (bool) get_parameter ('field2_recovery'); - $field3_recovery = (bool) get_parameter ('field3_recovery'); - - $result = alerts_update_alert_compound ($id, - array ('recovery_notify' => $recovery_notify, - 'field2_recovery' => $field2_recovery, - 'field3_recovery' => $field3_recovery)); - } - else { - return false; - } - - return $result; -} - -/* We set here the number of steps */ -define ('LAST_STEP', 3); - -$step = (int) get_parameter ('step', 1); - -$create_compound = (bool) get_parameter ('create_compound'); -$update_compound = (bool) get_parameter ('update_compound'); - -$name = ''; -$description = ''; -$time_from = '12:00'; -$time_to = '12:00'; -$monday = true; -$tuesday = true; -$wednesday = true; -$thursday = true; -$friday = true; -$saturday = true; -$sunday = true; -$special_day = false; -$default_action = 0; -$field1 = ''; -$field2 = ''; -$field3 = ''; -$min_alerts = 0; -$max_alerts = 1; -$threshold = SECONDS_5MINUTES; -$recovery_notify = false; -$field2_recovery = ''; -$field3_recovery = ''; - -if ($id && ! $create_compound) { - $compound = alerts_get_alert_compound ($id); - $name = $compound['name']; - $description = $compound['description']; - $time_from = $compound['time_from']; - $time_to = $compound['time_to']; - $monday = (bool) $compound['monday']; - $tuesday = (bool) $compound['tuesday']; - $wednesday = (bool) $compound['wednesday']; - $thursday = (bool) $compound['thursday']; - $friday = (bool) $compound['friday']; - $saturday = (bool) $compound['saturday']; - $sunday = (bool) $compound['sunday']; - $special_day = (bool) $template['special_day']; - $max_alerts = $compound['max_alerts']; - $min_alerts = $compound['min_alerts']; - $threshold = $compound['time_threshold']; - $recovery_notify = $compound['recovery_notify']; - $field2_recovery = $compound['field2_recovery']; - $field3_recovery = $compound['field3_recovery']; - $id_agent = $compound['id_agent']; - $id_group = agents_get_agent_group ($id_agent); - - if (! check_acl ($config['id_user'], $id_group, "AW")) { - db_pandora_audit("ACL Violation", - "Trying to access Alert Management"); - require ("general/noaccess.php"); - return; - } -} - -// Header -ui_print_page_header (__('Alerts').' » '.__('Configure correlated alert'), "images/god2.png", false, "", true); - -if ($create_compound) { - $name = (string) get_parameter ('name'); - $description = (string) get_parameter ('description'); - - $result = alerts_create_alert_compound ($name, $id_agent, - array ('description' => $description)); - - ui_print_result_message ($result, - __('Successfully created'), - __('Could not be created')); - /* Go to previous step in case of error */ - if ($result === false) { - $step = $step - 1; - } - else { - $id = $result; - $alerts = (array) get_parameter ('conditions'); - $operations = (array) get_parameter ('operations'); - - foreach ($alerts as $id_alert) { - alerts_add_alert_compound_element ($id, (int) $id_alert, $operations[$id_alert]); - } - } -} - -if ($update_compound) { - $result = update_compound ($step - 1); - - ui_print_result_message ($result, - __('Successfully updated'), - __('Could not be updated')); - /* Go to previous step in case of error */ - if ($result === false) { - $step = $step - 1; - } -} - -print_alert_compound_steps ($step, $id); - -$groups = users_get_groups (); - -$table->id = 'compound'; -$table->width = '98%'; -$table->style = array (); -$table->style[0] = 'font-weight: bold; vertical-align: top'; -$table->style[2] = 'font-weight: bold'; -$table->size = array (); -$table->size[0] = '20%'; -$table->size[2] = '20%'; -if ($step == 2) { - /* Firing conditions and events */ - $threshold_values = alerts_compound_threshold_values (); - if (in_array ($threshold, array_keys ($threshold_values))) { - $table->style['other_label'] = 'display:none; font-weight: bold'; - $table->style['other_input'] = 'display:none'; - $threshold_selected = $threshold; - } - else { - $table->style['other_label'] = 'font-weight: bold'; - $threshold_selected = -1; - } - - if ($default_action == 0) { - $table->rowstyle = array (); - $table->rowstyle['field1'] = 'display: none'; - $table->rowstyle['field2'] = 'display: none'; - $table->rowstyle['field3'] = 'display: none'; - $table->rowstyle['preview'] = 'display: none'; - } - $table->colspan = array (); - $table->colspan[4][1] = 3; - $table->colspan['actions'][1] = 3; - $table->colspan['field1'][1] = 3; - $table->colspan['field2'][1] = 3; - $table->colspan['field3'][1] = 3; - $table->colspan['preview'][1] = 3; - - $table->data[0][0] = __('Days of week'); - $table->data[0][1] = __('Mon'); - $table->data[0][1] .= html_print_checkbox ('monday', 1, $monday, true); - $table->data[0][1] .= __('Tue'); - $table->data[0][1] .= html_print_checkbox ('tuesday', 1, $tuesday, true); - $table->data[0][1] .= __('Wed'); - $table->data[0][1] .= html_print_checkbox ('wednesday', 1, $wednesday, true); - $table->data[0][1] .= __('Thu'); - $table->data[0][1] .= html_print_checkbox ('thursday', 1, $thursday, true); - $table->data[0][1] .= __('Fri'); - $table->data[0][1] .= html_print_checkbox ('friday', 1, $friday, true); - $table->data[0][1] .= __('Sat'); - $table->data[0][1] .= html_print_checkbox ('saturday', 1, $saturday, true); - $table->data[0][1] .= __('Sun'); - $table->data[0][1] .= html_print_checkbox ('sunday', 1, $sunday, true); - - $table->data[0][2] = __('Use special days list'); - $table->data[0][3] = html_print_checkbox ('special_day', 1, $special_day, true); - - $table->data[1][0] = __('Time from'); - $table->data[1][1] = html_print_input_text ('time_from', $time_from, '', 7, 7, - true); - $table->data[1][2] = __('Time to'); - $table->data[1][3] = html_print_input_text ('time_to', $time_to, '', 7, 7, - true); - - $table->data['threshold'][0] = __('Time threshold'); - $table->data['threshold'][1] = html_print_select ($threshold_values, - 'threshold', $threshold_selected, '', '', '', true, false, false); - $table->data['threshold']['other_label'] = __('Other value'); - $table->data['threshold']['other_input'] = html_print_input_text ('other_threshold', - $threshold, '', 5, 7, true); - $table->data['threshold']['other_input'] .= ' '.__('seconds'); - - $table->data[3][0] = __('Min. number of alerts'); - $table->data[3][1] = html_print_input_text ('min_alerts', $min_alerts, '', - 5, 7, true); - $table->data[3][2] = __('Max. number of alerts'); - $table->data[3][3] = html_print_input_text ('max_alerts', $max_alerts, '', - 5, 7, true); - - $table->data[4][0] = __('Actions'); - switch ($config['dbtype']) { - case "mysql": - case "postgresql": - $table->data[4][1] = html_print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name', - 'action', '', '', __('Select'), 0, true, false, false).' '; - break; - case "oracle": - $table->data[4][1] = html_print_select_from_sql ('SELECT id, dbms_lob.substr(name,4000,1) as name FROM talert_actions ORDER BY dbms_lob.substr(name,4000,1)', - 'action', '', '', __('Select'), 0, true, false, false).' '; - break; - } - - $table->data[4][1] .= html_print_button (__('Add'), 'add_action', false, '', - 'class="sub next"', true); - $table->data[4][1] .= '
    '; - /* TODO: Finish fires_max and fires_min support */ -/* $table->data[4][1] .= ''.__('Advanced options').' » '; - $table->data[4][1] .= ''; -*/ - $table->data['actions'][0] = __('Assigned actions'); - $table->data['actions'][1] = '
      '; - if ($id) { - $actions = alerts_get_alert_compound_actions ($id); - if (empty ($actions)) - $table->rowstyle['actions'] = 'display: none'; - foreach ($actions as $action) { - $table->data['actions'][1] .= '
    • '; - $table->data['actions'][1] .= $action['name']; - $table->data['actions'][1] .= ' ('; - if ($action['fires_min'] == $action['fires_max']) { - if ($action['fires_min'] == 0) - $table->data['actions'][1] .= __('Always'); - else - $table->data['actions'][1] .= __('On').' '.$action['fires_min']; - } - else { - if ($action['fires_min'] == 0) - $table->data['actions'][1] .= __('Until').' '.$action['fires_max']; - else - $table->data['actions'][1] .= __('From').' '.$action['fires_min']. - ' '.__('to').' '.$action['fires_max']; - } - $table->data['actions'][1] .= ')'; - $table->data['actions'][1] .= ''; - $table->data['actions'][1] .= html_print_image('images/cross.png', true, array("title" => __('Delete'))); - $table->data['actions'][1] .= ''; - $table->data['actions'][1] .= html_print_input_hidden ('actions[]', $action['id'], true); - $table->data['actions'][1] .= '
    • '; - } - } - $table->data['actions'][1] .= '
    '; - -} -else if ($step == 3) { - /* Alert recover */ - if (! $recovery_notify) { - $table->rowstyle = array (); - $table->rowstyle['field2'] = 'display:none;'; - $table->rowstyle['field3'] = 'display:none'; - } - $table->data[0][0] = __('Alert recovery'); - $values = array (false => __('Disabled'), true => __('Enabled')); - $table->data[0][1] = html_print_select ($values, - 'recovery_notify', $recovery_notify, '', '', '', true, false, - false); - - $table->data['field2'][0] = __('Field 2'); - $table->data['field2'][1] = html_print_input_text ('field2_recovery', - $field2_recovery, '', 35, 255, true); - - $table->data['field3'][0] = __('Field 3'); - $table->data['field3'][1] = html_print_textarea ('field3_recovery', 10, 30, - $field3_recovery, '', true); -} -else { - /* Step 1 by default */ - $table->size = array (); - $table->size[0] = '20%'; - $table->data = array (); - $table->rowstyle = array (); - $table->rowstyle['value'] = 'display: none'; - $table->rowstyle['max'] = 'display: none'; - $table->rowstyle['min'] = 'display: none'; - $table->rowstyle['conditions'] = 'display: none'; - - $show_matches = false; - if ($id) { - $table->rowstyle['conditions'] = ''; - } - - $table->data[0][0] = __('Name'); - $table->data[0][1] = html_print_input_text ('name', $name, '', 35, 255, true); - - $table->data[1][0] = __('Assigned to'); - $table->data[1][1] = html_print_select (agents_get_group_agents (array_keys ($groups)), - 'id_agent', $id_agent, '', __('Select'), 0, true); - $table->data[2][0] = __('Description'); - $table->data[2][1] = html_print_textarea ('description', 10, 30, - $description, '', true); - - $table->data[3][0] = __('Condition'); - $table->data[3][0] .= ''; - $table->colspan[3][0] = 2; - - $table_alerts->id = 'conditions_list'; - $table_alerts->width = '100%'; - $table_alerts->data = array (); - $table_alerts->head = array (); - $table_alerts->head[0] = ''; - $table_alerts->head[1] = __('Agent'); - $table_alerts->head[2] = __('Module'); - $table_alerts->head[3] = __('Alert'); - $table_alerts->head[4] = __('Operator'); - $table_alerts->size = array (); - $table_alerts->size[0] = '20px'; - $table_alerts->size[1] = '20%'; - $table_alerts->size[2] = '40%'; - $table_alerts->size[3] = '40%'; - $table_alerts->size[4] = '10%'; - - if ($id) { - $conditions = alerts_get_alert_compound_elements ($id); - if ($conditions === false) - $conditions = array (); - foreach ($conditions as $condition) { - $data = array (); - - $alert = alerts_get_alert_agent_module ($condition['id_alert_template_module']); - $data[0] = ''; - $data[0] .= html_print_image("images/delete.png", true); - $data[0] .= ''; - $idAgent = agents_get_agent_id_by_module_id($alert['id_agent_module']); - $nameAgent = agents_get_name($idAgent); - $data[1] = '' . $nameAgent . ''; - $data[2] = modules_get_agentmodule_name ($alert['id_agent_module']); - $data[3] = alerts_get_alert_template_name ($alert['id_alert_template']); - if ($condition['operation'] == 'NOP') { - $data[4] = html_print_input_hidden ('operations['.$alert['id'].']', 'NOP', true); - } - else { - $data[4] = html_print_select (alerts_compound_operations (), - 'operations['.$alert['id'].']', $condition['operation'], '', '', '', true); - } - $data[4] .= html_print_input_hidden ("conditions[]", $alert['id'], true); - - array_push ($table_alerts->data, $data); - } - } - - $table->data['conditions'][1] = html_print_table ($table_alerts, true); - $table->colspan['conditions'][1] = 2; -} - -/* If it's the last step it will redirect to compound lists */ -if ($step >= LAST_STEP) { - echo '
    '; -} -else { - echo ''; -} -html_print_table ($table); - -echo ''; -echo '
    '; -if ($id) { - html_print_input_hidden ('id', $id); - html_print_input_hidden ('update_compound', 1); -} -else { - html_print_input_hidden ('create_compound', 1); -} - -if ($step >= LAST_STEP) { - html_print_submit_button (__('Finish'), 'finish', false, 'class="sub upd"'); -} -else { - html_print_input_hidden ('step', $step + 1); - html_print_submit_button (__('Next'), 'next', false, 'class="sub next"'); -} -echo '
    '; -echo '
    '; - -/* Show alert search when we're on the first step */ -if ($step == 1) { - echo '

    '. __('Add condition') . '

    '; - - $id_group = (int) get_parameter ('id_group'); - - $table->id = 'alert_search'; - $table->data = array (); - $table->head = array (); - $table->size = array (); - $table->size[0] = '10%'; - $table->size[1] = '40%'; - $table->size[2] = '10%'; - $table->size[3] = '40%'; - - $table->data[0][0] = __('Group'); - $table->data[0][1] = html_print_select_groups(false, "AR", true, 'search_id_group', $id_group, - false, '', '', true); - $table->data[0][2] = __('Agent'); - $table->data[0][3] = html_print_select (agents_get_group_agents ($id_group, false, "none"), - 'search_id_agent', $id_agent, false, __('Select'), 0, true); - $table->data[0][3] .= ''; - - html_print_table ($table); - echo ''; - - /* Rest of fields are reused */ - $table_alerts->id = 'alert_list'; - $table_alerts->width = '98%'; - $table_alerts->data = array (); - unset ($table_alerts->head[4]); - - if (! $id_agent) { - $table_alerts->class = 'invisible'; - } - else { - $alerts = agents_get_alerts_simple ($id_agent); - - if (empty ($alerts)) { - $table_alerts->data[0][0] = "
    ".__('No alerts found')."
    "; - $table_alerts->colspan[0][0] = 3; - $id_agent = 0; - } - - foreach ($alerts as $alert) { - $data = array (); - - $data[0] = ''; - $data[0] .= html_print_image('images/add.png', true); - $data[0] .= ''; - $data[1] = agents_get_name($id_agent); - $data[2] = modules_get_agentmodule_name ($alert['id_agent_module']); - $data[3] = alerts_get_alert_template_name ($alert['id_alert_template']); - - array_push ($table_alerts->data, $data); - } - } - - html_print_table ($table_alerts); - - /* Pager for alert list using Javascript */ - echo '
    '; - echo '
    '; - echo html_print_image("images/go_first.png", true, array("class" => "first")); - echo html_print_image("images/go_previous.png", true, array("class" => "prev")); - echo ''; - echo html_print_image("images/go_next.png", true, array("class" => "next")); - echo html_print_image("images/go_last.png", true, array("class" => "last")); - echo ''; - echo '
    '; - echo '
    '; - - echo ''; -} - -ui_require_jquery_file ("ui-timepicker-addon"); -ui_require_jquery_file ('form'); -ui_require_jquery_file ('tablesorter'); -ui_require_jquery_file ('tablesorter.pager'); -?> - - - - -