mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Removed references to location override
This commit is contained in:
@@ -738,18 +738,6 @@ function devclass($device) {
|
|||||||
function getlocations() {
|
function getlocations() {
|
||||||
$ignore_dev_location = array();
|
$ignore_dev_location = array();
|
||||||
$locations = array();
|
$locations = array();
|
||||||
// Fetch override locations, not through get_dev_attrib, this would be a huge number of queries
|
|
||||||
$rows = dbFetchRows("SELECT attrib_type,attrib_value,device_id FROM devices_attribs WHERE attrib_type LIKE 'override_sysLocation%' ORDER BY attrib_type");
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
if ($row['attrib_type'] == 'override_sysLocation_bool' && $row['attrib_value'] == 1) {
|
|
||||||
$ignore_dev_location[$row['device_id']] = 1;
|
|
||||||
} //end if
|
|
||||||
else if ($row['attrib_type'] == 'override_sysLocation_string' && (isset($ignore_dev_location[$row['device_id']]) && $ignore_dev_location[$row['device_id']] == 1)) {
|
|
||||||
if (!in_array($row['attrib_value'], $locations)) {
|
|
||||||
$locations[] = $row['attrib_value'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch regular locations
|
// Fetch regular locations
|
||||||
if ($_SESSION['userlevel'] >= '5') {
|
if ($_SESSION['userlevel'] >= '5') {
|
||||||
@@ -761,7 +749,7 @@ function getlocations() {
|
|||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
// Only add it as a location if it wasn't overridden (and not already there)
|
// Only add it as a location if it wasn't overridden (and not already there)
|
||||||
if ($row['location'] != '' && !isset($ignore_dev_location[$row['device_id']])) {
|
if ($row['location'] != '') {
|
||||||
if (!in_array($row['location'], $locations)) {
|
if (!in_array($row['location'], $locations)) {
|
||||||
$locations[] = $row['location'];
|
$locations[] = $row['location'];
|
||||||
}
|
}
|
||||||
|
@@ -64,10 +64,6 @@ echo '</td>';
|
|||||||
echo ' <td>'.$device['hardware'].' '.$device['features'].'</td>';
|
echo ' <td>'.$device['hardware'].' '.$device['features'].'</td>';
|
||||||
echo ' <td>'.formatUptime($device['uptime'], 'short').' <br />';
|
echo ' <td>'.formatUptime($device['uptime'], 'short').' <br />';
|
||||||
|
|
||||||
if (get_dev_attrib($device, 'override_sysLocation_bool')) {
|
|
||||||
$device['location'] = get_dev_attrib($device, 'override_sysLocation_string');
|
|
||||||
}
|
|
||||||
|
|
||||||
echo ' '.truncate($device['location'], 32, '').'</td>';
|
echo ' '.truncate($device['location'], 32, '').'</td>';
|
||||||
|
|
||||||
echo ' </tr>';
|
echo ' </tr>';
|
||||||
|
@@ -6,11 +6,6 @@ require_once $config['install_dir'].'/includes/object-cache.inc.php';
|
|||||||
// FIXME: This appears to keep a complete cache of device details in memory for every page load.
|
// FIXME: This appears to keep a complete cache of device details in memory for every page load.
|
||||||
// It would be interesting to know where this is used. It probably should have its own API.
|
// It would be interesting to know where this is used. It probably should have its own API.
|
||||||
foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) {
|
foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) {
|
||||||
if (get_dev_attrib($device, 'override_sysLocation_bool')) {
|
|
||||||
$device['real_location'] = $device['location'];
|
|
||||||
$device['location'] = get_dev_attrib($device, 'override_sysLocation_string');
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache['devices']['hostname'][$device['hostname']] = $device['device_id'];
|
$cache['devices']['hostname'][$device['hostname']] = $device['device_id'];
|
||||||
$cache['devices']['id'][$device['device_id']] = $device;
|
$cache['devices']['id'][$device['device_id']] = $device;
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ if (!empty($_POST['location']) && $_POST['location'] == 'Unset') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['location'])) {
|
if (!empty($_POST['location'])) {
|
||||||
$sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)";
|
$sql .= " AND `location` = ?";
|
||||||
$param[] = mres($_POST['location']);
|
$param[] = mres($_POST['location']);
|
||||||
$param[] = mres($_POST['location']);
|
$param[] = mres($_POST['location']);
|
||||||
}
|
}
|
||||||
@@ -167,10 +167,6 @@ foreach (dbFetchRows($sql, $param) as $device) {
|
|||||||
$port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
|
$port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
|
||||||
$sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id']));
|
$sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id']));
|
||||||
|
|
||||||
if (get_dev_attrib($device, 'override_sysLocation_bool')) {
|
|
||||||
$device['location'] = get_dev_attrib($device, 'override_sysLocation_string');
|
|
||||||
}
|
|
||||||
|
|
||||||
$actions = ('<div class="row">
|
$actions = ('<div class="row">
|
||||||
<div class="col-xs-1">');
|
<div class="col-xs-1">');
|
||||||
$actions .= '<a href="'.generate_device_url($device).'"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device" /></a> ';
|
$actions .= '<a href="'.generate_device_url($device).'"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device" /></a> ';
|
||||||
|
@@ -9,20 +9,22 @@ if ($_POST['editing']) {
|
|||||||
$override_sysLocation_string = mres($_POST['sysLocation']);
|
$override_sysLocation_string = mres($_POST['sysLocation']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_dev_attrib($device,'override_sysLocation_bool') != $override_sysLocation_bool
|
if ($device['override_sysLocation'] != $override_sysLocation_bool || $device['location'] != $override_sysLocation_string) {
|
||||||
|| get_dev_attrib($device,'override_sysLocation_string') != $override_sysLocation_string) {
|
$updated = 1;
|
||||||
$updated = 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($override_sysLocation_bool) {
|
if ($override_sysLocation_bool) {
|
||||||
set_dev_attrib($device, 'override_sysLocation_bool', '1');
|
$override_sysLocation = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
del_dev_attrib($device, 'override_sysLocation_bool');
|
$override_sysLocation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbUpdate(array('override_sysLocation'=>$override_sysLocation), 'devices', '`device_id`=?' ,array($device['device_id']));
|
||||||
|
|
||||||
if (isset($override_sysLocation_string)) {
|
if (isset($override_sysLocation_string)) {
|
||||||
set_dev_attrib($device, 'override_sysLocation_string', $override_sysLocation_string);
|
dbUpdate(array('location'=>$override_sysLocation_string), 'devices', '`device_id`=?' ,array($device['device_id']));
|
||||||
};
|
}
|
||||||
|
|
||||||
#FIXME needs more sanity checking! and better feedback
|
#FIXME needs more sanity checking! and better feedback
|
||||||
|
|
||||||
@@ -50,8 +52,8 @@ if ($_POST['editing']) {
|
|||||||
|
|
||||||
$descr = $device['purpose'];
|
$descr = $device['purpose'];
|
||||||
|
|
||||||
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
|
$override_sysLocation = $device['override_sysLocation'];
|
||||||
$override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string');
|
$override_sysLocation_string = $device['location'];
|
||||||
|
|
||||||
if ($updated && $update_message) {
|
if ($updated && $update_message) {
|
||||||
print_message($update_message);
|
print_message($update_message);
|
||||||
@@ -116,7 +118,7 @@ if ($unknown) {
|
|||||||
<label for="sysLocation" class="col-sm-2 control-label">Override sysLocation:</label>
|
<label for="sysLocation" class="col-sm-2 control-label">Override sysLocation:</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) echo(' checked="1"'); ?> />
|
<input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation) echo(' checked="1"'); ?> />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -124,7 +126,7 @@ if ($unknown) {
|
|||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input id="sysLocation" name="sysLocation" class="form-control" <?php if (!$override_sysLocation_bool) echo(' disabled="1"'); ?> value="<?php echo($override_sysLocation_string); ?>" />
|
<input id="sysLocation" name="sysLocation" class="form-control" <?php if (!$override_sysLocation) echo(' disabled="1"'); ?> value="<?php echo($override_sysLocation_string); ?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@@ -181,8 +181,7 @@ if($format == "graph") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (device_permitted($device['device_id'])) {
|
if (device_permitted($device['device_id'])) {
|
||||||
if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
|
if (!$location_filter || $device['location'] == $location_filter) {
|
||||||
|| $device['location'] == $location_filter)) {
|
|
||||||
$graph_type = "device_".$subformat;
|
$graph_type = "device_".$subformat;
|
||||||
|
|
||||||
if ($_SESSION['widescreen']) {
|
if ($_SESSION['widescreen']) {
|
||||||
|
@@ -43,7 +43,7 @@ foreach (getlocations() as $location) {
|
|||||||
$devices_up = array();
|
$devices_up = array();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$down = 0;
|
$down = 0;
|
||||||
foreach (dbFetchRows("SELECT devices.device_id,devices.hostname,devices.status FROM devices LEFT JOIN devices_attribs ON devices.device_id = devices_attribs.device_id WHERE ( devices.location = ? || ( devices_attribs.attrib_type = 'override_sysLocation_string' && devices_attribs.attrib_value = ? ) ) && devices.disabled = 0 && devices.ignore = 0 GROUP BY devices.hostname", array($location,$location)) as $device) {
|
foreach (dbFetchRows("SELECT devices.device_id,devices.hostname,devices.status FROM devices LEFT JOIN devices_attribs ON devices.device_id = devices_attribs.device_id WHERE devices.location = ? && devices.disabled = 0 && devices.ignore = 0 GROUP BY devices.hostname", array($location)) as $device) {
|
||||||
if( $config['frontpage_globe']['markers'] == 'devices' || empty($config['frontpage_globe']['markers']) ) {
|
if( $config['frontpage_globe']['markers'] == 'devices' || empty($config['frontpage_globe']['markers']) ) {
|
||||||
$devices[] = $device['hostname'];
|
$devices[] = $device['hostname'];
|
||||||
$count++;
|
$count++;
|
||||||
|
@@ -296,10 +296,6 @@ function device_by_id_cache($device_id, $refresh = '0') {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device_id));
|
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device_id));
|
||||||
if (get_dev_attrib($device,'override_sysLocation_bool')) {
|
|
||||||
$device['real_location'] = $device['location'];
|
|
||||||
$device['location'] = get_dev_attrib($device,'override_sysLocation_string');
|
|
||||||
}
|
|
||||||
$cache['devices']['id'][$device_id] = $device;
|
$cache['devices']['id'][$device_id] = $device;
|
||||||
}
|
}
|
||||||
return $device;
|
return $device;
|
||||||
|
@@ -22,10 +22,6 @@ while ($end == 0) {
|
|||||||
passthru('clear');
|
passthru('clear');
|
||||||
$tbl = new Console_Table(CONSOLE_TABLE_ALIGN_RIGHT);
|
$tbl = new Console_Table(CONSOLE_TABLE_ALIGN_RIGHT);
|
||||||
foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) {
|
foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) {
|
||||||
if (get_dev_attrib($device, 'override_sysLocation_bool')) {
|
|
||||||
$device['real_location'] = $device['location'];
|
|
||||||
$device['location'] = get_dev_attrib($device, 'override_sysLocation_string');
|
|
||||||
}
|
|
||||||
|
|
||||||
$devices['count']++;
|
$devices['count']++;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user