MDL-21097 Correctly check capabilities for course settings items
- Make sure that items in course settings (and frontpage settings) are shown depending on user capabilities - Make sure user is able to turn editing on on the page even if he has only limited number of seciton/modules capabilities
This commit is contained in:
@@ -125,6 +125,11 @@
|
||||
$PAGE->set_pagelayout('course');
|
||||
$PAGE->set_pagetype('course-view-' . $course->format);
|
||||
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
||||
$PAGE->set_other_editing_capability('moodle/course:activityvisibility');
|
||||
if (course_format_uses_sections($course->format)) {
|
||||
$PAGE->set_other_editing_capability('moodle/course:sectionvisibility');
|
||||
$PAGE->set_other_editing_capability('moodle/course:movesections');
|
||||
}
|
||||
|
||||
if ($reset_user_allowed_editing) {
|
||||
// ugly hack
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
|
||||
$PAGE->set_pagetype('site-index');
|
||||
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
||||
$PAGE->set_other_editing_capability('moodle/course:activityvisibility');
|
||||
$PAGE->set_docs_path('');
|
||||
$PAGE->set_pagelayout('frontpage');
|
||||
$editing = $PAGE->user_is_editing();
|
||||
|
||||
@@ -3582,7 +3582,7 @@ class settings_navigation extends navigation_node {
|
||||
$coursenode->force_open();
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
if ($this->page->user_allowed_editing()) {
|
||||
// Add the turn on/off settings
|
||||
|
||||
if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
|
||||
@@ -3603,7 +3603,9 @@ class settings_navigation extends navigation_node {
|
||||
$editstring = get_string('turneditingon');
|
||||
}
|
||||
$coursenode->add($editstring, $editurl, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $coursecontext)) {
|
||||
// Add the module chooser toggle
|
||||
$modchoosertoggleurl = clone($baseurl);
|
||||
if ($this->page->user_is_editing() && course_ajax_enabled($course)) {
|
||||
@@ -3619,7 +3621,9 @@ class settings_navigation extends navigation_node {
|
||||
$modchoosertoggle->add_class('visibleifjs');
|
||||
user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
if ($this->page->user_is_editing()) {
|
||||
// Removed as per MDL-22732
|
||||
// $this->add_course_editing_links($course);
|
||||
@@ -4381,7 +4385,7 @@ class settings_navigation extends navigation_node {
|
||||
}
|
||||
$frontpage->id = 'frontpagesettings';
|
||||
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
if ($this->page->user_allowed_editing()) {
|
||||
|
||||
// Add the turn on/off settings
|
||||
$url = new moodle_url('/course/view.php', array('id'=>$course->id, 'sesskey'=>sesskey()));
|
||||
@@ -4393,7 +4397,9 @@ class settings_navigation extends navigation_node {
|
||||
$editstring = get_string('turneditingon');
|
||||
}
|
||||
$frontpage->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
// Add the course settings link
|
||||
$url = new moodle_url('/admin/settings.php', array('section'=>'frontpagesettings'));
|
||||
$frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
|
||||
|
||||
Reference in New Issue
Block a user