diff options
author | Christian Hofmaier | 2017-09-29 18:28:03 +0200 |
---|---|---|
committer | Christian Hofmaier | 2017-09-29 18:28:03 +0200 |
commit | 7250d8de72daa36cb23bfc3cb20c23905fcee94d (patch) | |
tree | 31dbe27fa16d822cc5a43e0636864edcc0c176ec /modules-available/internetaccess | |
parent | [news] small design change + implemented new permission system (diff) | |
download | slx-admin-7250d8de72daa36cb23bfc3cb20c23905fcee94d.tar.gz slx-admin-7250d8de72daa36cb23bfc3cb20c23905fcee94d.tar.xz slx-admin-7250d8de72daa36cb23bfc3cb20c23905fcee94d.zip |
[internetaccess] implemented new permission system
Diffstat (limited to 'modules-available/internetaccess')
-rw-r--r-- | modules-available/internetaccess/page.inc.php | 46 | ||||
-rw-r--r-- | modules-available/internetaccess/permissions/permissions.json | 3 | ||||
-rw-r--r-- | modules-available/internetaccess/templates/_page.html | 2 |
3 files changed, 30 insertions, 21 deletions
diff --git a/modules-available/internetaccess/page.inc.php b/modules-available/internetaccess/page.inc.php index 246d4477..4f4cb8f3 100644 --- a/modules-available/internetaccess/page.inc.php +++ b/modules-available/internetaccess/page.inc.php @@ -6,27 +6,33 @@ class Page_InternetAccess extends Page protected function doPreprocess() { User::load(); - if (!User::hasPermission('superadmin')) { - Message::addError('main.no-permission'); - Util::redirect('?do=Main'); - } - if (isset($_POST['PROXY_CONF'])) { - $data = array(); - foreach (array('PROXY_CONF', 'PROXY_ADDR', 'PROXY_PORT', 'PROXY_USERNAME', 'PROXY_PASSWORD') as $key) { - $data[$key] = Request::post($key, ''); - } - if (!FileUtil::arrayToFile(CONFIG_PROXY_CONF, $data)) { - Message::addError('main.error-write', CONFIG_PROXY_CONF); - Util::redirect(); + + $action = Request::any('action', 'show'); + + if ($action == 'save') { + if (User::hasPermission("configuration.save")) { + if (isset($_POST['PROXY_CONF'])) { + $data = array(); + foreach (array('PROXY_CONF', 'PROXY_ADDR', 'PROXY_PORT', 'PROXY_USERNAME', 'PROXY_PASSWORD') as $key) { + $data[$key] = Request::post($key, ''); + } + if (!FileUtil::arrayToFile(CONFIG_PROXY_CONF, $data)) { + Message::addError('main.error-write', CONFIG_PROXY_CONF); + Util::redirect(); + } else { + Message::addSuccess('settings-updated'); + Taskmanager::release(Taskmanager::submit('ReloadProxy')); + $taskids = array(); + Trigger::stopDaemons(NULL, $taskids); + $taskids = array(); + Trigger::startDaemons(NULL, $taskids); + Session::set('ia-restart', $taskids); + Util::redirect('?do=InternetAccess&show=update'); + } + } } else { - Message::addSuccess('settings-updated'); - Taskmanager::release(Taskmanager::submit('ReloadProxy')); - $taskids = array(); - Trigger::stopDaemons(NULL, $taskids); - $taskids = array(); - Trigger::startDaemons(NULL, $taskids); - Session::set('ia-restart', $taskids); - Util::redirect('?do=InternetAccess&show=update'); + Message::addError('main.no-permission'); + Util::redirect('?do=internetaccess'); } } } diff --git a/modules-available/internetaccess/permissions/permissions.json b/modules-available/internetaccess/permissions/permissions.json new file mode 100644 index 00000000..6d88ccc5 --- /dev/null +++ b/modules-available/internetaccess/permissions/permissions.json @@ -0,0 +1,3 @@ +{ + "configuration.safe": "Safe new configuration." +}
\ No newline at end of file diff --git a/modules-available/internetaccess/templates/_page.html b/modules-available/internetaccess/templates/_page.html index 332c63ff..d363561e 100644 --- a/modules-available/internetaccess/templates/_page.html +++ b/modules-available/internetaccess/templates/_page.html @@ -1,6 +1,6 @@ <h1>{{lang_internetAccess}}</h1> -<form action="?do=InternetAccess" method="post"> +<form action="?do=InternetAccess&action=save" method="post"> <input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="position:absolute;top:-2000px" tabindex="-1"> <input type="password" name="password_fake" id="password_fake" value="" style="position:absolute;top:-2000px" tabindex="-1"> <input type="hidden" name="token" value="{{token}}"> |