From 7fb2e4ca050784269e78133cc5a2610e066c660f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 7 Dec 2021 14:56:43 +0100 Subject: [statistics/passthrough] Consider group<->location mapping for KCL --- .../passthrough/hooks/locations-column.inc.php | 48 ++++++++++++++++++++++ modules-available/passthrough/install.inc.php | 14 +++++++ modules-available/passthrough/lang/de/module.json | 3 ++ modules-available/passthrough/lang/en/module.json | 3 ++ 4 files changed, 68 insertions(+) create mode 100644 modules-available/passthrough/hooks/locations-column.inc.php create mode 100644 modules-available/passthrough/lang/de/module.json create mode 100644 modules-available/passthrough/lang/en/module.json (limited to 'modules-available/passthrough') 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 @@ +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 -- cgit v1.2.3-55-g7522