Apply fixes from StyleCI (#12120)

This commit is contained in:
Jellyfrog
2020-09-21 15:40:17 +02:00
committed by GitHub
parent 77c531527c
commit 82f43cb98d
1733 changed files with 18337 additions and 18540 deletions

View File

@@ -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);