From 54945fa728028fa859279b6a0ccab2f095aae24a Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Thu, 21 Sep 2017 11:36:23 +0800 Subject: [PATCH] MDL-35429 roles: teachers and managers can restore automated backups Changes the default for the 'moodle/restore:viewautomatedfilearea' cap from 'Not set' to 'Allow' for the teacher and manager role archetypes. --- lib/db/access.php | 4 ++++ lib/filebrowser/tests/file_browser_test.php | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/db/access.php b/lib/db/access.php index 7b3a37a38e7..68704f4d66b 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -305,6 +305,10 @@ $capabilities = array( 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ), ), 'moodle/restore:restoretargethub' => array( diff --git a/lib/filebrowser/tests/file_browser_test.php b/lib/filebrowser/tests/file_browser_test.php index 3ce057026f3..25835debed3 100644 --- a/lib/filebrowser/tests/file_browser_test.php +++ b/lib/filebrowser/tests/file_browser_test.php @@ -78,6 +78,10 @@ class file_browser_testcase extends advanced_testcase { $this->teacher = $this->getDataGenerator()->create_user(); $this->teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher')); + + // Make sure we're testing what should be the default capabilities. + assign_capability('moodle/restore:viewautomatedfilearea', CAP_ALLOW, $this->teacherrole->id, $coursecontext1); + $this->getDataGenerator()->enrol_user($this->teacher->id, $this->course1->id, $this->teacherrole->id); $this->getDataGenerator()->enrol_user($this->teacher->id, $this->course2->id, $this->teacherrole->id); @@ -175,9 +179,9 @@ class file_browser_testcase extends advanced_testcase { // Filearea "Course summary" has a child that is the actual image file. $this->assertEquals($this->course1filerecord, $child->get_children()[0]->get_params()); - // There are six course-level file areas and no modules in this course. + // There are seven course-level file areas available to teachers with default caps and no modules in this course. $allchildren = $fileinfo->get_children(); - $this->assertEquals(6, count($allchildren)); + $this->assertEquals(7, count($allchildren)); $modulechildren = array_filter($allchildren, function($a) { return $a instanceof file_info_context_module; });