diff options
author | Simon Rettberg | 2021-12-17 11:30:37 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-03-09 15:06:54 +0100 |
commit | ecb80fc2afed0407e9903023242a34e75fb7bde4 (patch) | |
tree | f57810f8572c91ffdb2dee51a4c10d83087a596b /modules-available/locations | |
parent | [eventlog] Add english translations (diff) | |
download | slx-admin-ecb80fc2afed0407e9903023242a34e75fb7bde4.tar.gz slx-admin-ecb80fc2afed0407e9903023242a34e75fb7bde4.tar.xz slx-admin-ecb80fc2afed0407e9903023242a34e75fb7bde4.zip |
[locations/passthrough] Make location assignment recusive
Properly show inherited passthough groups in location list,
disable inherited passthrough groups in selection dialog.
Diffstat (limited to 'modules-available/locations')
-rw-r--r-- | modules-available/locations/inc/abstractlocationcolumn.inc.php | 5 | ||||
-rw-r--r-- | modules-available/locations/pages/locations.inc.php | 23 |
2 files changed, 16 insertions, 12 deletions
diff --git a/modules-available/locations/inc/abstractlocationcolumn.inc.php b/modules-available/locations/inc/abstractlocationcolumn.inc.php index 9583429e..65224da9 100644 --- a/modules-available/locations/inc/abstractlocationcolumn.inc.php +++ b/modules-available/locations/inc/abstractlocationcolumn.inc.php @@ -16,6 +16,11 @@ abstract class AbstractLocationColumn return false; } + public function propagationOverride(string $parent, string $data): string + { + return $data; + } + public function propagateDefaultHtml(): string { return $this->getColumnHtml(0); diff --git a/modules-available/locations/pages/locations.inc.php b/modules-available/locations/pages/locations.inc.php index 0eb035c8..8ba4793e 100644 --- a/modules-available/locations/pages/locations.inc.php +++ b/modules-available/locations/pages/locations.inc.php @@ -123,7 +123,7 @@ class SubPage unset($loc); foreach ($plugins as $pk => $plugin) { if ($plugin->propagateColumn()) { - self::propagateFields($locationList, $plugin->propagateDefaultHtml(), $pk); + self::propagateFields($locationList, $plugin, $pk); } } foreach ($locationList as &$loc) { @@ -155,23 +155,22 @@ class SubPage Module::isAvailable('js_ip'); // For CIDR magic } - private static function propagateFields(array &$locationList, string $defaultValue, string $plugin) + private static function propagateFields(array &$locationList, AbstractLocationColumn $plugin, string $pluginKey) { $depth = array(); foreach ($locationList as &$loc) { $d = $loc['depth']; - if (empty($loc['plugins'][$plugin]['html'])) { + if (empty($loc['plugins'][$pluginKey]['html'])) { // Has no explicit config assignment - if ($d === 0) { - $loc['plugins'][$plugin]['html'] = $defaultValue; - } else { - $loc['plugins'][$plugin]['html'] = $depth[$d - 1]; - } - $loc['plugins'][$plugin]['class'] = 'gray'; - } elseif (empty($loc['plugins'][$plugin]['class'])) { - $loc['plugins'][$plugin]['class'] = 'slx-bold'; + $loc['plugins'][$pluginKey]['html'] = $depth[$d - 1] ?? $plugin->propagateDefaultHtml(); + $loc['plugins'][$pluginKey]['class'] = 'gray'; + } elseif (empty($loc['plugins'][$pluginKey]['class'])) { + $loc['plugins'][$pluginKey]['class'] = 'slx-bold'; + $loc['plugins'][$pluginKey]['html'] = + $plugin->propagationOverride($depth[$d - 1] ?? $plugin->propagateDefaultHtml(), + $loc['plugins'][$pluginKey]['html']); } - $depth[$d] = $loc['plugins'][$plugin]['html']; + $depth[$d] = $loc['plugins'][$pluginKey]['html']; unset($depth[$d + 1]); } } |