Merge branch 'ent-6933-fix-inconsistency-in-alerts-group-profiles-revised' into 'develop'

Fixed and improved alert functions.

See merge request artica/pandorafms!3957
This commit is contained in:
Daniel Rodriguez 2021-04-14 13:15:29 +00:00
commit a93a3b7967
6 changed files with 178 additions and 181 deletions

View File

@ -61,6 +61,11 @@ if (defined('METACONSOLE')) {
$sec = 'galertas';
}
$can_edit_all = false;
if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
$can_edit_all = true;
}
// Header.
if (defined('METACONSOLE')) {
alerts_meta_print_header();
@ -79,30 +84,13 @@ if ($copy_action) {
$al_action = alerts_get_alert_action($id);
if (!check_acl_restricted_all($config['id_user'], $al_action['id_group'], 'LM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
if ($al_action !== false) {
// If user tries to copy an action with group=ALL.
if ($al_action['id_group'] == 0) {
// Then must have "PM" access privileges.
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
// If user who doesn't have permission to modify group all tries to copy an action with group=ALL.
if ($can_edit_all == false && $al_action['id_group'] == 0) {
$al_action['id_group'] = users_get_first_group(false, 'LM', false);
} else {
$own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
if ($can_edit_all == true || check_acl($config['id_user'], 0, 'PM')) {
$own_groups = array_keys(
users_get_groups($config['id_user'], 'LM')
);
@ -125,7 +113,7 @@ if ($copy_action) {
}
}
$result = alerts_clone_alert_action($id);
$result = alerts_clone_alert_action($id, $al_action['id_group']);
if ($result) {
db_pandora_audit(
@ -397,10 +385,9 @@ foreach ($actions as $action) {
$data = [];
if (check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')) {
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'&pure='.$pure.'">'.$action['name'].'</a>';
} else {
$data[0] = $action['name'];
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'&pure='.$pure.'">'.$action['name'].'</a>';
if ($action['id_group'] == 0 && $can_edit_all == false) {
$data[0] .= ui_print_help_tip(__('You cannot edit this action, You don\'t have the permission to edit All group.'), true);
}
$data[1] = $action['command_name'];
@ -420,7 +407,7 @@ foreach ($actions as $action) {
$data[4] = '';
if (is_central_policies_on_node() === false
&& check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')
&& check_acl($config['id_user'], $action['id_group'], 'LM')
) {
$table->cellclass[] = [
3 => 'action_buttons',
@ -430,10 +417,35 @@ foreach ($actions as $action) {
$id_action = $action['id'];
$text_confirm = __('Are you sure?');
$data[3] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions"
onClick="copy_action('.$id_action.',\''.$text_confirm.'\');">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>';
$data[4] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions"
onClick="delete_action('.$id_action.',\''.$text_confirm.'\');">'.html_print_image('images/cross.png', true, ['class' => 'invert_filter']).'</a>';
$data[3] = '<form method="post" style="display: inline; float: right" onsubmit="if (!confirm(\''.$text_confirm.'\')) return false;">';
$data[3] .= html_print_input_hidden('copy_action', 1, true);
$data[3] .= html_print_input_hidden('id', $id_action, true);
$data[3] .= html_print_input_image(
'dup',
'images/copy.png',
1,
'',
true,
['title' => __('Duplicate')]
);
$data[3] .= '</form> ';
if ($action['id_group'] != 0 || $can_edit_all == true) {
$data[4] = '<form method="post" style="display: inline; float: right" onsubmit="if (!confirm(\''.$text_confirm.'\')) return false;">';
$data[4] .= html_print_input_hidden('delete_action', 1, true);
$data[4] .= html_print_input_hidden('id', $id_action, true);
$data[4] .= html_print_input_image(
'del',
'images/cross.png',
1,
'',
true,
['title' => __('Delete')]
);
$data[4] .= '</form> ';
} else {
$data[4] = '';
}
}
array_push($table->data, $data);
@ -458,44 +470,3 @@ if (is_central_policies_on_node() === false) {
enterprise_hook('close_meta_frame');
?>
<script type="text/javascript">
function copy_action(id_action, text_confirm) {
if (!confirm(text_confirm)) {
return false;
} else {
jQuery.post ("ajax.php",
{
"page" : "godmode/alerts/alert_actions",
"copy_action" : 1,
"id" : id_action
},
function (data, status) {
// No data.
},
"json"
);
}
}
function delete_action(id_action, text_confirm) {
if (!confirm(text_confirm)) {
return false;
} else {
jQuery.post ("ajax.php",
{
"page" : "godmode/alerts/alert_actions",
"delete_action" : 1,
"id" : id_action
},
function (data, status) {
// No data.
},
"json"
);
}
}
</script>

View File

@ -28,12 +28,6 @@ if (! check_acl($config['id_user'], 0, 'LM')) {
exit;
}
if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin($config['id_user'])) {
echo "<div id='message_permissions' title='".__('Permissions warning')."' style='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Command management is limited to administrator users or user profiles with permissions over Pandora FMS management').'</p>';
echo '</div>';
}
if (is_metaconsole()) {
$sec = 'advanced';
} else {
@ -467,6 +461,17 @@ if (is_ajax()) {
return;
}
// This check should be after ajax. Because, ajax will be called from configure_alert_action.
if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin($config['id_user
'])) {
echo "<div id='message_permissions' title='".__('Permissions warning')."' s
tyle='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Command managem
ent is limited to administrator users or user profiles with permissions over Pan
dora FMS management').'</p>';
echo '</div>';
}
enterprise_hook('open_meta_frame');
if ($update_command) {

View File

@ -401,17 +401,16 @@ foreach ($templates as $template) {
$data = [];
if (check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')) {
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&id='.$template['id'].'&pure='.$pure.'">'.$template['name'].'</a>';
} else {
$data[0] = $template['name'];
$data[0] = '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&id='.$template['id'].'&pure='.$pure.'">'.$template['name'].'</a>';
if (!check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')) {
$data[0] .= ui_print_help_tip(__('You cannot edit this alert template, You don\'t have the permission to edit All group.'), true);
}
$data[1] = ui_print_group_icon($template['id_group'], true);
$data[3] = alerts_get_alert_templates_type_name($template['type']);
if (is_central_policies_on_node() === false
&& check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')
&& check_acl($config['id_user'], $template['id_group'], 'LM')
) {
$table->cellclass[][4] = 'action_buttons';
$data[4] = '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'" class="float-left inline_line">';
@ -427,18 +426,20 @@ foreach ($templates as $template) {
);
$data[4] .= '</form> ';
$data[4] .= '<form method="post" class="float-right inline_line" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$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,
['title' => __('Delete')]
);
$data[4] .= '</form> ';
if (check_acl_restricted_all($config['id_user'], $template['id_group'], 'LM')) {
$data[4] .= '<form method="post" class="float-right inline_line" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$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,
['title' => __('Delete')]
);
$data[4] .= '</form> ';
}
} else {
$data[4] = '';
}

View File

@ -58,7 +58,7 @@ if (defined('METACONSOLE')) {
if ($al_action !== false) {
$own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
if ($own_info['is_admin'] || check_acl_restricted_all($config['id_user'], 0, 'LM')) {
$own_groups = array_keys(users_get_groups($config['id_user'], 'LM'));
} else {
$own_groups = array_keys(users_get_groups($config['id_user'], 'LM', false));
@ -91,8 +91,14 @@ if ($al_action !== false) {
true
);
}
$is_in_group = true;
}
if (!$is_in_group && $al_action['id_group'] != 0) {
db_pandora_audit('ACL Violation', 'Trying to access unauthorized alert action configuration');
include 'general/noaccess.php';
exit;
}
$is_central_policies_on_node = is_central_policies_on_node();
@ -102,6 +108,11 @@ if ($is_central_policies_on_node === true) {
);
}
$disabled = !$is_in_group;
$disabled_attr = '';
if ($disabled) {
$disabled_attr = 'disabled="disabled"';
}
$name = '';
$id_command = '';
@ -116,15 +127,6 @@ if ($id) {
$group = $action['id_group'];
$action_threshold = $action['action_threshold'];
$create_wu_integria = $action['create_wu_integria'];
if (!check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
}
// Hidden div with help hint to fill with javascript.
@ -175,7 +177,7 @@ $table->data[0][1] = html_print_input_text(
'',
'',
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
if (io_safe_output($name) == 'Monitoring Event') {
@ -194,7 +196,7 @@ $own_info = get_user_info($config['id_user']);
$return_all_group = false;
if (users_can_manage_group_all('LW') === true) {
if (users_can_manage_group_all('LW') === true || $disabled) {
$return_all_group = true;
}
@ -211,7 +213,7 @@ $table->data[1][1] = '<div class="w250px inline">'.html_print_select_groups(
false,
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
).'</div>';
$table->colspan[1][1] = 2;
@ -245,11 +247,11 @@ $table->data[2][1] = html_print_select_from_sql(
true,
false,
false,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[2][1] .= ' ';
if ($is_central_policies_on_node === false
&& check_acl($config['id_user'], 0, 'PM')
&& check_acl($config['id_user'], 0, 'PM') && !$disabled
) {
$table->data[2][1] .= __('Create Command');
$table->data[2][1] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
@ -272,7 +274,7 @@ $table->data[3][1] = html_print_extended_select_for_time(
false,
true,
'',
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
false,
'',
false,
@ -308,7 +310,7 @@ $table->data[6][0] = __('Create workunit on recovery').ui_print_help_tip(
__('If closed status is set on recovery, a workunit will be added to the ticket in Integria IMS rather that closing the ticket.'),
true
);
$table->data[6][1] = html_print_checkbox_switch_extended('create_wu_integria', 1, $create_wu_integria, false, '', '', true);
$table->data[6][1] = html_print_checkbox_switch_extended('create_wu_integria', 1, $create_wu_integria, false, '', $disabled_attr, true);
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$table->data['field'.$i][0] = html_print_image(
@ -328,12 +330,16 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$table->data['field'.$i][1] .= html_print_input_hidden(
'field'.$i.'_value',
(!empty($action['field'.$i]) || $action['field'.$i] == 0) ? $action['field'.$i] : '',
true
true,
'',
$disabled_attr
);
$table->data['field'.$i][2] .= html_print_input_hidden(
'field'.$i.'_recovery_value',
(!empty($action['field'.$i.'_recovery']) || $action['field'.$i] == 0) ? $action['field'.$i.'_recovery'] : '',
true
true,
'',
$disabled_attr
);
}
@ -346,18 +352,7 @@ if ($is_central_policies_on_node === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden('id', $id);
if ($al_action['id_group'] == 0) {
// Then must have "PM" access privileges.
if (check_acl($config['id_user'], 0, 'PM')) {
html_print_input_hidden('update_action', 1);
html_print_submit_button(
__('Update'),
'create',
false,
'class="sub upd"'
);
}
} else {
if (!$disabled) {
html_print_input_hidden('update_action', 1);
html_print_submit_button(
__('Update'),
@ -365,6 +360,12 @@ if ($is_central_policies_on_node === false) {
false,
'class="sub upd"'
);
} else {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions">';
html_print_submit_button(__('Back'), 'back', false, 'class="sub upd"');
echo '</form>';
echo '</div>';
}
} else {
html_print_input_hidden('create_action', 1);
@ -608,6 +609,7 @@ $(document).ready (function () {
for (i = 1; i <= max_fields; i++) {
var old_value = '';
var old_recovery_value = '';
var disabled = '';
var field_row = data["fields_rows"][i];
var $table_macros_field = $('#table_macros-field' + i);
@ -623,6 +625,7 @@ $(document).ready (function () {
== ("hidden-field" + i + "_value")) {
old_value = $("[name=field" + i + "_value]").val();
disabled = $("[name=field" + i + "_value]").attr('disabled');
}
if (($("[name=field" + i + "_recovery_value]").attr('id'))
@ -689,6 +692,10 @@ $(document).ready (function () {
$('#help_alert_macros_hint').html());
}
if (disabled) {
$("[name=field" + i + "_value]").attr('disabled','disabled');
$("[name=field" + i + "_recovery_value]").attr('disabled','disabled');
}
$table_macros_field.show();
}

View File

@ -38,7 +38,6 @@ $step = (int) get_parameter('step', 1);
// We set here the number of steps.
define('LAST_STEP', 3);
// If user tries to duplicate/edit a template with group=ALL then must have "PM" access privileges
if ($duplicate_template) {
$source_id = (int) get_parameter('source_id');
$a_template = alerts_get_alert_template($source_id);
@ -52,19 +51,14 @@ if (defined('METACONSOLE')) {
$sec = 'galertas';
}
$can_edit_all = false;
if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
$can_edit_all = true;
}
if ($a_template !== false) {
// If user tries to duplicate/edit a template with group=ALL
if ($a_template['id_group'] == 0) {
if (users_can_manage_group_all('LM') === false) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
// Header
if (defined('METACONSOLE')) {
alerts_meta_print_header();
} else {
@ -146,7 +140,12 @@ if ($a_template !== false) {
if ($duplicate_template) {
$source_id = (int) get_parameter('source_id');
$id = alerts_duplicate_alert_template($source_id);
// If user doesn't have the permission to access All group and source template is All group, then group is changed to the first group of user.
if ($can_edit_all == false && a_template['id_group'] == 0) {
$a_template['id_group'] = users_get_first_group(false, 'LM', false);
}
$id = alerts_duplicate_alert_template($source_id, $a_template['id_group']);
if ($id) {
db_pandora_audit('Template alert management', 'Duplicate alert template '.$source_id.' clone to '.$id);
@ -386,6 +385,14 @@ $create_alert = (bool) get_parameter('create_alert');
$create_template = (bool) get_parameter('create_template');
$update_template = (bool) get_parameter('update_template');
$disabled = false;
if (!$create_alert && !$create_template) {
// When user edits a template with All group, user must have "LM" access privileges againt All group.
if ($a_template['id_group'] == 0 && !$can_edit_all) {
$disabled = true;
}
}
$name = '';
$description = '';
$type = '';
@ -602,7 +609,7 @@ if ($step == 2) {
1,
$monday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Tue');
$table->data[0][1] .= html_print_checkbox(
@ -610,7 +617,7 @@ if ($step == 2) {
1,
$tuesday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Wed');
$table->data[0][1] .= html_print_checkbox(
@ -618,7 +625,7 @@ if ($step == 2) {
1,
$wednesday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Thu');
$table->data[0][1] .= html_print_checkbox(
@ -626,7 +633,7 @@ if ($step == 2) {
1,
$thursday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Fri');
$table->data[0][1] .= html_print_checkbox(
@ -634,7 +641,7 @@ if ($step == 2) {
1,
$friday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Sat');
$table->data[0][1] .= html_print_checkbox(
@ -642,7 +649,7 @@ if ($step == 2) {
1,
$saturday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][1] .= __('Sun');
$table->data[0][1] .= html_print_checkbox(
@ -650,7 +657,7 @@ if ($step == 2) {
1,
$sunday,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[0][2] = __('Use special days list');
@ -659,7 +666,7 @@ if ($step == 2) {
1,
$special_day,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[1][0] = __('Time from');
@ -680,7 +687,7 @@ if ($step == 2) {
'',
'',
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[1][2] = __('Time to');
$table->data[1][3] = html_print_input_text(
@ -700,7 +707,7 @@ if ($step == 2) {
'',
'',
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->colspan['threshold'][1] = 3;
@ -716,7 +723,7 @@ if ($step == 2) {
false,
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[3][0] = __('Min. number of alerts');
@ -737,7 +744,7 @@ if ($step == 2) {
'',
'',
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[3][2] = __('Reset counter for non-sustained alerts');
@ -750,7 +757,7 @@ if ($step == 2) {
1,
$min_alerts_reset_counter,
true,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
'',
false,
$create_template == 1 ? 'checked=checked' : ''
@ -774,7 +781,7 @@ if ($step == 2) {
'',
'',
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[4][2] = __('Disable event');
@ -783,7 +790,7 @@ if ($step == 2) {
1,
$disable_event,
true,
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[5][0] = __('Default action');
@ -811,7 +818,7 @@ if ($step == 2) {
true,
false,
false,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
false,
false,
0
@ -833,7 +840,7 @@ if ($step == 2) {
false,
false,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[6][1] .= '<span id="matches_value" '.($show_matches ? '' : 'class="invisible"').'>';
$table->data[6][1] .= '&nbsp;'.html_print_checkbox('matches_value', 1, $matches, true);
@ -886,7 +893,8 @@ if ($step == 2) {
'',
5,
255,
true
true,
$disabled
);
$table->colspan['min'][1] = 3;
@ -897,7 +905,8 @@ if ($step == 2) {
'',
5,
255,
true
true,
$disabled
);
$table->colspan['max'][1] = 3;
@ -940,7 +949,7 @@ if ($step == 2) {
false,
false,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->colspan[0][1] = 2;
@ -966,7 +975,7 @@ if ($step == 2) {
0,
'',
false,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"removeTinyMCE('textarea_field".$i."')",
'',
true
@ -979,7 +988,7 @@ if ($step == 2) {
0,
'',
true,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"addTinyMCE('textarea_field".$i."')",
'',
true
@ -995,7 +1004,7 @@ if ($step == 2) {
'class="fields" min-height-40px',
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
// Recovery.
@ -1007,7 +1016,7 @@ if ($step == 2) {
0,
'',
false,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"removeTinyMCE('textarea_field".$i."_recovery')",
'',
true
@ -1020,7 +1029,7 @@ if ($step == 2) {
0,
'',
true,
$is_central_policies_on_node,
$is_central_policies_on_node | $disabled,
"addTinyMCE('textarea_field".$i."_recovery')",
'',
true
@ -1036,7 +1045,7 @@ if ($step == 2) {
'class="fields min-height-40px"',
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
}
} else {
@ -1093,7 +1102,7 @@ if ($step == 2) {
'',
'',
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
@ -1103,8 +1112,12 @@ if ($step == 2) {
$return_all_group = false;
if (users_can_manage_group_all('LM') === true) {
if (users_can_manage_group_all('LM') === true || $disabled) {
$return_all_group = true;
} else {
if ($id_group == 0) {
$id_group = users_get_first_group(false, 'LM', false);
}
}
$table->data[0][1] .= '&nbsp;';
@ -1121,7 +1134,7 @@ if ($step == 2) {
false,
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
).'</div>';
@ -1134,7 +1147,7 @@ if ($step == 2) {
'',
true,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
$table->data[2][0] = __('Priority');
@ -1149,7 +1162,7 @@ if ($step == 2) {
false,
false,
'',
$is_central_policies_on_node
$is_central_policies_on_node | $disabled
);
if (defined('METACONSOLE')) {
@ -1186,16 +1199,6 @@ if ($id) {
html_print_input_hidden('create_template', 1);
}
$disabled = false;
if (!$create_alert && !$create_template) {
if ($a_template['id_group'] == 0) {
// then must have "PM" access privileges
if (! check_acl($config['id_user'], 0, 'PM')) {
$disabled = true;
}
}
}
if (!$disabled) {
if ($is_central_policies_on_node === false) {
if ($step >= LAST_STEP) {

View File

@ -448,10 +448,11 @@ function alerts_delete_alert_action($id_alert_action)
* Clone an alert action.
*
* @param int Id of the original alert action
* @param int Agent group id if it wants to be changed when clone.
*
* @return mixed Id of the cloned action or false in case of fail.
*/
function alerts_clone_alert_action($id_alert_action)
function alerts_clone_alert_action($id_alert_action, $id_group)
{
$id_alert_action = safe_int($id_alert_action, 1);
if (empty($id_alert_action)) {
@ -464,6 +465,10 @@ function alerts_clone_alert_action($id_alert_action)
return false;
}
if ($id_group != '') {
$action['id_group'] = $id_group;
}
unset($action['id']);
return alerts_create_alert_action($action['name'].' '.__('copy'), $action['id_alert_command'], $action);
@ -1130,10 +1135,11 @@ function alerts_get_alert_template_field3_recovery($id_alert_template)
* Duplicates an alert template.
*
* @param int Id of an alert template.
* @param int Agent group id if it wants to be changed when duplicate.
*
* @return mixed Duplicates an alert template or false if something goes wrong.
*/
function alerts_duplicate_alert_template($id_alert_template)
function alerts_duplicate_alert_template($id_alert_template, $id_group)
{
$template = alerts_get_alert_template($id_alert_template);
@ -1141,6 +1147,10 @@ function alerts_duplicate_alert_template($id_alert_template)
return false;
}
if ($id_group != '') {
$template['id_group'] = $id_group;
}
$name = io_safe_input(__('Copy of').' ').$template['name'];
$type = $template['type'];