diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index e5c2df8dfe..02b80a0b00 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -9,45 +9,69 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -require_once 'includes/object-cache.inc.php'; -$sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` FROM `devices` AS `D`'; +if (defined('show_settings')) { + + $common_output[] = ' +
+
+ +
+ +
+
+
+
+ +
+
+
+ '; -if (is_normal_user() === true) { - $sql.= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND'; - $param = array( - $_SESSION['user_id'] - ); } else { - $sql.= ' WHERE'; -} -$sql.= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`"; -$temp_output = array(); -$c = '0'; + require_once 'includes/object-cache.inc.php'; + $tile_width = $widget_settings['tile_width']; -foreach(dbFetchRows($sql, $param) as $device) { - if ($device['status'] == '1') { - $btn_type = 'btn-success'; - if ($device['uptime'] < $config['uptime_warning']) { - $btn_type = 'btn-warning'; - $c++; - } + $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` FROM `devices` AS `D`'; + + if (is_normal_user() === true) { + $sql.= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND'; + $param = array( + $_SESSION['user_id'] + ); } else { - $btn_type = 'btn-danger'; + $sql.= ' WHERE'; } - $temp_output[] = ''; -} + $sql.= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`"; + $temp_output = array(); + $c = '0'; -$temp_rows = count($temp_output); -$temp_output[] = ''; -$temp_header = array( - '
' . $devices['up'] . ' '. $c .' ' . $devices['down'] . '

' -); -$common_output = array_merge($temp_header, $temp_output); + foreach(dbFetchRows($sql, $param) as $device) { + if ($device['status'] == '1') { + $btn_type = 'btn-success'; + if ($device['uptime'] < $config['uptime_warning']) { + $btn_type = 'btn-warning'; + $c++; + } + } + else { + $btn_type = 'btn-danger'; + } + + $temp_output[] = ''; + } + + $temp_rows = count($temp_output); + $temp_output[] = '
'; + $temp_header = array( + '
' . $devices['up'] . ' '. $c .' ' . $devices['down'] . '

' + ); + $common_output = array_merge($temp_header, $temp_output); +}