mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12120)
This commit is contained in:
@@ -15,26 +15,26 @@
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
if (! Auth::user()->hasGlobalAdmin()) {
|
||||
$response = [
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
);
|
||||
];
|
||||
echo _json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['sub_type']) && !empty($_POST['sub_type'])) {
|
||||
$status = 'error';
|
||||
if (isset($_POST['sub_type']) && ! empty($_POST['sub_type'])) {
|
||||
$status = 'error';
|
||||
$message = 'Error removing custom';
|
||||
if (dbUpdate(array('sensor_custom' => 'No'), 'sensors', '`sensor_id` = ?', array($_POST['sensor_id'])) >= 0) {
|
||||
$status = 'ok';
|
||||
if (dbUpdate(['sensor_custom' => 'No'], 'sensors', '`sensor_id` = ?', [$_POST['sensor_id']]) >= 0) {
|
||||
$status = 'ok';
|
||||
$message = 'Custom limit removed. New one will be set up in rediscovery';
|
||||
} else {
|
||||
$message = 'Couldn\'t not remove custom. Enable debug and check logfile';
|
||||
}
|
||||
} else {
|
||||
if (!is_numeric($_POST['device_id']) || !is_numeric($_POST['sensor_id'])) {
|
||||
if (! is_numeric($_POST['device_id']) || ! is_numeric($_POST['sensor_id'])) {
|
||||
$message = "Invalid device or sensor id";
|
||||
} else {
|
||||
if ($_POST['state'] == 'true') {
|
||||
@@ -47,8 +47,8 @@ if (isset($_POST['sub_type']) && !empty($_POST['sub_type'])) {
|
||||
$state = 0;
|
||||
$state_string = "disabled";
|
||||
}
|
||||
if (dbUpdate(array('sensor_alert' => $state), 'sensors', '`sensor_id` = ? AND `device_id` = ?', array($_POST['sensor_id'], $_POST['device_id'])) >= 0) {
|
||||
$status = ($state == 0) ? 'info' : 'ok';
|
||||
if (dbUpdate(['sensor_alert' => $state], 'sensors', '`sensor_id` = ? AND `device_id` = ?', [$_POST['sensor_id'], $_POST['device_id']]) >= 0) {
|
||||
$status = ($state == 0) ? 'info' : 'ok';
|
||||
$message = 'Alerts ' . $state_string . ' for sensor ' . $_POST['sensor_desc'];
|
||||
} else {
|
||||
$status = 'error';
|
||||
@@ -56,8 +56,8 @@ if (isset($_POST['sub_type']) && !empty($_POST['sub_type'])) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$response = array(
|
||||
$response = [
|
||||
'status' => $status,
|
||||
'message' => $message
|
||||
);
|
||||
'message' => $message,
|
||||
];
|
||||
echo _json_encode($response);
|
||||
|
||||
Reference in New Issue
Block a user