'.$template['name'].''; echo ''.__('Type').': '; echo alerts_get_alert_templates_type_name ($template['type']); echo '
'; echo ui_print_alert_template_example ($template['id'], true); echo '
'; if ($template['description'] != '') { echo ''.__('Description').':
'; echo $template['description']; echo '
'; } echo ''.__('Priority').': '; echo get_priority_name ($template['priority']); echo '
'; if ($template['monday'] && $template['tuesday'] && $template['wednesday'] && $template['thursday'] && $template['friday'] && $template['saturday'] && $template['sunday']) { /* Everyday */ echo ''.__('Everyday').'
'; } else { $days = array ('monday' => __('Monday'), 'tuesday' => __('Tuesday'), 'wednesday' => __('Wednesday'), 'thursday' => __('Thursday'), 'friday' => __('Friday'), 'saturday' => __('Saturday'), 'sunday' => __('Sunday')); echo ''.__('Days').': '.__('Every').' '; $actives = array (); foreach ($days as $day => $name) { if ($template[$day]) array_push ($actives, $name); } $last = array_pop ($actives); if (count ($actives)) { echo implode (', ', $actives); echo ' '.__('and').' '; } echo $last; echo "
"; } echo "" . __('Time threshold') . ": "; echo human_time_description_raw($template['time_threshold']); echo '
'; if ($template['time_from'] != $template['time_to']) { echo ''.__('From').' '; echo $template['time_from']; echo ' '.__('to').' '; echo $template['time_to']; echo '
'; } return; } return; } if (! check_acl ($config['id_user'], 0, "LM")) { db_pandora_audit("ACL Violation", "Trying to access Alert Management"); require ("general/noaccess.php"); exit; } $update_template = (bool) get_parameter ('update_template'); $delete_template = (bool) get_parameter ('delete_template'); $pure = get_parameter('pure', 0); if (defined('METACONSOLE')) { $sec = 'advanced'; } else { $sec = 'galertas'; } // This prevents to duplicate the header in case delete_templete action is performed if (!$delete_template) { // Header if (defined('METACONSOLE')) { alerts_meta_print_header (); } else { ui_print_page_header (__('Alerts')." » ". __('Alert templates'), "images/gm_alerts.png", false, "alert_template", true); } } if ($update_template) { $id = (int) get_parameter ('id'); $recovery_notify = (bool) get_parameter ('recovery_notify'); $fields_recovery = array(); for($i=2;$i<=10;$i++) { $fields_recovery['field'.$i.'_recovery'] = (string) get_parameter ('field'.$i); } $values = $fields_recovery; $values['recovery_notify'] = $recovery_notify; $result = alerts_update_alert_template ($id, $values); ui_print_result_message ($result, __('Successfully updated'), __('Could not be updated')); } // If user tries to delete a template with group=ALL then must have "PM" access privileges if ($delete_template) { $id = get_parameter ('id'); $al_template = alerts_get_alert_template($id); if ($al_template !== false){ // If user tries to delete a template with group=ALL then must have "PM" access privileges if ($al_template['id_group'] == 0) { if (! check_acl ($config['id_user'], 0, "PM")) { db_pandora_audit("ACL Violation", "Trying to access Alert Management"); require ("general/noaccess.php"); exit; } else { if (defined('METACONSOLE')) { alerts_meta_print_header (); } else { ui_print_page_header( __('Alerts') . " » " . __('Alert templates'), "images/gm_alerts.png", false, "alert_template", true); } } } // If user tries to delete a template of others groups else { $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) $own_groups = array_keys(users_get_groups($config['id_user'], "LM")); else $own_groups = array_keys(users_get_groups($config['id_user'], "LM", false)); $is_in_group = in_array($al_template['id_group'], $own_groups); // Then template group have to be is his own groups if ($is_in_group) { if (defined('METACONSOLE')) { alerts_meta_print_header (); } else { ui_print_page_header (__('Alerts')." » ". __('Alert templates'), "images/gm_alerts.png", false, "alert_template", true); } } else { db_pandora_audit("ACL Violation", "Trying to access Alert Management"); require ("general/noaccess.php"); exit; } } } else { if (defined('METACONSOLE')) { alerts_meta_print_header (); } else { ui_print_page_header (__('Alerts')." » ". __('Alert templates'), "images/gm_alerts.png", false, "alert_template", true); } } $result = alerts_delete_alert_template ($id); if ($result) { db_pandora_audit("Template alert management", "Delete alert template #" . $id); } else { db_pandora_audit("Template alert management", "Fail try to delete alert template #" . $id); } ui_print_result_message ($result, __('Successfully deleted'), __('Could not be deleted')); } $url = ui_get_url_refresh (array ('offset' => false)); $search_string = (string) get_parameter ('search_string'); $search_type = (string) get_parameter ('search_type'); $table->width = '98%'; $table->data = array (); $table->head = array (); $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->style[2] = 'font-weight: bold'; $table->data[0][0] = __('Type'); $table->data[0][1] = html_print_select (alerts_get_alert_templates_types (), 'search_type', $search_type, '', __('All'), '', true, false, false); $table->data[0][2] = __('Search'); $table->data[0][3] = html_print_input_text ('search_string', $search_string, '', 25, 255, true); $table->data[0][4] = '
'; $table->data[0][4] .= html_print_submit_button (__('Search'), 'search', false, 'class="sub search"', true); $table->data[0][4] .= '
'; echo '
'; html_print_table ($table); echo '
'; unset ($table); $filter = array (); if ($search_type != '') $filter['type'] = $search_type; if ($search_string) $filter[] = '(name LIKE "%'.$search_string.'%" OR description LIKE "%'.$search_string.'%" OR value LIKE "%'.$search_string.'%")'; $total_templates = alerts_get_alert_templates ($filter, array ('COUNT(*) AS total')); $total_templates = $total_templates[0]['total']; $filter['offset'] = (int) get_parameter ('offset'); $filter['limit'] = (int) $config['block_size']; if (!is_user_admin($config['id_user'])) $filter['id_group'] = array_keys(users_get_groups(false, "LM")); $templates = alerts_get_alert_templates ($filter, array ('id', 'name', 'description', 'type', 'id_group')); if ($templates === false) $templates = array (); $table->width = '98%'; $table->data = array (); $table->head = array (); $table->head[0] = __('Name'); $table->head[1] = __('Group'); //$table->head[2] = __('Description'); $table->head[3] = __('Type'); $table->head[4] = __('Op.'); $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->size = array (); $table->size[4] = '65px'; $table->align = array (); $table->align[1] = 'center'; $table->align[4] = 'center'; $rowPair = true; $iterator = 0; foreach ($templates as $template) { if ($rowPair) $table->rowclass[$iterator] = 'rowPair'; else $table->rowclass[$iterator] = 'rowOdd'; $rowPair = !$rowPair; $iterator++; $data = array (); $data[0] = ''. $template['name'].''; $data[1] = ui_print_group_icon ($template["id_group"], true); $data[3] = alerts_get_alert_templates_type_name ($template['type']); $data[4] = '
'; $data[4] .= html_print_input_hidden ('duplicate_template', 1, true); $data[4] .= html_print_input_hidden ('source_id', $template['id'], true); $data[4] .= html_print_input_image ('dup', 'images/copy.png', 1, '', true, array ('title' => __('Duplicate'))); $data[4] .= '
'; $data[4] .= '
'; $data[4] .= html_print_input_hidden ('delete_template', 1, true); $data[4] .= html_print_input_hidden ('id', $template['id'], true); $data[4] .= html_print_input_image ('del', 'images/cross.png', 1, '', true, array ('title' => __('Delete'))); $data[4] .= '
'; array_push ($table->data, $data); } ui_pagination ($total_templates, $url); if (isset($data)) { html_print_table ($table); } else { echo "
".__('No alert templates defined')."
"; } echo '
'; echo '
'; html_print_submit_button (__('Create'), 'create', false, 'class="sub next"'); html_print_input_hidden ('create_alert', 1); echo '
'; echo '
'; ?>