diff --git a/html/pages/device/edit/device.inc.php b/html/pages/device/edit/device.inc.php index 4a716d214b..acb9ad889b 100644 --- a/html/pages/device/edit/device.inc.php +++ b/html/pages/device/edit/device.inc.php @@ -78,6 +78,24 @@ if ($_POST['editing']) { print_error('Only administrative users may update the device hostname'); } } + if (isset($_POST['sysName']) && $_POST['sysName'] !== '' && $_POST['sysName'] !== $device['sysName']) { + if (is_admin()) { + $result = dbUpdate(array('sysName' => $_POST['sysName']), 'devices', '`device_id` = ?', array($device['device_id'])); + if ($result !== false) { + print_message("sysName updated from {$device['sysName']} to {$_POST['sysName']}"); + echo ' + + '; + } else { + print_error("Failed to update sysName"); + } + } else { + print_error('Only administrative users may update the device hostname'); + } + } } else { include 'includes/error-no-perm.inc.php'; } @@ -124,7 +142,16 @@ if ($updated && $update_message) { -
+
+ +
+ +
+
+ +
+
+
@@ -259,6 +286,15 @@ if ($updated && $update_message) { document.getElementById('edit-hostname-input').disabled = true; } }); + $('#sysName-edit-button').click(function(e) { + e.preventDefault(); + disabled_state = document.getElementById('edit-sysName-input').disabled; + if (disabled_state == true) { + document.getElementById('edit-sysName-input').disabled = false; + } else { + document.getElementById('edit-sysName-input').disabled = true; + } + }); $('#parent_id').select2({ width: 'resolve', tags: true,