From f2faf9fae6ddeddb0baaef279aaa0d60917b7e9d Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Wed, 20 Sep 2017 15:52:50 +0800 Subject: [PATCH] MDL-35429 restore: capability clarification for automated backups - added relevant cap check on restorefile.php to improve the error message when attempting to restore automated backups. This cap is already responsible for controlling restores from automated areas. - Restored the 'viewautomatedfilearea' capabilities original lang string. --- backup/restorefile.php | 3 +++ lang/en/role.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backup/restorefile.php b/backup/restorefile.php index 7b0fcd29690..be9ae4a8fb7 100644 --- a/backup/restorefile.php +++ b/backup/restorefile.php @@ -79,6 +79,9 @@ if (!check_dir_exists($tmpdir, true, true)) { // choose the backup file from backup files tree if ($action == 'choosebackupfile') { + if ($filearea == 'automated') { + require_capability('moodle/restore:viewautomatedfilearea', $context); + } if ($fileinfo = $browser->get_file_info($filecontext, $component, $filearea, $itemid, $filepath, $filename)) { if (is_a($fileinfo, 'file_info_stored')) { // Use the contenthash rather than copying the file where possible, diff --git a/lang/en/role.php b/lang/en/role.php index 7af4a201029..15407340c90 100644 --- a/lang/en/role.php +++ b/lang/en/role.php @@ -352,7 +352,7 @@ $string['restore:restoretargetimport'] = 'Restore from files targeted as import' $string['restore:rolldates'] = 'Allowed to roll activity configuration dates on restore'; $string['restore:uploadfile'] = 'Upload files to backup areas'; $string['restore:userinfo'] = 'Restore user data'; -$string['restore:viewautomatedfilearea'] = 'View automated backup area'; +$string['restore:viewautomatedfilearea'] = 'Restore courses from automated backups'; $string['risks'] = 'Risks'; $string['roleallowheader'] = 'Allow role:'; $string['roleallowinfo'] = 'Select a role to be added to the list of allowed roles in context "{$a->context}", capability "{$a->cap}":';