Merge branch '2457-No-permite-editar-ni-eliminar-alertas-de-cluster' into 'develop'

Added new funcionality to cluster alert configuration: update alert

See merge request artica/pandorafms!1634
This commit is contained in:
vgilc 2018-09-28 10:50:44 +02:00
commit d5b9ddec46
4 changed files with 43 additions and 9 deletions

View File

@ -218,7 +218,7 @@ $(document).ready (function () {
$("#value", $value).append ("<em><?php echo __('Empty') ?></em>"); $("#value", $value).append ("<em><?php echo __('Empty') ?></em>");
} }
else { else {
$("#value", $value).append (data); $("#value", $value).append (parseInt(data));
} }
$loading.hide (); $loading.hide ();
$value.show (); $value.show ();

View File

@ -705,18 +705,26 @@ foreach ($simple_alerts as $alert) {
if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LW")) { if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LW")) {
$data[4] .= '&nbsp;&nbsp;<form class="delete_alert_form" action="' . $url . '" method="post" style="display: inline;">'; $data[4] .= '&nbsp;&nbsp;<form class="delete_alert_form" action="' . $url . '" method="post" style="display: inline;">';
if ($alert['disabled']) { if ($alert['disabled']) {
$data[4] .= html_print_image('images/add.disabled.png',
true, array('title' => __("Add action")));
} }
else { else {
$data[4] .= '<a href="javascript:show_add_action(\'' . $alert['id'] . '\');">'; $data[4] .= '<a href="javascript:show_add_action(\'' . $alert['id'] . '\');">';
$data[4] .= html_print_image('images/add.png', true, array('title' => __("Add action")));
$data[4] .= '</a>'; $data[4] .= '</a>';
} }
$data[4] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete'))); $data[4] .= html_print_input_image ('delete', 'images/cross.png', 1, '', true, array('title' => __('Delete')));
$data[4] .= html_print_input_hidden ('delete_alert', 1, true); $data[4] .= html_print_input_hidden ('delete_alert', 1, true);
$data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true); $data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[4] .= '</form>'; $data[4] .= '</form>';
$data[4] .= '<form class="view_alert_form" method="post" style="display: inline;">';
$data[4] .= html_print_input_image ('update', 'images/builder.png', 1, '', true, array('title' => __('Update')));
$data[4] .= html_print_input_hidden ('upd_alert', 1, true);
$data[4] .= html_print_input_hidden ('id_alert', $alert['id'], true);
$data[4] .= '</form>';
} }
if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LM")) { if(check_acl_one_of_groups ($config['id_user'], $all_groups, "LM")) {

View File

@ -47,6 +47,7 @@ $add_action = (bool) get_parameter ('add_action');
$update_action = (bool) get_parameter ('update_action'); $update_action = (bool) get_parameter ('update_action');
$delete_action = (bool) get_parameter ('delete_action'); $delete_action = (bool) get_parameter ('delete_action');
$delete_alert = (bool) get_parameter ('delete_alert'); $delete_alert = (bool) get_parameter ('delete_alert');
$update_alert = (bool) get_parameter ('update_alert'); ////
$disable_alert = (bool) get_parameter ('disable_alert'); $disable_alert = (bool) get_parameter ('disable_alert');
$enable_alert = (bool) get_parameter ('enable_alert'); $enable_alert = (bool) get_parameter ('enable_alert');
$standbyon_alert = (bool) get_parameter ('standbyon_alert'); $standbyon_alert = (bool) get_parameter ('standbyon_alert');
@ -67,10 +68,32 @@ $standby = get_parameter('standby','');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
$messageAction = ''; $messageAction = '';
if ($update_alert) {
$id_alert_agent_module = (int) get_parameter ('id_alert_update');
$id_alert_template = (int) get_parameter ('template');
$id_agent_module = (int) get_parameter ('id_agent_module');
$values_upd = array();
if (!empty($id_alert_template))
$values_upd['id_agent_module'] = $id_agent_module;
if (!empty($id_alert_template))
$values_upd['id_alert_template'] = $id_alert_template;
$id = alerts_update_alert_agent_module ($id_alert_agent_module, $values_upd);
$messageAction = ui_print_result_message ($id,
__('Successfully updated'), __('Could not be updated'), '', true);
}
if ($create_alert) { if ($create_alert) {
$id_alert_template = (int) get_parameter ('template'); $id_alert_template = (int) get_parameter ('template');
$id_agent_module = (int) get_parameter ('id_agent_module'); $id_agent_module = (int) get_parameter ('id_agent_module');
if (db_get_value_sql("SELECT COUNT(id) if (db_get_value_sql("SELECT COUNT(id)
FROM talert_template_modules FROM talert_template_modules
WHERE id_agent_module = " . $id_agent_module . " WHERE id_agent_module = " . $id_agent_module . "
@ -81,7 +104,7 @@ if ($create_alert) {
} }
else { else {
$id = alerts_create_alert_agent_module ($id_agent_module, $id_alert_template); $id = alerts_create_alert_agent_module ($id_agent_module, $id_alert_template);
$alert_template_name = db_get_value ("name", $alert_template_name = db_get_value ("name",
"talert_templates","id", $id_alert_template); "talert_templates","id", $id_alert_template);
$module_name = db_get_value ("nombre", $module_name = db_get_value ("nombre",
@ -116,6 +139,7 @@ if ($create_alert) {
$values['module_action_threshold'] = $values['module_action_threshold'] =
(int)get_parameter ('module_action_threshold'); (int)get_parameter ('module_action_threshold');
alerts_add_alert_agent_module_action ($id, $action_select, $values); alerts_add_alert_agent_module_action ($id, $action_select, $values);
} }
} }

View File

@ -1019,14 +1019,16 @@ function alerts_create_alert_agent_module ($id_agent_module, $id_alert_template,
* @return mixed Affected rows or false if something goes wrong. * @return mixed Affected rows or false if something goes wrong.
*/ */
function alerts_update_alert_agent_module ($id_alert_agent_module, $values) { function alerts_update_alert_agent_module ($id_alert_agent_module, $values) {
if (empty ($id_agent_module))
if (empty ($id_alert_agent_module))
return false; return false;
if (! is_array ($values)) if (! is_array ($values))
return false; return false;
return (@db_process_sql_update ('talert_template_modules', return (@db_process_sql_update ('talert_template_modules',
$values, $values,
array ('id' => $id_alert_template))) !== false; array ('id' => $id_alert_agent_module))) !== false;
} }
/** /**