diff options
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
-rw-r--r-- | modules-available/locationinfo/page.inc.php | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index f8aa1c5b..c6aa0860 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -223,14 +223,14 @@ class Page_LocationInfo extends Page if ($locationids === false) { if (!$failIfEmpty) return array(); - Message::addError('main.paramter-missing', 'locationids'); + Message::addError('main.parameter-missing', 'locationids'); Util::redirect('?do=locationinfo'); } $locationids = explode(',', $locationids); $all = array_map(function ($item) { return $item['locationid']; }, Location::queryLocations()); $locationids = array_filter($locationids, function ($item) use ($all) { return in_array($item, $all); }); if ($failIfEmpty && empty($locationids)) { - Message::addError('main.paramter-empty', 'locationids'); + Message::addError('main.parameter-empty', 'locationids'); Util::redirect('?do=locationinfo'); } return $locationids; @@ -254,11 +254,14 @@ class Page_LocationInfo extends Page $params = $this->preparePanelConfigDefault(); } elseif ($paneltype === 'URL') { $params = $this->preparePanelConfigUrl(); + } elseif ($paneltype === 'SUMMARY') { + $params = $this->preparePanelConfigSummary(); } else { Message::addError('invalid-panel-type', $paneltype); Util::redirect('?do=locationinfo'); } + if ($paneluuid === 'new') { $paneluuid = Util::randomUuid(); $query = "INSERT INTO `locationinfo_panel` (paneluuid, panelname, locationids, paneltype, panelconfig, lastchange) @@ -320,6 +323,13 @@ class Page_LocationInfo extends Page return array('config' => $conf, 'locationids' => []); } + private function preparePanelConfigSummary() + { + // Check locations + $locationids = self::getLocationIdsFromRequest(true); + return array('locationids' => $locationids); + } + /** * Updates the server settings in the db. */ @@ -331,7 +341,7 @@ class Page_LocationInfo extends Page $backend = CourseBackend::getInstance($servertype); if ($backend === false) { - Messages::addError('invalid-backend-type', $servertype); + Message::addError('invalid-backend-type', $servertype); Util::redirect('?do=locationinfo'); } @@ -439,7 +449,7 @@ class Page_LocationInfo extends Page $locations = Location::getLocations(0, 0, false, true); // Get hidden state of all locations - $dbquery = Database::simpleQuery("SELECT li.locationid, li.serverid, li.serverlocationid, li.openingtime, li.lastcalendarupdate, cb.servername + $dbquery = Database::simpleQuery("SELECT li.locationid, li.serverid, li.serverlocationid, li.openingtime, li.lastcalendarupdate, cb.servertype, cb.servername FROM `locationinfo_locationconfig` AS li LEFT JOIN `locationinfo_coursebackend` AS cb USING (serverid)"); @@ -456,6 +466,7 @@ class Page_LocationInfo extends Page 'openingGlyph' => $glyph, 'backend' => $backend, 'lastCalendarUpdate' => $row['lastcalendarupdate'], // TODO + 'backendMissing' => !CourseBackend::exists($row['servertype']), ); } @@ -582,7 +593,7 @@ class Page_LocationInfo extends Page /** * Ajax the time table * - * @param $id id of the location + * @param int $id id of the location */ private function ajaxConfigLocation($id) { @@ -798,9 +809,11 @@ class Page_LocationInfo extends Page } $langs = Dictionary::getLanguages(true); - foreach ($langs as &$lang) { - if ($lang['cc'] === $config['language']) { - $lang['selected'] = 'selected'; + if (isset($config['language'])) { + foreach ($langs as &$lang) { + if ($lang['cc'] === $config['language']) { + $lang['selected'] = 'selected'; + } } } @@ -832,7 +845,7 @@ class Page_LocationInfo extends Page 'url' => $config['url'], 'ssl_checked' => $config['insecure-ssl'] ? 'checked' : '', )); - } else { // TODO + } else { Render::addTemplate('page-config-panel-summary', array( 'new' => $id === 'new', 'uuid' => $id, @@ -862,19 +875,37 @@ class Page_LocationInfo extends Page Util::redirect($config['url']); } - $data = array( - 'uuid' => $uuid, - 'config' => json_encode($config), - 'language' => $config['language'], - ); - + $data = array(); preg_match('#^(.*)/#', $_SERVER['PHP_SELF'], $script); preg_match('#^([^?]+)/#', $_SERVER['REQUEST_URI'], $request); if ($script[1] !== $request[1]) { $data['dirprefix'] = $script[1] . '/'; } - echo Render::parse('frontend-default', $data); + if ($type === 'DEFAULT') { + $data += array( + 'uuid' => $uuid, + 'config' => json_encode($config), + 'language' => $config['language'], + ); + + die(Render::parse('frontend-default', $data)); + } + + if ($type === 'SUMMARY') { + $locations = LocationInfo::getLocationsOr404($uuid, false); + $config['tree'] = Location::getRecursive($locations); + $data += array( + 'uuid' => $uuid, + 'config' => json_encode($config), + 'language' => $config['language'], + ); + + die(Render::parse('frontend-summary', $data)); + } + + http_response_code(500); + die('Unknown panel type ' . $type); } } |