summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2026-01-20 15:52:04 +0100
committerSimon Rettberg2026-01-20 15:52:04 +0100
commit24f5c388cd1246074bf5d39c5a0c484d0d625d80 (patch)
treea961f7bbc10d62b30e43ecbf898818cc21660287 /modules-available
parentIntelliJ: Mark Testdir (diff)
downloadslx-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')
-rw-r--r--modules-available/locationinfo/api.inc.php24
-rw-r--r--modules-available/locationinfo/inc/locationinfo.inc.php1
-rw-r--r--modules-available/locationinfo/install.inc.php12
-rw-r--r--modules-available/locationinfo/lang/de/panel-params.json2
-rw-r--r--modules-available/locationinfo/lang/de/template-tags.json2
-rw-r--r--modules-available/locationinfo/lang/en/panel-params.json2
-rw-r--r--modules-available/locationinfo/lang/en/template-tags.json2
-rw-r--r--modules-available/locationinfo/page.inc.php15
-rw-r--r--modules-available/locationinfo/templates/page-config-panel-default.html17
-rw-r--r--modules-available/locationinfo/templates/page-panels.html4
10 files changed, 74 insertions, 7 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index 1a3bd76e..cd2ffd5a 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -42,6 +42,8 @@ function HandleParameters()
$output = LocationInfo::getCalendar($locationIds, time() + 3);
} elseif ($get === "manifest") {
$output = generateManifest($uuid);
+ } elseif ($get === 'list') {
+ $output = generatePublicPanelList();
}
if ($output !== null) {
Header('Content-Type: application/json; charset=utf-8');
@@ -170,4 +172,26 @@ function generateManifest(string $uuid): array
];
}
return $data;
+}
+
+function generatePublicPanelList(): array
+{
+ $base = Util::shouldRedirectDomain();
+ if ($base !== null) {
+ $base = 'https://' . $base;
+ } else {
+ $base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
+ }
+ $result = [
+ 'server_name' => 'To be filled by O.E.M.',
+ 'panels' => [],
+ ];
+ $res = Database::simpleQuery("SELECT paneluuid, panelname FROM locationinfo_panel WHERE ispublic = 1");
+ foreach ($res as $row) {
+ $result['panels'][] = [
+ 'title' => $row['panelname'],
+ 'url' => $base . '/panel/' . $row['paneluuid'],
+ ];
+ }
+ return $result;
} \ No newline at end of file
diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php
index 511ed3ea..6cef3337 100644
--- a/modules-available/locationinfo/inc/locationinfo.inc.php
+++ b/modules-available/locationinfo/inc/locationinfo.inc.php
@@ -268,6 +268,7 @@ class LocationInfo
$params['string'] = array_reverse($params['string'], true);
$params['string']['panelname'] = [];
$params['string'] = array_reverse($params['string'], true);
+ $params['bool']['ispublic'] = ['section' => 'general'];
$sections = [];
foreach ($params as $varType => $options) {
foreach ($options as $key => $properties) {
diff --git a/modules-available/locationinfo/install.inc.php b/modules-available/locationinfo/install.inc.php
index 732ea6e9..f4bbca1c 100644
--- a/modules-available/locationinfo/install.inc.php
+++ b/modules-available/locationinfo/install.inc.php
@@ -30,6 +30,7 @@ $t3 = $res[] = tableCreate('locationinfo_panel', "
`paneltype` enum('DEFAULT', 'SUMMARY', 'URL', 'UPCOMING') NOT NULL,
`panelconfig` blob NOT NULL,
`lastchange` int(10) UNSIGNED NOT NULL DEFAULT 0,
+ `ispublic` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`paneluuid`),
KEY `panelname` (`panelname`)
");
@@ -103,7 +104,7 @@ if (tableGetConstraints('locationinfo_backendlog', 'serverid',
'locationinfo_coursebackend', 'serverid', 'ON UPDATE CASCADE ON DELETE CASCADE');
}
-// 2025-06-17: Make locationds text column
+// 2025-06-17: Make locationids text column
if (stripos(tableColumnType('locationinfo_panel', 'locationids'), 'text') === false) {
if (Database::exec('ALTER TABLE `locationinfo_panel` MODIFY `locationids` text CHAR SET ascii NOT NULL')) {
$res[] = UPDATE_DONE;
@@ -112,6 +113,15 @@ if (stripos(tableColumnType('locationinfo_panel', 'locationids'), 'text') === fa
}
}
+// 2025-12-12: Add "public" column
+if (!tableHasColumn('locationinfo_panel', 'ispublic')) {
+ if (Database::exec('ALTER TABLE `locationinfo_panel` ADD `ispublic` tinyint(1) NOT NULL DEFAULT 0') !== false) {
+ $res[] = UPDATE_DONE;
+ } else {
+ $res[] = UPDATE_FAILED;
+ }
+}
+
// Create response for browser
if (in_array(UPDATE_RETRY, $res)) {
diff --git a/modules-available/locationinfo/lang/de/panel-params.json b/modules-available/locationinfo/lang/de/panel-params.json
index 1830a93c..adbac0c9 100644
--- a/modules-available/locationinfo/lang/de/panel-params.json
+++ b/modules-available/locationinfo/lang/de/panel-params.json
@@ -32,6 +32,8 @@
"intro-SUMMARY": "Hier k\u00f6nnen Sie ein \u00dcbersichts-Panel definieren. Das Panel zeigt eine \u00dcbersicht der in den R\u00e4umen enthalten PCs.",
"intro-UPCOMING": "Eine Anzeigetafel, die die n\u00e4chsten Veranstaltungen in einem oder mehreren R\u00e4umen anzeigt. Die Veranstaltungen werden chronologisch aufsteigend untereinander angezeigt, mit Start- und Endzeit.",
"intro-URL": "unused",
+ "ispublic": "\u00d6ffentlich",
+ "ispublic_helptext": "Wenn aktiviert, erscheint dieses Panel in der \u00f6ffentlich abfragbaren Liste aller Infotafeln",
"language": "Sprache",
"language-system": "Systemsprache bevorzugen",
"language-system_helptext": "Sofern unterst\u00fctzt, wird das Panel in der Sprache ausgeliefert, die der Browser des Users anfordert",
diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json
index e4c8d4e3..6ffa8cd7 100644
--- a/modules-available/locationinfo/lang/de/template-tags.json
+++ b/modules-available/locationinfo/lang/de/template-tags.json
@@ -42,6 +42,8 @@
"lang_goToLocation": "Gehe zu Raum",
"lang_goToLocationWarning": "Weiterleitung zum Raum-Modul",
"lang_hostnameTooltip": "Zeige kurzen Hostnamen in Rechner-Piktogramm",
+ "lang_isPublic": "\u00d6ffentlich",
+ "lang_isPublicTooltip": "Wenn aktiviert, erscheint dieses Panel in der \u00f6ffentlich abfragbaren Liste aller Infotafeln",
"lang_language": "Sprache",
"lang_languageTooltip": "Legt die Sprache der angezeigten Oberfl\u00e4che fest",
"lang_lastCalendarUpdate": "Kalender Update",
diff --git a/modules-available/locationinfo/lang/en/panel-params.json b/modules-available/locationinfo/lang/en/panel-params.json
index 257e44a1..21c5385b 100644
--- a/modules-available/locationinfo/lang/en/panel-params.json
+++ b/modules-available/locationinfo/lang/en/panel-params.json
@@ -32,6 +32,8 @@
"intro-SUMMARY": "Here you can define a summary panel which shows a overview of clients in your locations.",
"intro-UPCOMING": "Panel that shows active and upcoming events in one or more locations. Events will be shown in ascending order.",
"intro-URL": "unused",
+ "ispublic": "Public",
+ "ispublic_helptext": "Show this panel in publicly accessible list of info panels",
"language": "Language",
"language-system": "Prefer system language",
"language-system_helptext": "If supported, the panel will be displayed in the language the user's browser requested",
diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json
index 46d4d144..9c945692 100644
--- a/modules-available/locationinfo/lang/en/template-tags.json
+++ b/modules-available/locationinfo/lang/en/template-tags.json
@@ -42,6 +42,8 @@
"lang_goToLocation": "GoTo Location",
"lang_goToLocationWarning": "Forward to Location-Module",
"lang_hostnameTooltip": "Show simple hostname inside computer icon",
+ "lang_isPublic": "Public",
+ "lang_isPublicTooltip": "Show this panel in publicly accessible list of info panels",
"lang_language": "Language",
"lang_languageTooltip": "The language the frontend uses",
"lang_lastCalendarUpdate": "Calendar update",
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
diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html
index cba66745..d5275453 100644
--- a/modules-available/locationinfo/templates/page-config-panel-default.html
+++ b/modules-available/locationinfo/templates/page-config-panel-default.html
@@ -134,6 +134,23 @@
</div>
</div>
</div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-sm-4">
+ <label for="input-ispublic">{{lang_isPublic}}</label>
+ </div>
+ <div class="col-sm-8">
+ <div class="checkbox">
+ <input id="input-ispublic" type="checkbox" name="ispublic" {{ispublic_checked}}>
+ <label></label>
+ </div>
+ </div>
+ <div class="col-sm-12 small text-muted spacebottop">
+ {{lang_isPublicTooltip}}
+ </div>
+ </div>
+ </div>
</div>
</div>
</div>
diff --git a/modules-available/locationinfo/templates/page-panels.html b/modules-available/locationinfo/templates/page-panels.html
index 1f428cc6..8025fcd7 100644
--- a/modules-available/locationinfo/templates/page-panels.html
+++ b/modules-available/locationinfo/templates/page-panels.html
@@ -9,6 +9,7 @@
<thead>
<tr>
<th>{{lang_panel}}</th>
+ <th>{{lang_isPublic}}</th>
<th>{{lang_panelType}}</th>
<th>{{lang_locations}}</th>
{{#hasRunmode}}
@@ -25,6 +26,9 @@
<a href="/panel/{{paneluuid}}" target="_blank">{{panelname}}</a>
</td>
<td>
+ {{#ispublic}}<span class="glyphicon glyphicon-ok"></span>{{/ispublic}}
+ </td>
+ <td>
{{paneltype}}
</td>
<td>