From 78c2407ba64007256f61328e2c58daa3bd49cd97 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 7 Sep 2016 19:13:24 +0200 Subject: [roomplanner] Add managerip field, move mgr/tutor fields to location_roomplanner table, add to install.inc.php --- modules-available/roomplanner/page.inc.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'modules-available/roomplanner/page.inc.php') diff --git a/modules-available/roomplanner/page.inc.php b/modules-available/roomplanner/page.inc.php index 2d3b5187..8826615d 100644 --- a/modules-available/roomplanner/page.inc.php +++ b/modules-available/roomplanner/page.inc.php @@ -60,7 +60,7 @@ class Page_Roomplanner extends Page if (Request::get('pvs', false, 'bool')) { /* return a pvs-file */ echo "
";
-			echo PvsGenerator::generate($locationid);
+			echo PvsGenerator::generate();
 			echo "
"; die(); } @@ -68,12 +68,19 @@ class Page_Roomplanner extends Page if ($this->action === 'show') { /* do nothing */ Dashboard::disable(); - $furniture = $this->getFurniture(); + $config = Database::queryFirst('SELECT roomplan, managerip FROM location_roomplan WHERE locationid = :locationid', ['locationid' => $this->locationid]); + if ($config !== false) { + $managerIp = $config['managerip']; + } else { + $managerIp = ''; + } + $furniture = $this->getFurniture($config); $subnetMachines = $this->getPotentialMachines(); $machinesOnPlan = $this->getMachinesOnPlan(); $roomConfig = array_merge($furniture, $machinesOnPlan); Render::addTemplate('page', [ 'location' => $this->location, + 'managerip' => $managerIp, 'subnetMachines' => json_encode($subnetMachines), 'locationid' => $this->locationid, 'roomConfiguration' => json_encode($roomConfig)]); @@ -201,14 +208,18 @@ class Page_Roomplanner extends Page protected function saveRoomConfig($furniture) { $obj = json_encode(['furniture' => $furniture]); - Database::exec('INSERT INTO location_roomplan (locationid, roomplan) VALUES (:locationid, :roomplan) ON DUPLICATE KEY UPDATE roomplan=:roomplan', - ['locationid' => $this->locationid, - 'roomplan' => $obj]); + Database::exec('INSERT INTO location_roomplan (locationid, roomplan, managerip, tutoruuid)' + . ' VALUES (:locationid, :roomplan, :managerip, :tutoruuid)' + . ' ON DUPLICATE KEY UPDATE roomplan=VALUES(roomplan), managerip=VALUES(managerip), tutoruuid=VALUES(tutoruuid)', [ + 'locationid' => $this->locationid, + 'roomplan' => $obj, + 'managerip' => Request::post('managerip', '', 'string'), + 'tutoruuid' => '' // TODO + ]); } - protected function getFurniture() + protected function getFurniture($config) { - $config = Database::queryFirst('SELECT roomplan FROM location_roomplan WHERE locationid = :locationid', ['locationid' => $this->locationid]); if ($config === false) { return array(); } -- cgit v1.2.3-55-g7522