summaryrefslogtreecommitdiffstats
path: root/modules-available/backup
diff options
context:
space:
mode:
authorUdo Walter2017-12-14 14:40:53 +0100
committerUdo Walter2017-12-14 14:40:53 +0100
commit1a4fa4f756c9b58a5a4da6b4511ac9ceda866326 (patch)
tree45fe23b29be375f235c8d4861fff3b2edc69bc06 /modules-available/backup
parent[webinterface] added permissions to edit https, password and design settings (diff)
downloadslx-admin-1a4fa4f756c9b58a5a4da6b4511ac9ceda866326.tar.gz
slx-admin-1a4fa4f756c9b58a5a4da6b4511ac9ceda866326.tar.xz
slx-admin-1a4fa4f756c9b58a5a4da6b4511ac9ceda866326.zip
[backup] added permissions to create and restore backups
Diffstat (limited to 'modules-available/backup')
-rw-r--r--modules-available/backup/lang/de/permissions.json4
-rw-r--r--modules-available/backup/lang/en/permissions.json4
-rw-r--r--modules-available/backup/page.inc.php12
-rw-r--r--modules-available/backup/permissions/permissions.json4
-rw-r--r--modules-available/backup/style.css7
-rw-r--r--modules-available/backup/templates/_page.html4
6 files changed, 28 insertions, 7 deletions
diff --git a/modules-available/backup/lang/de/permissions.json b/modules-available/backup/lang/de/permissions.json
new file mode 100644
index 00000000..e5f189b8
--- /dev/null
+++ b/modules-available/backup/lang/de/permissions.json
@@ -0,0 +1,4 @@
+{
+ "create": "Eine Sicherung erstellen und herunterladen.",
+ "restore": "Eine Sicherung hochladen und wiederherstellen."
+} \ No newline at end of file
diff --git a/modules-available/backup/lang/en/permissions.json b/modules-available/backup/lang/en/permissions.json
new file mode 100644
index 00000000..ee1d87cb
--- /dev/null
+++ b/modules-available/backup/lang/en/permissions.json
@@ -0,0 +1,4 @@
+{
+ "create": "Create and download a backup.",
+ "restore": "Upload and restore a backup."
+} \ No newline at end of file
diff --git a/modules-available/backup/page.inc.php b/modules-available/backup/page.inc.php
index 77d677c7..26182ca3 100644
--- a/modules-available/backup/page.inc.php
+++ b/modules-available/backup/page.inc.php
@@ -11,21 +11,21 @@ class Page_Backup extends Page
protected function doPreprocess()
{
User::load();
- if (!User::hasPermission('superadmin')) {
+ if (!User::isLoggedIn()) {
Message::addError('main.no-permission');
Util::redirect('?do=Main');
}
$this->action = Request::post('action');
- if ($this->action === 'backup') {
+ if ($this->action === 'backup' && User::hasPermission("create")) {
$this->backup();
- } elseif ($this->action === 'restore') {
+ } elseif ($this->action === 'restore' && User::hasPermission("restore")) {
$this->restore();
}
}
protected function doRender()
{
- if ($this->action === 'restore') {
+ if ($this->action === 'restore' && User::hasPermission("restore")) {
Render::addTemplate('restore', $this->templateData);
} else {
$lastBackup = (int)Property::get(self::LAST_BACKUP_PROP, 0);
@@ -34,7 +34,9 @@ class Page_Backup extends Page
} else {
$lastBackup = date('d.m.Y', $lastBackup);
}
- Render::addTemplate('_page', ['last_backup' => $lastBackup]);
+ Render::addTemplate('_page', ['last_backup' => $lastBackup,
+ "createAllowed" => User::hasPermission("create"),
+ "restoreAllowed" => User::hasPermission("restore")]);
}
}
diff --git a/modules-available/backup/permissions/permissions.json b/modules-available/backup/permissions/permissions.json
new file mode 100644
index 00000000..feeffe33
--- /dev/null
+++ b/modules-available/backup/permissions/permissions.json
@@ -0,0 +1,4 @@
+[
+ "create",
+ "restore"
+] \ No newline at end of file
diff --git a/modules-available/backup/style.css b/modules-available/backup/style.css
new file mode 100644
index 00000000..7b86af56
--- /dev/null
+++ b/modules-available/backup/style.css
@@ -0,0 +1,7 @@
+.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 88815897..41e73091 100644
--- a/modules-available/backup/templates/_page.html
+++ b/modules-available/backup/templates/_page.html
@@ -3,7 +3,7 @@
<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">
+ <div class="panel panel-default {{^createAllowed}}disabledPanel{{/createAllowed}}">
<div class="panel-heading">{{lang_backup}}</div>
<div class="panel-body">
<p>{{lang_backupDescription}}</p>
@@ -20,7 +20,7 @@
<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">
+ <div class="panel panel-default {{^restoreAllowed}}disabledPanel{{/restoreAllowed}}">
<div class="panel-heading">{{lang_restore}}</div>
<div class="panel-body">
<p>{{lang_restoreDescription}}</p>