diff options
| author | czaks <marcin@6irc.net> | 2013-08-04 21:17:38 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-08-04 21:17:38 -0400 |
| commit | f494b34562e555edb4c7ba14ce8444a001f36d00 (patch) | |
| tree | 5503897969e7f82f95c3607f78e3cbc3f9c8f79f /inc/mod/config-editor.php | |
| parent | 7407593ec5b3b3857719a72e7bf98e0fcae4e929 (diff) | |
| parent | 0c829aa8f6fb592c15086e8b2b0276fd862e89f1 (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts:
inc/image.php
Diffstat (limited to 'inc/mod/config-editor.php')
| -rw-r--r-- | inc/mod/config-editor.php | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/inc/mod/config-editor.php b/inc/mod/config-editor.php index caca5a0e..27740378 100644 --- a/inc/mod/config-editor.php +++ b/inc/mod/config-editor.php @@ -1,5 +1,43 @@ <?php +function permission_to_edit_config_var($varname) { + global $config, $mod; + + if (is_array($config['mod']['config'][DISABLED])) { + foreach ($config['mod']['config'][DISABLED] as $disabled_var_name) { + $disabled_var_name = explode('>', $disabled_var_name); + if (count($disabled_var_name) == 1) + $disabled_var_name = $disabled_var_name[0]; + if ($varname == $disabled_var_name) + return false; + } + } + + $allow_only = false; + // for ($perm = (int)$mod['type']; $perm >= JANITOR; $perm --) { + for ($perm = JANITOR; $perm <= (int)$mod['type']; $perm ++) { + $allow_only = false; + if (is_array($config['mod']['config'][$perm])) { + foreach ($config['mod']['config'][$perm] as $perm_var_name) { + if ($perm_var_name == '!') { + $allow_only = true; + continue; + } + $perm_var_name = explode('>', $perm_var_name); + if ((count($perm_var_name) == 1 && $varname == $perm_var_name[0]) || + (is_array($varname) && array_slice($varname, 0, count($perm_var_name)) == $perm_var_name)) { + if ($allow_only) + return true; + else + return false; + } + } + } + } + + return !$allow_only; +} + function config_vars() { global $config; @@ -77,8 +115,8 @@ function config_vars() { $already_exists = true; } - if (!$already_exists) - $conf[] = $var; + if (!$already_exists && permission_to_edit_config_var($var['name'])) + $conf[] = $var; } } |
