fix: Detection blank or unknown device types and update #5412 (#5414)

* fix: Detection blank or unknown device types and update #5412

* Less ifs
This commit is contained in:
Neil Lathwood
2017-01-13 05:47:13 +00:00
committed by Tony Murray
parent 7215059fd0
commit 6ff3ae8789
2 changed files with 5 additions and 11 deletions

View File

@@ -1527,10 +1527,11 @@ function load_os(&$device)
);
// Set type to a predefined type for the OS if it's not already set
if ($device['type'] == 'unknown' || $device['type'] == '') {
if ($config['os'][$device['os']]['type']) {
$device['type'] = $config['os'][$device['os']]['type'];
}
if ($config['os'][$device['os']]['type'] != $device['type']) {
log_event('Device type changed '.$device['type'].' => '.$config['os'][$device['os']]['type'], $device, 'system');
$device['type'] = $config['os'][$device['os']]['type'];
dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id']));
echo "Device type changed to " . $device['type'] . "!\n";
}
if ($config['os'][$device['os']]['group']) {

View File

@@ -15,10 +15,3 @@ if ($icon != $device['icon']) {
$sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed Icon! : $icon\n";
}
if ($config['os'][$device['os']]['type'] != $device['type']) {
log_event('Device type changed '.$device['type'].' => '.$config['os'][$device['os']]['type'], $device, 'system');
$device['type'] = $config['os'][$device['os']]['type'];
$sql = dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed Type! : ".$device['type'].PHP_EOL;
}