From b4da5de452fa0c5dedc752c406848c835630302b Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 14 Feb 2017 12:56:16 +0000 Subject: [PATCH] refactor: Centralised the updating of device logo #5873 (#5874) --- includes/discovery/os.inc.php | 8 +------- includes/functions.php | 11 +++++++++++ includes/polling/os.inc.php | 5 +---- includes/polling/os/radlan.inc.php | 1 - 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/includes/discovery/os.inc.php b/includes/discovery/os.inc.php index e29c43eb46..a24e719f02 100644 --- a/includes/discovery/os.inc.php +++ b/includes/discovery/os.inc.php @@ -8,10 +8,4 @@ if ($os != $device['os']) { echo "Changed OS! : $os\n"; } -$icon = getImageName($device, false); -if ($icon != $device['icon']) { - log_event('Device Icon changed ' . $device['icon'] . " => $icon", $device, 'system', 3); - $device['icon'] = $icon; - $sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id'])); - echo "Changed Icon! : $icon\n"; -} +update_device_logo($device); diff --git a/includes/functions.php b/includes/functions.php index 8b738c881c..c25ef6c76f 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1993,3 +1993,14 @@ function recordSnmpStatistic($stat, $start_time) $snmp_stats["${stat}_sec"] += $runtime; return $runtime; } + +function update_device_logo($device) +{ + $icon = getImageName($device, false); + if ($icon != $device['icon']) { + log_event('Device Icon changed ' . $device['icon'] . " => $icon", $device, 'system', 3); + $device['icon'] = $icon; + $sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id'])); + echo "Changed Icon! : $icon\n"; + } +} diff --git a/includes/polling/os.inc.php b/includes/polling/os.inc.php index 5154cb8976..5e162b2f05 100644 --- a/includes/polling/os.inc.php +++ b/includes/polling/os.inc.php @@ -30,10 +30,7 @@ if ($serial != $device['serial']) { log_event('Serial -> ' . $serial, $device, 'system', 3); } -if ($icon != $device['icon']) { - $update_array['icon'] = $icon; - log_event('Icon -> ' . $icon, $device, 'system', 3); -} +update_device_logo($device); echo 'Hardware: ' . $hardware . PHP_EOL; echo 'Version: ' . $version . PHP_EOL; diff --git a/includes/polling/os/radlan.inc.php b/includes/polling/os/radlan.inc.php index 2935cc92df..8721a28d8f 100644 --- a/includes/polling/os/radlan.inc.php +++ b/includes/polling/os/radlan.inc.php @@ -2,7 +2,6 @@ $version = snmp_get($device, 'rndBrgVersion.0', '-Ovq', 'RADLAN-MIB'); $hardware = str_replace('ATI', 'Allied Telesis', $poll_device['sysDescr']); -$icon = 'allied'; $features = snmp_get($device, 'rndBaseBootVersion.00', '-Ovq', 'RADLAN-MIB');