summaryrefslogtreecommitdiffstats
path: root/modules-available/passthrough
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
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')
-rw-r--r--modules-available/passthrough/hooks/locations-column.inc.php48
-rw-r--r--modules-available/passthrough/install.inc.php14
-rw-r--r--modules-available/passthrough/lang/de/module.json3
-rw-r--r--modules-available/passthrough/lang/en/module.json3
4 files changed, 68 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
diff --git a/modules-available/passthrough/install.inc.php b/modules-available/passthrough/install.inc.php
index e08be38b..01d3edbb 100644
--- a/modules-available/passthrough/install.inc.php
+++ b/modules-available/passthrough/install.inc.php
@@ -6,4 +6,18 @@ $result[] = tableCreate('passthrough_group', "
PRIMARY KEY (`groupid`)
");
+$result[] = tableCreate('passthrough_group_x_location', "
+ `groupid` varchar(32) CHARACTER SET ascii DEFAULT NULL,
+ `locationid` INT(11) NOT NULL,
+ PRIMARY KEY (`groupid`, `locationid`)
+");
+
+$result[] = tableAddConstraint('passthrough_group_x_location', 'groupid',
+ 'passthrough_group', 'groupid',
+ 'ON DELETE CASCADE ON UPDATE CASCADE');
+
+$result[] = tableAddConstraint('passthrough_group_x_location', 'locationid',
+ 'location', 'locationid',
+ 'ON DELETE CASCADE ON UPDATE CASCADE');
+
responseFromArray($result); \ No newline at end of file
diff --git a/modules-available/passthrough/lang/de/module.json b/modules-available/passthrough/lang/de/module.json
new file mode 100644
index 00000000..c8657ccd
--- /dev/null
+++ b/modules-available/passthrough/lang/de/module.json
@@ -0,0 +1,3 @@
+{
+ "location-column-header": "Passthrough"
+} \ No newline at end of file
diff --git a/modules-available/passthrough/lang/en/module.json b/modules-available/passthrough/lang/en/module.json
new file mode 100644
index 00000000..c8657ccd
--- /dev/null
+++ b/modules-available/passthrough/lang/en/module.json
@@ -0,0 +1,3 @@
+{
+ "location-column-header": "Passthrough"
+} \ No newline at end of file