diff options
author | Simon Rettberg | 2021-03-04 15:39:30 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-03-04 15:39:30 +0100 |
commit | 6e423f87e0c8fa14c0e2d726c0db2dad40690449 (patch) | |
tree | e10f9beff1a7ebd9d0e1cc078ee81ed0089d552d /modules-available | |
parent | [statistics] Better check if locationid trigger exists (diff) | |
download | slx-admin-6e423f87e0c8fa14c0e2d726c0db2dad40690449.tar.gz slx-admin-6e423f87e0c8fa14c0e2d726c0db2dad40690449.tar.xz slx-admin-6e423f87e0c8fa14c0e2d726c0db2dad40690449.zip |
[roomplanner] Formatting, comments
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/roomplanner/page.inc.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/modules-available/roomplanner/page.inc.php b/modules-available/roomplanner/page.inc.php index 529dca40..8c3beace 100644 --- a/modules-available/roomplanner/page.inc.php +++ b/modules-available/roomplanner/page.inc.php @@ -79,7 +79,9 @@ class Page_Roomplanner extends Page private function showLeafEditor() { - $config = Database::queryFirst('SELECT roomplan, managerip, tutoruuid FROM location_roomplan WHERE locationid = :locationid', ['locationid' => $this->locationid]); + $config = Database::queryFirst('SELECT roomplan, managerip, tutoruuid + FROM location_roomplan + WHERE locationid = :locationid', ['locationid' => $this->locationid]); $runmode = RunMode::getForMode(Page::getModule(), $this->locationid, true); if (empty($runmode)) { $config['dedicatedmgr'] = false; @@ -109,7 +111,9 @@ class Page_Roomplanner extends Page 'locationid' => $this->locationid, 'roomConfiguration' => json_encode($roomConfig), 'edit_disabled' => $canEdit ? '' : 'disabled', - 'statistics_disabled' => Module::get('statistics') !== false && User::hasPermission('.statistics.machine.view-details') ? '' : 'disabled', + 'statistics_disabled' => + (Module::get('statistics') !== false && User::hasPermission('.statistics.machine.view-details')) + ? '' : 'disabled', ]; Render::addTemplate('header', $params); if ($canEdit) { @@ -122,9 +126,10 @@ class Page_Roomplanner extends Page private function showComposedEditor() { // Load settings - $row = Database::queryFirst("SELECT locationid, roomplan FROM location_roomplan WHERE locationid = :lid", [ - 'lid' => $this->locationid, - ]); + $row = Database::queryFirst("SELECT locationid, roomplan + FROM location_roomplan + WHERE locationid = :lid", + ['lid' => $this->locationid]); $room = new ComposedRoom($row); $params = [ 'location' => $this->location, @@ -161,7 +166,7 @@ class Page_Roomplanner extends Page $this->action = Request::any('action', false, 'string'); if ($this->action === 'getmachines') { - + // Load suggestions when typing in the search box of the "add machine" pop-up User::load(); $locations = User::getAllowedLocations('edit'); if (empty($locations)) { @@ -202,6 +207,7 @@ class Page_Roomplanner extends Page } echo json_encode($returnObject); } elseif ($this->action === 'save') { + // Save roomplan - give feedback if it failed so the window can stay open $this->loadRequestedLocation(); if ($this->locationid === false) { die('Missing locationid in save data'); @@ -292,11 +298,15 @@ class Page_Roomplanner extends Page } } + /** + * @param array $computers Deserialized json from browser with all the computers + * @param array $oldComputers Deserialized old roomplan from database, used to find removed computers + */ protected function saveComputerConfig($computers, $oldComputers) { $oldUuids = []; - /* collect all uuids from the old computers */ + /* collect all uuids from the old roomplan */ foreach ($oldComputers['computers'] as $c) { $oldUuids[] = $c['muuid']; } @@ -329,6 +339,7 @@ class Page_Roomplanner extends Page ['locationid' => $this->locationid, 'muuid' => $computer['muuid'], 'position' => $position]); } + // Get all computers that were removed from the roomplan and reset their data in DB $toDelete = array_diff($oldUuids, $newUuids); foreach ($toDelete as $d) { @@ -377,7 +388,9 @@ class Page_Roomplanner extends Page protected function getMachinesOnPlan($tutorUuid) { - $result = Database::simpleQuery('SELECT machineuuid, macaddr, clientip, hostname, position FROM machine WHERE fixedlocationid = :locationid', + $result = Database::simpleQuery('SELECT machineuuid, macaddr, clientip, hostname, position + FROM machine + WHERE fixedlocationid = :locationid', ['locationid' => $this->locationid]); $machines = []; while ($row = $result->fetch(PDO::FETCH_ASSOC)) { |