summaryrefslogtreecommitdiffstats
path: root/modules-available/passthrough/hooks
diff options
context:
space:
mode:
authorSimon Rettberg2021-12-07 14:56:43 +0100
committerSimon Rettberg2022-03-09 15:06:54 +0100
commit7fb2e4ca050784269e78133cc5a2610e066c660f (patch)
treee614880d2f8189e33da763f70fbc9cf7d09e72cb /modules-available/passthrough/hooks
parent[eventlog] install: Fix SQL (diff)
downloadslx-admin-7fb2e4ca050784269e78133cc5a2610e066c660f.tar.gz
slx-admin-7fb2e4ca050784269e78133cc5a2610e066c660f.tar.xz
slx-admin-7fb2e4ca050784269e78133cc5a2610e066c660f.zip
[statistics/passthrough] Consider group<->location mapping for KCL
Diffstat (limited to 'modules-available/passthrough/hooks')
-rw-r--r--modules-available/passthrough/hooks/locations-column.inc.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/modules-available/passthrough/hooks/locations-column.inc.php b/modules-available/passthrough/hooks/locations-column.inc.php
new file mode 100644
index 00000000..9757ac50
--- /dev/null
+++ b/modules-available/passthrough/hooks/locations-column.inc.php
@@ -0,0 +1,48 @@
+<?php
+
+if (!User::hasPermission('.passthrough.view')) {
+ return null;
+}
+
+class PassthroughLocationColumn extends AbstractLocationColumn
+{
+
+ private $lookup;
+
+ public function __construct(array $allowedLocationIds)
+ {
+ $this->lookup = Database::queryKeyValueList("SELECT gxl.locationid, GROUP_CONCAT(gxl.groupid SEPARATOR ', ') AS grps
+ FROM passthrough_group_x_location gxl
+ WHERE locationid IN (:allowedLocationIds) GROUP BY locationid", compact('allowedLocationIds'));
+ }
+
+ public function getColumnHtml(int $locationId): string
+ {
+ return htmlspecialchars($this->lookup[$locationId] ?? '');
+ }
+
+ public function getEditUrl(int $locationId): string
+ {
+ if (!User::hasPermission('.passthrough.assign', $locationId))
+ return '';
+ return '?do=passthrough&show=assignlocation&locationid=' . $locationId;
+ }
+
+ public function header(): string
+ {
+ return Dictionary::translateFileModule('passthrough', 'module', 'location-column-header');
+ }
+
+ public function priority(): int
+ {
+ return 4000;
+ }
+
+ public function propagateColumn(): bool
+ {
+ return true;
+ }
+
+}
+
+return new PassthroughLocationColumn($allowedLocationIds); \ No newline at end of file