'.$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 = [
'monday' => __('Monday'),
'tuesday' => __('Tuesday'),
'wednesday' => __('Wednesday'),
'thursday' => __('Thursday'),
'friday' => __('Friday'),
'saturday' => __('Saturday'),
'sunday' => __('Sunday'),
];
echo ''.__('Days').': '.__('Every').' ';
$actives = [];
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(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
$update_template = (bool) get_parameter('update_template');
$delete_template = (bool) get_parameter('delete_template');
$pure = get_parameter('pure', 0);
$sec = (is_metaconsole() === true) ? 'advanced' : '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_standard_header(
__('Alerts'),
'images/gm_alerts.png',
false,
'',
true,
[],
[
[
'link' => '',
'label' => __('Alerts'),
],
[
'link' => '',
'label' => __('Alert templates'),
],
]
);
}
}
if ($update_template) {
$id = (int) get_parameter('id');
$recovery_notify = (bool) get_parameter('recovery_notify');
$fields_recovery = [];
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$values['field'.$i] = (string) get_parameter('field'.$i);
$values['field'.$i.'_recovery'] = ($recovery_notify) ? (string) get_parameter('field'.$i.'_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(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Alert Management'
);
include '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,
'alerts_config',
true
);
}
}
} 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,
'alerts_config',
true
);
}
} else {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Alert Management'
);
include '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,
'alerts_config',
true
);
}
}
$result = alerts_delete_alert_template($id);
if ($result) {
db_pandora_audit(
AUDIT_LOG_ALERT_MANAGEMENT,
'Delete alert template #'.$id
);
} else {
db_pandora_audit(
AUDIT_LOG_ALERT_MANAGEMENT,
'Fail try to delete alert template #'.$id
);
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('Could not be deleted')
);
}
if (is_management_allowed() === false) {
if (is_metaconsole() === false) {
$url = ''.__('metaconsole').'';
} else {
$url = __('any node');
}
ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert templates information is read only. Go to %s to manage it.',
$url
)
);
}
$search_string = (string) get_parameter('search_string');
$search_type = (string) get_parameter('search_type');
$url = ui_get_url_refresh(
[
'offset' => false,
'search_string' => $search_string,
'search_type' => $search_type,
'alert_flag' => true,
],
true,
false
);
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters filter-table-adv';
if (is_metaconsole() === true) {
$table->cellspacing = 0;
$table->cellpadding = 0;
}
$table->data = [];
$table->head = [];
$table->style = [];
$table->style[0] = 'width: 50%;';
$table->style[1] = 'width: 50%;';
$table->data[0][0] = html_print_label_input_block(
__('Type'),
html_print_select(
alerts_get_alert_templates_types(),
'search_type',
$search_type,
'',
__('All'),
'',
true,
false,
false,
'w100p',
false,
'width: 100%;'
)
);
$table->data[0][1] = html_print_label_input_block(
__('Search'),
html_print_input_text(
'search_string',
$search_string,
'',
25,
255,
true,
false,
false,
'',
'w100p'
)
);
$table->data[1][0] = ' ';
$table->data[1][1] = html_print_submit_button(
__('Search'),
'',
false,
[
'class' => 'float-right',
'icon' => 'search',
],
true
);
$filter = '