diff options
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/backup/lang/de/permissions.json | 4 | ||||
-rw-r--r-- | modules-available/backup/lang/en/permissions.json | 4 | ||||
-rw-r--r-- | modules-available/backup/page.inc.php | 12 | ||||
-rw-r--r-- | modules-available/backup/permissions/permissions.json | 4 | ||||
-rw-r--r-- | modules-available/backup/style.css | 7 | ||||
-rw-r--r-- | modules-available/backup/templates/_page.html | 4 |
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> |