summaryrefslogtreecommitdiffstats
path: root/modules-available/roomplanner/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-09-07 11:39:51 +0200
committerSimon Rettberg2016-09-07 11:39:51 +0200
commit86423a7cc2f52a8f7428b8c75e7260a1f9439cda (patch)
tree82b9384451bab4604f5a5c1da721fdbe0b74b39c /modules-available/roomplanner/page.inc.php
parent[Render] Add 'ovverride' to setTitle, so it's possible to set the title only ... (diff)
downloadslx-admin-86423a7cc2f52a8f7428b8c75e7260a1f9439cda.tar.gz
slx-admin-86423a7cc2f52a8f7428b8c75e7260a1f9439cda.tar.xz
slx-admin-86423a7cc2f52a8f7428b8c75e7260a1f9439cda.zip
[roomplanner] Show location name in title
Diffstat (limited to 'modules-available/roomplanner/page.inc.php')
-rw-r--r--modules-available/roomplanner/page.inc.php38
1 files changed, 29 insertions, 9 deletions
diff --git a/modules-available/roomplanner/page.inc.php b/modules-available/roomplanner/page.inc.php
index d437fdd0..9e01eca3 100644
--- a/modules-available/roomplanner/page.inc.php
+++ b/modules-available/roomplanner/page.inc.php
@@ -6,12 +6,25 @@ class Page_Roomplanner extends Page
/**
* @var int locationid of location we're editing
*/
- private $locationid;
+ private $locationid = false;
+
+ /**
+ * @var array location data from location table
+ */
+ private $location = false;
/**
* @var string action to perform
*/
- private $action;
+ private $action = false;
+
+ private function loadRequestedLocation()
+ {
+ $this->locationid = Request::get('locationid', false, 'integer');
+ if ($this->locationid !== false) {
+ $this->location = Location::get($this->locationid);
+ }
+ }
protected function doPreprocess()
{
@@ -22,18 +35,22 @@ class Page_Roomplanner extends Page
Util::redirect('?do=Main');
}
- $this->locationid = Request::get('locationid', null, 'integer');
$this->action = Request::any('action', 'show', 'string');
-
- if ($this->locationid === null) {
+ $this->loadRequestedLocation();
+ if ($this->locationid === false) {
Message::addError('need-locationid');
Util::redirect('?do=locations');
}
+ if ($this->location === false) {
+ Message::addError('invalid-locationid');
+ Util::redirect('?do=locations');
+ }
if ($this->action === 'save') {
$this->handleSaveRequest(false);
Util::redirect("?do=roomplanner&locationid={$this->locationid}&action=show");
}
+ Render::setTitle($this->location['locationname']);
}
protected function doRender()
@@ -56,10 +73,10 @@ class Page_Roomplanner extends Page
protected function doAjax()
{
- $this->action = Request::any('action', null, 'string');
+ $this->action = Request::any('action', false, 'string');
if ($this->action === 'getmachines') {
- $query = Request::get('query', null, 'string');
+ $query = Request::get('query', false, 'string');
/* the query could be anything: UUID, IP or macaddr */
// $result = Database::simpleQuery('SELECT machineuuid, macaddr, clientip, hostname '
@@ -84,10 +101,13 @@ class Page_Roomplanner extends Page
}
echo json_encode($returnObject);
} elseif ($this->action === 'save') {
- $this->locationid = Request::any('locationid', null, 'integer');
- if ($this->locationid === null) {
+ $this->loadRequestedLocation();
+ if ($this->locationid === false) {
die('Missing locationid in save data');
}
+ if ($this->location === false) {
+ die('Location with id ' . $this->locationid . ' does not exist.');
+ }
$this->handleSaveRequest(true);
die('SUCCESS');
} else {