summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2018-02-09 16:17:03 +0100
committerSimon Rettberg2018-02-09 16:17:03 +0100
commit676bb4aebcbb65f6271f062d03aef2a48346f2e3 (patch)
tree4ebaa48cad5acf9d9087f206018da446cd4a9e62 /modules-available
parentPermissions: Introduce helper functions for common tasks (diff)
downloadslx-admin-676bb4aebcbb65f6271f062d03aef2a48346f2e3.tar.gz
slx-admin-676bb4aebcbb65f6271f062d03aef2a48346f2e3.tar.xz
slx-admin-676bb4aebcbb65f6271f062d03aef2a48346f2e3.zip
[backup] Use permission helpers
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/backup/page.inc.php14
-rw-r--r--modules-available/backup/style.css7
-rw-r--r--modules-available/backup/templates/_page.html14
3 files changed, 15 insertions, 20 deletions
diff --git a/modules-available/backup/page.inc.php b/modules-available/backup/page.inc.php
index 949cd7f3..14522734 100644
--- a/modules-available/backup/page.inc.php
+++ b/modules-available/backup/page.inc.php
@@ -16,16 +16,18 @@ class Page_Backup extends Page
Util::redirect('?do=Main');
}
$this->action = Request::post('action');
- if ($this->action === 'backup' && User::hasPermission("create")) {
+ if ($this->action === 'backup') {
+ User::assertPermission("create");
$this->backup();
- } elseif ($this->action === 'restore' && User::hasPermission("restore")) {
+ } elseif ($this->action === 'restore') {
+ User::assertPermission("restore");
$this->restore();
}
}
protected function doRender()
{
- if ($this->action === 'restore' && User::hasPermission("restore")) {
+ if ($this->action === 'restore') { // TODO: We're in post mode, redirect with all the taskids first...
Render::addTemplate('restore', $this->templateData);
} else {
$lastBackup = (int)Property::get(self::LAST_BACKUP_PROP, 0);
@@ -34,9 +36,9 @@ class Page_Backup extends Page
} else {
$lastBackup = date('d.m.Y', $lastBackup);
}
- Render::addTemplate('_page', ['last_backup' => $lastBackup,
- "createAllowed" => User::hasPermission("create"),
- "restoreAllowed" => User::hasPermission("restore")]);
+ $params = ['last_backup' => $lastBackup];
+ Permission::addGlobalTags($params['perms'], NULL, ['create', 'restore']);
+ Render::addTemplate('_page', $params);
}
}
diff --git a/modules-available/backup/style.css b/modules-available/backup/style.css
deleted file mode 100644
index 7b86af56..00000000
--- a/modules-available/backup/style.css
+++ /dev/null
@@ -1,7 +0,0 @@
-.disabledPanel {
- cursor: not-allowed;
-}
-.disabledPanel > .panel-body {
- pointer-events: none;
- opacity: 0.8;
-}
diff --git a/modules-available/backup/templates/_page.html b/modules-available/backup/templates/_page.html
index 41e73091..4c6cade4 100644
--- a/modules-available/backup/templates/_page.html
+++ b/modules-available/backup/templates/_page.html
@@ -3,16 +3,16 @@
<form action="?do=Backup" method="post">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="action" value="backup">
- <div class="panel panel-default {{^createAllowed}}disabledPanel{{/createAllowed}}">
+ <div class="panel panel-default">
<div class="panel-heading">{{lang_backup}}</div>
- <div class="panel-body">
+ <div class="panel-body {{perms.create.disabled}}">
<p>{{lang_backupDescription}}</p>
<p class="text-right">
{{lang_lastBackup}}:
{{^last_backup}}{{lang_unknown}}{{/last_backup}}
{{last_backup}}
</p>
- <button class="btn btn-primary pull-right" type="submit"><span class="glyphicon glyphicon-save"></span> {{lang_download}}</button>
+ <button {{perms.create.disabled}} class="btn btn-primary pull-right" type="submit"><span class="glyphicon glyphicon-save"></span> {{lang_download}}</button>
</div>
</div>
</form>
@@ -20,15 +20,15 @@
<form action="?do=Backup" method="post" enctype="multipart/form-data">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="action" value="restore">
- <div class="panel panel-default {{^restoreAllowed}}disabledPanel{{/restoreAllowed}}">
+ <div class="panel panel-default">
<div class="panel-heading">{{lang_restore}}</div>
- <div class="panel-body">
+ <div class="panel-body {{perms.restore.disabled}}">
<p>{{lang_restoreDescription}}</p>
<div class="input-group upload-ex">
<input type="text" class="form-control" readonly placeholder="{{lang_selectFile}}">
<span class="input-group-btn">
<span class="btn btn-default btn-file">
- {{lang_browseForFile}}&hellip; <input type="file" name="backupfile">
+ {{lang_browseForFile}}&hellip; <input type="file" name="backupfile" {{perms.restore.disabled}}>
</span>
</span>
</div>
@@ -46,7 +46,7 @@
</div>
<p><i>{{lang_dozmodExplanation}}</i></p>
</div>
- <button class="btn btn-primary pull-right" type="submit"><span class="glyphicon glyphicon-open"></span> {{lang_restore}}</button>
+ <button {{perms.restore.disabled}} class="btn btn-primary pull-right" type="submit"><span class="glyphicon glyphicon-open"></span> {{lang_restore}}</button>
</div>
</div>
</form> \ No newline at end of file