diff options
Diffstat (limited to 'modules-available/serversetup-bwlp')
7 files changed, 39 insertions, 9 deletions
diff --git a/modules-available/serversetup-bwlp/lang/de/permissions.json b/modules-available/serversetup-bwlp/lang/de/permissions.json new file mode 100644 index 00000000..673bf153 --- /dev/null +++ b/modules-available/serversetup-bwlp/lang/de/permissions.json @@ -0,0 +1,5 @@ +{ + "edit.address": "Boot-Adresse des Servers auswählen.", + "edit.menu": "Bootmenü anpassen.", + "download": "USB-Image herunteladen." +}
\ No newline at end of file diff --git a/modules-available/serversetup-bwlp/lang/en/permissions.json b/modules-available/serversetup-bwlp/lang/en/permissions.json new file mode 100644 index 00000000..c04f09f7 --- /dev/null +++ b/modules-available/serversetup-bwlp/lang/en/permissions.json @@ -0,0 +1,5 @@ +{ + "edit.address": "Choose boot address of the server.", + "edit.menu": "Customize boot menu.", + "download": "Download USB Image." +}
\ No newline at end of file diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index a8d29d6e..16d3f8e2 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -12,12 +12,12 @@ class Page_ServerSetup extends Page { User::load(); - if (!User::hasPermission('superadmin')) { + if (!User::isLoggedIn()) { Message::addError('main.no-permission'); Util::redirect('?do=Main'); } - if (Request::any('action') === 'getimage') { + if (Request::any('action') === 'getimage' && User::hasPermission("download")) { $this->handleGetImage(); } @@ -30,13 +30,13 @@ class Page_ServerSetup extends Page $this->getLocalAddresses(); } - if ($action === 'ip') { + if ($action === 'ip' && User::hasPermission("edit.address")) { // New address is to be set $this->getLocalAddresses(); $this->updateLocalAddress(); } - if ($action === 'ipxe') { + if ($action === 'ipxe' && User::hasPermission("edit.menu")) { // iPXE stuff changes $this->updatePxeMenu(); } @@ -52,7 +52,8 @@ class Page_ServerSetup extends Page Render::addTemplate('ipaddress', array( 'ips' => $this->taskStatus['data']['addresses'], - 'chooseHintClass' => $this->hasIpSet ? '' : 'alert alert-danger' + 'chooseHintClass' => $this->hasIpSet ? '' : 'alert alert-danger', + 'editAllowed' => User::hasPermission("edit.address"), )); $data = $this->currentMenu; if (!isset($data['defaultentry'])) { @@ -67,6 +68,8 @@ class Page_ServerSetup extends Page if ($data['defaultentry'] === 'custom') { $data['active-custom'] = 'checked'; } + $data['editAllowed'] = User::hasPermission("edit.menu"); + $data['downloadAllowed'] = User::hasPermission("download"); Render::addTemplate('ipxe', $data); } diff --git a/modules-available/serversetup-bwlp/permissions/permissions.json b/modules-available/serversetup-bwlp/permissions/permissions.json new file mode 100644 index 00000000..2166cf8e --- /dev/null +++ b/modules-available/serversetup-bwlp/permissions/permissions.json @@ -0,0 +1,5 @@ +[ + "edit.address", + "edit.menu", + "download" +]
\ No newline at end of file diff --git a/modules-available/serversetup-bwlp/style.css b/modules-available/serversetup-bwlp/style.css new file mode 100644 index 00000000..3aea98af --- /dev/null +++ b/modules-available/serversetup-bwlp/style.css @@ -0,0 +1,12 @@ +.disabledPanel { + cursor: not-allowed; +} + +.disabledPanel > .panel-body { + pointer-events: none; + opacity: 0.8; +} + +.panel-footer .btn-group { + cursor: not-allowed; +}
\ No newline at end of file diff --git a/modules-available/serversetup-bwlp/templates/ipaddress.html b/modules-available/serversetup-bwlp/templates/ipaddress.html index 0b3b2ed7..e82253f5 100644 --- a/modules-available/serversetup-bwlp/templates/ipaddress.html +++ b/modules-available/serversetup-bwlp/templates/ipaddress.html @@ -1,4 +1,4 @@ -<div class="panel panel-default"> +<div class="panel panel-default {{^editAllowed}}disabledPanel{{/editAllowed}}"> <div class="panel-heading"> {{lang_bootAddress}} </div> diff --git a/modules-available/serversetup-bwlp/templates/ipxe.html b/modules-available/serversetup-bwlp/templates/ipxe.html index bb776dca..e0dc53e5 100644 --- a/modules-available/serversetup-bwlp/templates/ipxe.html +++ b/modules-available/serversetup-bwlp/templates/ipxe.html @@ -3,7 +3,7 @@ <input type="password" name="password_fake" id="password_fake" value="" style="position:absolute;top:-2000px" tabindex="-1"> <input type="hidden" name="action" value="ipxe"> <input type="hidden" name="token" value="{{token}}"> - <div class="panel panel-default"> + <div class="panel panel-default {{^editAllowed}}disabledPanel{{/editAllowed}}"> <div class="panel-heading"> {{lang_bootMenu}} </div> @@ -52,10 +52,10 @@ </div> <div class="panel-footer"> - <button class="btn btn-primary pull-right" name="action" value="ipxe">{{lang_bootMenuCreate}}</button> + <button class="btn btn-primary pull-right" name="action" value="ipxe" {{^editAllowed}}disabled{{/editAllowed}}>{{lang_bootMenuCreate}}</button> <div> <div class="btn-group" role="group"> - <a class="btn btn-default" href="?do=ServerSetup&action=getimage"> + <a class="btn btn-default {{^downloadAllowed}}disabled{{/downloadAllowed}}" href="?do=ServerSetup&action=getimage"> <span class="glyphicon glyphicon-download-alt"></span> {{lang_downloadImage}} </a> |