summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-14 23:30:07 +0200
committerSimon Rettberg2017-04-14 23:30:07 +0200
commitcbf219539b6202cc485b9580977ba4459393ca68 (patch)
tree1505dd7036dae903c0762053583f7438b080b820 /modules-available/locationinfo/page.inc.php
parent[locationinfo] page.inc.php: More simplification, error checks, formatting (diff)
downloadslx-admin-cbf219539b6202cc485b9580977ba4459393ca68.tar.gz
slx-admin-cbf219539b6202cc485b9580977ba4459393ca68.tar.xz
slx-admin-cbf219539b6202cc485b9580977ba4459393ca68.zip
[locationinfo] Remove more dead code, refactor javascript,
... and fix a few bugs I introduced
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
-rw-r--r--modules-available/locationinfo/page.inc.php47
1 files changed, 15 insertions, 32 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index 2408a491..d5f98cce 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -23,14 +23,17 @@ class Page_LocationInfo extends Page
$this->updateOpeningTimeEasy();
} elseif ($this->action === 'updateConfig') {
$this->updateLocationConfig();
- } elseif ($this->action === 'updateServer') {
- $this->updateServer();
} elseif ($this->action === 'deleteServer') {
$this->deleteServer();
} elseif ($this->action === 'checkConnection') {
- $this->checkConnection();
+ $this->checkConnection(Request::post('serverid', 0, 'int'));
} elseif ($this->action === 'updateServerSettings') {
$this->updateServerSettings();
+ } elseif (Request::isPost()) {
+ Messages::addWarning('main.invalid-action', $this->action);
+ }
+ if (Request::isPost()) {
+ Util::redirect('?do=locationinfo');
}
}
@@ -43,35 +46,15 @@ class Page_LocationInfo extends Page
}
/**
- * Updates the server in the db.
- */
- private function updateServer()
- {
- $id = Request::post('id', 0, 'int');
- if ($id == 0) {
- Database::exec("INSERT INTO `setting_location_info` (servername, serverurl, servertype) VALUES (:name, :url, :type)",
- array('name' => Request::post('name', '', 'string'),
- 'url' => Request::post('url', '', 'string'),
- 'type' => Request::post('type', '', 'string')));
- } else {
- Database::exec("UPDATE setting_location_info SET servername = :name, serverurl = :url, servertype = :type
- WHERE serverid = :id", array(
- 'id' => $id,
- 'name' => Request::post('name', '', 'string'),
- 'url' => Request::post('url', '', 'string'),
- 'type' => Request::post('type', '', 'string')
- ));
- }
-
- $this->checkConnection();
- }
-
- /**
* Deletes the server from the db.
*/
private function deleteServer()
{
- $id = Request::post('id', 0, 'int');
+ $id = Request::post('serverid', false, 'int');
+ if ($id === false) {
+ Messages::addError('server-id-missing');
+ return;
+ }
Database::exec("DELETE FROM `setting_location_info` WHERE serverid=:id", array('id' => $id));
}
@@ -141,7 +124,6 @@ class Page_LocationInfo extends Page
$counter++;
}
$params = array(
- 'id' => $serverid,
'name' => $servername,
'url' => $serverurl,
'type' => $servertype,
@@ -152,6 +134,7 @@ class Page_LocationInfo extends Page
VALUES (:name, :url, :type, :credentials)', $params);
$this->checkConnection(Database::lastInsertId());
} else {
+ $params['id'] = $serverid;
Database::exec('UPDATE `setting_location_info`
SET servername = :name, serverurl = :url, servertype = :type, credentials = :credentials
WHERE serverid = :id', $params);
@@ -268,13 +251,13 @@ class Page_LocationInfo extends Page
2 => array("Sunday"),
);
foreach ($blocks as $idx => $days) {
- if (!empty($openingtime[$idx]) && !empty($closingtime[$idx])) {
+ //if (!empty($openingtime[$idx]) && !empty($closingtime[$idx])) {
$result[] = array(
'days' => $days,
'openingtime' => $openingtime[$idx],
'closingtime' => $closingtime[$idx],
);
- }
+ //}
}
Database::exec("INSERT INTO `location_info` (locationid, openingtime)
@@ -577,7 +560,7 @@ class Page_LocationInfo extends Page
{
$row = Database::queryFirst("SELECT openingtime FROM `location_info` WHERE locationid = :id", array('id' => $id));
if ($row !== false) {
- $openingtimes = json_decode($dbdata['openingtime'], true);
+ $openingtimes = json_decode($row['openingtime'], true);
}
if (!is_array($openingtimes)) {
$openingtimes = array();