MDL-75771 core_courseformat: Fix capability for edit controls
course_format\base:show_editor now by default uses 'moodle/course:manageactivities', but also accepts other capabilities as param
This commit is contained in:
@@ -1340,13 +1340,18 @@ abstract class base {
|
||||
/**
|
||||
* return true if the course editor must be displayed.
|
||||
*
|
||||
* @param array|null $capabilities array of capabilities a user needs to have to see edit controls in general.
|
||||
* If null or not specified, the user needs to have 'moodle/course:manageactivities'
|
||||
* @return bool true if edit controls must be displayed
|
||||
*/
|
||||
public function show_editor(): bool {
|
||||
public function show_editor(?array $capabilities = ['moodle/course:manageactivities']): bool {
|
||||
global $PAGE;
|
||||
$course = $this->get_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
return $PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext);
|
||||
if ($capabilities === null) {
|
||||
$capabilities = ['moodle/course:manageactivities'];
|
||||
}
|
||||
return $PAGE->user_is_editing() && has_all_capabilities($capabilities, $coursecontext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user