From 41612c4481111969367d1a228ad4875d781558a2 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 30 Nov 2021 15:27:59 +0100 Subject: [locations] Modularize additional column handling Additional columns are now added through a hook, moving specialized code where it belongs. --- .../sysconfig/hooks/locations-column.inc.php | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 modules-available/sysconfig/hooks/locations-column.inc.php (limited to 'modules-available/sysconfig/hooks/locations-column.inc.php') diff --git a/modules-available/sysconfig/hooks/locations-column.inc.php b/modules-available/sysconfig/hooks/locations-column.inc.php new file mode 100644 index 00000000..f60a852d --- /dev/null +++ b/modules-available/sysconfig/hooks/locations-column.inc.php @@ -0,0 +1,57 @@ +lookup[$locId] = $conf['title']; + } + } + } + + public function getColumnHtml(int $locationId): string + { + return htmlspecialchars($this->lookup[$locationId] ?? ''); + } + + public function getEditUrl(int $locationId): string + { + if (!User::hasPermission('.sysconfig.config.assign', $locationId)) + return ''; + return '?do=sysconfig&locationid=' . $locationId; + } + + public function header(): string + { + return Dictionary::translateFileModule('sysconfig', 'module', 'location-column-header'); + } + + public function priority(): int + { + return 2000; + } + + public function propagateColumn(): bool + { + return true; + } + + public function propagateDefaultHtml(): string + { + return htmlspecialchars($this->lookup[0] ?? ''); + } +} + +return new SysconfigLocationColumn(); \ No newline at end of file -- cgit v1.2.3-55-g7522