mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Change select order from id to name * added example icmp/snmp down rules given by @kkrumm1 * Renovated Alert Rules * Defaulted sort by name * Moved top buttons and results selector outside of table and aligned them with pull-left and pull-right * Collapsed '#' (ID) into 'Type' and added titles for the icons * Added Devices and Transports columns for each rule * Moved Extra column next to transports * Added icons for Enabled when a user does not have global admin * Changed row_# variable to rule_id_# * Some 'else' cleanup * Added various title tags for more information when hovering * Moved pagination outside of table and align it with pull-left and added a bootgrid style summary pulled-right * Added table & th tags for bootgrid (but didn't turn it on) * code climate, round 1 * code climate, round 2 * add hrefs for device & device group edit * added trailing slash for device-groups/../edit/ * prevent #name conflict with transport modal * add hrefs for transport & transport group edit * use popover consistently * code climate, round 3 * removed unused variables * code climate, round 4 * popover variables * reload after successful delete * more informative feedback * use toastr, not #message, & don't reload * added license header & fail faster if not admin * use (more informative) ajax error message * delete confirmation with alert name in the modal * print each device per line * add href for all devices * refresh status & enabled data-content when/if a rule is turned on/off * use DRY style per @SourceDoctor (& my) preference); codeclimate meh * point devices popover to the right
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* LibreNMS
|
|
*
|
|
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
* option) any later version. Please see LICENSE.txt at the top level of
|
|
* the source code distribution for details.
|
|
*/
|
|
|
|
header('Content-type: text/plain');
|
|
|
|
if (!Auth::user()->hasGlobalAdmin()) {
|
|
die('ERROR: You need to be admin');
|
|
}
|
|
|
|
if (!is_numeric($vars['alert_id'])) {
|
|
echo 'ERROR: No alert selected';
|
|
exit;
|
|
} else {
|
|
$alert_name = dbFetchCell('SELECT name FROM alert_rules WHERE id=?', [$vars['alert_id']]);
|
|
$alert_msg_prefix = 'Alert rule';
|
|
if ($alert_name) {
|
|
$alert_msg_prefix .= ' ' . $alert_name;
|
|
}
|
|
if (!$alert_name) {
|
|
$alert_msg_prefix .= ' id ' . $vars['alert_id'];
|
|
}
|
|
if (dbDelete('alert_rules', '`id` = ?', array($vars['alert_id']))) {
|
|
dbDelete('alert_device_map', 'rule_id=?', [$vars['alert_id']]);
|
|
dbDelete('alert_group_map', 'rule_id=?', [$vars['alert_id']]);
|
|
dbDelete('alert_transport_map', 'rule_id=?', [$vars['alert_id']]);
|
|
dbDelete('alert_template_map', 'alert_rule_id=?', [$vars['alert_id']]);
|
|
echo $alert_msg_prefix . ' has been deleted.';
|
|
exit;
|
|
} else {
|
|
echo 'ERROR: ' . $alert_msg_prefix . ' has not been deleted.';
|
|
exit;
|
|
}
|
|
}
|