Issues (2963)

includes/html/list/transport_groups.inc.php (1 issue)

1
<?php
2
/**
3
 * transport-groups.inc.php
4
 *
5
 * List transports and transport groups
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  2018 Vivia Nguyen-Tran
23
 * @author     Vivia Nguyen-Tran <vivia@ualberta>
24
 */
25
if (! Auth::user()->hasGlobalRead()) {
0 ignored issues
show
The method hasGlobalRead() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
if (! Auth::user()->/** @scrutinizer ignore-call */ hasGlobalRead()) {
Loading history...
26
    return [];
27
}
28
29
[$transports, $t_more] = include 'transports.inc.php';
30
31
$query = '';
32
$params = [];
33
34
if (! empty($_REQUEST['search'])) {
35
    $query .= ' WHERE `transport_group_name` LIKE ?';
36
    $params[] = '%' . $vars['search'] . '%';
37
}
38
39
$total = dbFetchCell("SELECT COUNT(*) FROM `alert_transport_groups` $query", $params);
40
$more = false;
41
42
if (! empty($_REQUEST['limit'])) {
43
    $limit = (int) $_REQUEST['limit'];
44
    $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1;
45
    $offset = ($page - 1) * $limit;
46
47
    $query .= " LIMIT $offset, $limit";
48
} else {
49
    $offset = 0;
50
}
51
52
$sql = "SELECT `transport_group_id` AS `id`, `transport_group_name` AS `text` FROM `alert_transport_groups` $query";
53
$groups = dbFetchRows($sql, $params);
54
$more = ($offset + count($groups)) < $total;
55
$groups = array_map(function ($group) {
56
    $group['text'] = 'Group: ' . $group['text'];
57
    $group['id'] = 'g' . $group['id'];
58
59
    return $group;
60
}, $groups);
61
62
$data = [['text' => 'Transport Groups', 'children' => $groups], $transports[0]];
63
64
return[$data, $more || $c_more];
65