diff options
| author | Simon Rettberg | 2026-01-20 15:52:04 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2026-01-20 15:52:04 +0100 |
| commit | 24f5c388cd1246074bf5d39c5a0c484d0d625d80 (patch) | |
| tree | a961f7bbc10d62b30e43ecbf898818cc21660287 /modules-available/locationinfo/page.inc.php | |
| parent | IntelliJ: Mark Testdir (diff) | |
| download | slx-admin-24f5c388cd1246074bf5d39c5a0c484d0d625d80.tar.gz slx-admin-24f5c388cd1246074bf5d39c5a0c484d0d625d80.tar.xz slx-admin-24f5c388cd1246074bf5d39c5a0c484d0d625d80.zip | |
[locationinfo] Add panel query API, add option to mark panels as public
This adds the option to query a JSON of all available info panels.
In addition, info panels can be marked as public/private, and only
public panels will be returned in the JSON.
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
| -rw-r--r-- | modules-available/locationinfo/page.inc.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 2953f90b..3db6d216 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -239,7 +239,6 @@ class Page_LocationInfo extends Page // Check panel type $paneltype = Request::post('ptype', false, 'string'); -//Refactored Code switch ($paneltype) { case 'DEFAULT': $params = $this->preparePanelConfigDefault(); @@ -264,11 +263,11 @@ class Page_LocationInfo extends Page if ($paneluuid === 'new') { $paneluuid = Util::randomUuid(); - $query = "INSERT INTO `locationinfo_panel` (paneluuid, panelname, locationids, paneltype, panelconfig, lastchange) - VALUES (:id, :name, :locationids, :type, :config, :now)"; + $query = "INSERT INTO `locationinfo_panel` (paneluuid, panelname, locationids, paneltype, panelconfig, lastchange, ispublic) + VALUES (:id, :name, :locationids, :type, :config, :now, :ispublic)"; } else { $query = "UPDATE `locationinfo_panel` - SET panelname = :name, locationids = :locationids, paneltype = :type, panelconfig = :config, lastchange = :now + SET panelname = :name, locationids = :locationids, paneltype = :type, panelconfig = :config, lastchange = :now, ispublic = :ispublic WHERE paneluuid = :id"; } $params['id'] = $paneluuid; @@ -277,6 +276,7 @@ class Page_LocationInfo extends Page $params['now'] = time(); $params['config'] = json_encode($params['config']); $params['locationids'] = implode(',', $params['locationids']); + $params['ispublic'] = Request::post('ispublic', false, 'bool'); Database::exec($query, $params); Message::addSuccess('config-saved'); @@ -560,7 +560,7 @@ class Page_LocationInfo extends Page return; } $res = Database::simpleQuery('SELECT p.paneluuid, p.panelname, p.locationids, p.panelconfig, - p.paneltype FROM locationinfo_panel p + p.paneltype, p.ispublic FROM locationinfo_panel p ORDER BY panelname ASC'); $hasRunmode = Module::isAvailable('runmode'); if ($hasRunmode) { @@ -858,11 +858,12 @@ class Page_LocationInfo extends Page $panel = [ 'paneltype' => substr($id, 4), 'panelname' => '', + 'ispublic' => false, ]; $id = 'new'; } else { // Get Config data from db - $panel = Database::queryFirst("SELECT panelname, locationids, paneltype, panelconfig + $panel = Database::queryFirst("SELECT panelname, locationids, paneltype, panelconfig, ispublic FROM locationinfo_panel WHERE paneluuid = :id", array('id' => $id)); if ($panel === false) { @@ -886,6 +887,7 @@ class Page_LocationInfo extends Page $config += $def; } $config['panelname'] = $panel['panelname']; + $config['ispublic'] = $panel['ispublic']; $configData = LocationInfo::getEditTemplateData($panel['paneltype'], $config); LocationInfo::makeCheckedProperties($panel['paneltype'], $config); @@ -900,6 +902,7 @@ class Page_LocationInfo extends Page 'locations' => Location::getLocations(), 'locationids' => $panel['locationids'] ?? '', 'overrides' => json_encode($config['overrides']), + 'ispublic_checked' => $config['ispublic'] ? 'checked' : '', ] + $config); } elseif ($panel['paneltype'] === 'URL') { // Bookmarks are handled differently |
