summaryrefslogtreecommitdiffstats
path: root/modules-available/baseconfig
diff options
context:
space:
mode:
authorSimon Rettberg2019-10-31 15:15:03 +0100
committerSimon Rettberg2019-10-31 15:15:03 +0100
commite18b0b0c764652d6f77465082eb474330f43915b (patch)
tree7f3a3e588cc6a5f6a9d4c1c02a615d1ab3cb1c98 /modules-available/baseconfig
parent[statistics] Don't try to show room plan for non-leaf rooms (diff)
downloadslx-admin-e18b0b0c764652d6f77465082eb474330f43915b.tar.gz
slx-admin-e18b0b0c764652d6f77465082eb474330f43915b.tar.xz
slx-admin-e18b0b0c764652d6f77465082eb474330f43915b.zip
[statistics/baseconfig] Allow per-machine configvar overrides
Diffstat (limited to 'modules-available/baseconfig')
-rw-r--r--modules-available/baseconfig/inc/validator.inc.php2
-rw-r--r--modules-available/baseconfig/page.inc.php24
2 files changed, 13 insertions, 13 deletions
diff --git a/modules-available/baseconfig/inc/validator.inc.php b/modules-available/baseconfig/inc/validator.inc.php
index 2dfeed7c..60cda5a4 100644
--- a/modules-available/baseconfig/inc/validator.inc.php
+++ b/modules-available/baseconfig/inc/validator.inc.php
@@ -47,7 +47,7 @@ class Validator
* Otherwise it it assumed that the value is a plain text
* password that is supposed to be hashed.
*/
- private static function linuxPassword(&$displayValue)
+ private static function linuxPassword($displayValue)
{
if (empty($displayValue))
return '';
diff --git a/modules-available/baseconfig/page.inc.php b/modules-available/baseconfig/page.inc.php
index 837a3b67..0c11d5e1 100644
--- a/modules-available/baseconfig/page.inc.php
+++ b/modules-available/baseconfig/page.inc.php
@@ -23,11 +23,7 @@ class Page_BaseConfig extends Page
$newValues = Request::post('setting');
if (is_array($newValues)) {
- if ($this->targetModule === 'locations') {
- User::assertPermission('edit', $this->qry_extra['field_value']);
- } else {
- User::assertPermission('edit', 0);
- }
+ User::assertPermission('edit', $this->getPermissionLocationId());
// Build variables for specific sub-settings
if ($this->targetModule === false || empty($this->qry_extra['field'])) {
// Global, or Module specific, but module doesn't have an extra field
@@ -118,13 +114,9 @@ class Page_BaseConfig extends Page
Util::redirect('?do=BaseConfig');
}
}
- if ($this->targetModule === 'locations') {
- User::assertPermission('view', $this->qry_extra['field_value']);
- $editForbidden = !User::hasPermission('edit', $this->qry_extra['field_value']);
- } else {
- User::assertPermission('view', 0);
- $editForbidden = !User::hasPermission('edit', 0);
- }
+ $lid = $this->getPermissionLocationId();
+ User::assertPermission('view', $lid);
+ $editForbidden = !User::hasPermission('edit', $lid);
// Get stuff that's set in DB already
if ($this->targetModule !== false && isset($this->qry_extra['field'])) {
$fields = '';
@@ -280,6 +272,14 @@ class Page_BaseConfig extends Page
$this->targetModule = $module;
$this->qry_extra = $hook;
}
+
+ private function getPermissionLocationId()
+ {
+ if (!isset($this->qry_extra['locationResolver']) || !isset($this->qry_extra['field_value']))
+ return 0;
+ $func = explode('::', $this->qry_extra['locationResolver']);
+ return (int)call_user_func($func, $this->qry_extra['field_value']);
+ }
/**
* Create html snippet for setting, based on given validator