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

@@ -1,13 +1,13 @@
<?php
if (Auth::user()->hasGlobalRead()) {
$data['active_count'] = array('query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,2) AND `devices`.`disabled` = 0 AND `devices`.`ignore` = 0');
$data['active_count'] = ['query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,2) AND `devices`.`disabled` = 0 AND `devices`.`ignore` = 0'];
} else {
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
$perms_sql = "`D`.`device_id` IN " .dbGenPlaceholders(count($device_ids));
$perms_sql = "`D`.`device_id` IN " . dbGenPlaceholders(count($device_ids));
$data['active_count'] = array(
$data['active_count'] = [
'query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE $perms_sql AND `alerts`.`state` NOT IN (0,2) AND `devices`.`disabled` = 0 AND `devices`.`ignore` = 0',
'params' => $device_ids
);
'params' => $device_ids,
];
}

View File

@@ -1,41 +1,41 @@
<?php
if (Auth::user()->hasGlobalRead()) {
$data['count'] = array('query' => 'SELECT COUNT(*) FROM devices');
$data['count'] = ['query' => 'SELECT COUNT(*) FROM devices'];
$data['up'] = array('query' => "SELECT COUNT(*) FROM devices WHERE `status` = '1' AND `ignore` = '0' AND `disabled` = '0'",);
$data['up'] = ['query' => "SELECT COUNT(*) FROM devices WHERE `status` = '1' AND `ignore` = '0' AND `disabled` = '0'"];
$data['down'] = array('query' => "SELECT COUNT(*) FROM devices WHERE `status` = '0' AND `ignore` = '0' AND `disabled` = '0'");
$data['down'] = ['query' => "SELECT COUNT(*) FROM devices WHERE `status` = '0' AND `ignore` = '0' AND `disabled` = '0'"];
$data['ignored'] = array('query' => "SELECT COUNT(*) FROM devices WHERE `ignore` = '1' AND `disabled` = '0'");
$data['ignored'] = ['query' => "SELECT COUNT(*) FROM devices WHERE `ignore` = '1' AND `disabled` = '0'"];
$data['disabled'] = array('query' => "SELECT COUNT(*) FROM devices WHERE `disabled` = '1'");
$data['disabled'] = ['query' => "SELECT COUNT(*) FROM devices WHERE `disabled` = '1'"];
} else {
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
$perms_sql = "`D`.`device_id` IN " .dbGenPlaceholders(count($device_ids));
$perms_sql = "`D`.`device_id` IN " . dbGenPlaceholders(count($device_ids));
$data['count'] = array(
$data['count'] = [
'query' => 'SELECT COUNT(*) FROM devices AS D WHERE $perms_sql',
'params' => $device_ids
);
'params' => $device_ids,
];
$data['up'] = array(
$data['up'] = [
'query' => "SELECT COUNT(*) FROM devices AS D WHERE $perms_sql AND D.`status` = '1' AND D.`ignore` = '0' AND D.`disabled` = '0'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['down'] = array(
$data['down'] = [
'query' => "SELECT COUNT(*) FROM devices AS D WHERE $perms_sql AND D.`status` = '0' AND D.`ignore` = '0' AND D.`disabled` = '0'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['ignored'] = array(
$data['ignored'] = [
'query' => "SELECT COUNT(*) FROM devices AS D WHERE $perms_sql AND D.`ignore` = '1' AND D.`disabled` = '0'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['disabled'] = array(
$data['disabled'] = [
'query' => "SELECT COUNT(*) FROM devices AS D WHERE $perms_sql AND D.`disabled` = '1'",
'params' => $device_ids
);
'params' => $device_ids,
];
}//end if

View File

@@ -21,26 +21,25 @@
* @package LibreNMS
* @subpackage Notifications
*/
$data['count'] = array(
$data['count'] = [
'query' => 'select count(notifications.notifications_id) from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?)',
'params' => array( Auth::id() )
);
'params' => [Auth::id()],
];
$data['unread'] = array(
$data['unread'] = [
'query' => 'select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',
'params' => array( Auth::id() )
);
'params' => [Auth::id()],
];
$data['sticky'] = array(
$data['sticky'] = [
'query' => 'select notifications.*,notifications_attribs.user_id from notifications inner join notifications_attribs on notifications.notifications_id = notifications_attribs.notifications_id where notifications_attribs.key = "sticky" && notifications_attribs.value = 1 order by notifications_attribs.attrib_id desc',
);
];
$data['sticky_count'] = array(
$data['sticky_count'] = [
'query' => 'select count(notifications.notifications_id) from notifications inner join notifications_attribs on notifications.notifications_id = notifications_attribs.notifications_id where notifications_attribs.key = "sticky" && notifications_attribs.value = 1',
);
];
$data['read'] = array(
$data['read'] = [
'query' => 'select notifications.* from notifications inner join notifications_attribs on notifications.notifications_id = notifications_attribs.notifications_id where notifications_attribs.user_id = ? && ( notifications_attribs.key = "read" && notifications_attribs.value = 1) && not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.key = "sticky" && notifications_attribs.value = "1") order by notifications_attribs.attrib_id desc',
'params' => array( Auth::id() )
);
'params' => [Auth::id()],
];

View File

@@ -1,48 +1,48 @@
<?php
if (Auth::user()->hasGlobalRead()) {
$data['count'] = array('query' => "SELECT COUNT(*) FROM ports WHERE `deleted` = '0'");
$data['count'] = ['query' => "SELECT COUNT(*) FROM ports WHERE `deleted` = '0'"];
$data['up'] = array('query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` = 'up'",);
$data['up'] = ['query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` = 'up'"];
$data['down'] = array('query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` <> 'up' AND I.`ifAdminStatus` = 'up'");
$data['down'] = ['query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` <> 'up' AND I.`ifAdminStatus` = 'up'"];
$data['shutdown'] = array('query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifAdminStatus` = 'down'");
$data['shutdown'] = ['query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifAdminStatus` = 'down'"];
$data['errored'] = array('query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')");
$data['errored'] = ['query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"];
$data['ignored'] = array('query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND (I.`ignore` = '1' OR D.`ignore` = '1')");
$data['ignored'] = ['query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND (I.`ignore` = '1' OR D.`ignore` = '1')"];
} else {
$device_ids = Permissions::portsForUser()->toArray() ?: [0];
$perms_sql = "`I`.`port_id` IN " .dbGenPlaceholders(count($device_ids));
$perms_sql = "`I`.`port_id` IN " . dbGenPlaceholders(count($device_ids));
$data['count'] = array(
$data['count'] = [
'query' => "SELECT COUNT(*) FROM ports AS I WHERE $perms_sql AND I.`deleted` = '0'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['up'] = array(
$data['up'] = [
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE $perms_sql AND I.`deleted` = '0' AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` = 'up'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['down'] = array(
$data['down'] = [
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE $perms_sql AND I.`deleted` = '0' AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` <> 'up' AND I.`ifAdminStatus` = 'up'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['shutdown'] = array(
$data['shutdown'] = [
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE $perms_sql AND I.`deleted` = '0' AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifAdminStatus` = 'down'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['errored'] = array(
$data['errored'] = [
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE $perms_sql AND I.`deleted` = '0' AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['ignored'] = array(
$data['ignored'] = [
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE $perms_sql AND I.`deleted` = '0' AND I.`device_id` = D.`device_id` AND (I.`ignore` = '1' OR D.`ignore` = '1')",
'params' => $device_ids
);
'params' => $device_ids,
];
}//end if

View File

@@ -1,37 +1,37 @@
<?php
if (Auth::user()->hasGlobalRead()) {
$data['count'] = array( 'query' => 'SELECT COUNT(*) FROM services');
$data['up'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '0'");
$data['down'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '2'");
$data['ignored'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '1' AND `service_disabled` = '0'");
$data['disabled'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_disabled` = '1'");
$data['count'] = ['query' => 'SELECT COUNT(*) FROM services'];
$data['up'] = ['query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '0'"];
$data['down'] = ['query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '2'"];
$data['ignored'] = ['query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '1' AND `service_disabled` = '0'"];
$data['disabled'] = ['query' => "SELECT COUNT(*) FROM services WHERE `service_disabled` = '1'"];
} else {
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
$perms_sql = "`S`.`device_id` IN " .dbGenPlaceholders(count($device_ids));
$perms_sql = "`S`.`device_id` IN " . dbGenPlaceholders(count($device_ids));
$data['count'] = array(
$data['count'] = [
'query' => 'SELECT COUNT(*) FROM services AS S WHERE $perms_sql',
'params' => $device_ids
);
'params' => $device_ids,
];
$data['up'] = array(
$data['up'] = [
'query' => "SELECT COUNT(*) FROM services AS S WHERE $perms_sql AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['down'] = array(
$data['down'] = [
'query' => "SELECT COUNT(*) FROM services AS S WHERE $perms_sql AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '2'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['ignored'] = array(
$data['ignored'] = [
'query' => "SELECT COUNT(*) FROM services AS S WHERE $perms_sql AND S.`service_ignore` = '1' AND S.`service_disabled` = '0'",
'params' => $device_ids
);
'params' => $device_ids,
];
$data['disabled'] = array(
$data['disabled'] = [
'query' => "SELECT COUNT(*) FROM services AS S WHERE $perms_sql AND S.`service_disabled` = '1'",
'params' => $device_ids
);
'params' => $device_ids,
];
}//end if

View File

@@ -1,13 +1,13 @@
<?php
if (Auth::user()->hasGlobalRead()) {
$data['count'] = array('query' => "SELECT COUNT(`toner_id`) FROM toner");
$data['count'] = ['query' => "SELECT COUNT(`toner_id`) FROM toner"];
} else {
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
$perms_sql = "`toner`.`device_id` IN " .dbGenPlaceholders(count($device_ids));
$perms_sql = "`toner`.`device_id` IN " . dbGenPlaceholders(count($device_ids));
$data['count'] = array(
$data['count'] = [
'query' => "SELECT COUNT(`toner_id`) FROM toner WHERE $perms_sql",
'params' => $device_ids
);
'params' => $device_ids,
];
}