1 | <?php |
||
2 | /** |
||
3 | * delete-poller.inc.php |
||
4 | * |
||
5 | * Handle poller delete request |
||
6 | * |
||
7 | * This program is free software: you can redistribute it and/or modify |
||
8 | * it under the terms of the GNU General Public License as published by |
||
9 | * the Free Software Foundation, either version 3 of the License, or |
||
10 | * (at your option) any later version. |
||
11 | * |
||
12 | * This program is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||
15 | * GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License |
||
18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
19 | * |
||
20 | * @link https://www.librenms.org |
||
21 | * |
||
22 | * @copyright 2017 Tony Murray |
||
23 | * @author Tony Murray <[email protected]> |
||
24 | */ |
||
25 | if (! Auth::user()->hasGlobalAdmin()) { |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
26 | $status = ['status' =>1, 'message' => 'ERROR: You need to be admin to delete poller entries']; |
||
27 | } else { |
||
28 | $id = $vars['id']; |
||
29 | if (! is_numeric($id)) { |
||
30 | $status = ['status' =>1, 'message' => 'No poller has been selected']; |
||
31 | } else { |
||
32 | $poller_name = dbFetchCell('SELECT `poller_name` FROM `pollers` WHERE `id`=?', [$id]); |
||
33 | if (dbDelete('pollers', 'id=?', [$id])) { |
||
34 | $status = ['status' => 0, 'message' => "Poller: <i>$poller_name ($id), has been deleted.</i>"]; |
||
35 | } else { |
||
36 | $status = ['status' => 1, 'message' => "Poller: <i>$poller_name ($id), has NOT been deleted.</i>"]; |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 | header('Content-Type: application/json'); |
||
41 | echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
||
42 |