diff --git a/course/format/topics/format.php b/course/format/topics/format.php index b8ce8f22862..0c58c4d0e02 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -186,29 +186,33 @@ while ($section <= $course->numsections) { ''.$strshowonlytopic.'
'; } - if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { - - if ($course->marker == $section) { // Show the "light globe" on/off - echo ''.''.$strmarkedthistopic.'
'; - } else { - echo ''.''.$strmarkthistopic.'
'; + $coursecontext = context_course::instance($course->id); + if ($PAGE->user_is_editing()) { + if (has_capability('moodle/course:setcurrentsection', $coursecontext)) { + if ($course->marker == $section) { // Show the "light globe" on/off + echo ''.''.$strmarkedthistopic.'
'; + } else { + echo ''.''.$strmarkthistopic.'
'; + } } - - if ($thissection->visible) { // Show the hide/show eye - echo ''. - ''.$strtopichide.'
'; - } else { - echo ''. - ''.$strtopicshow.'
'; + if (has_capability('moodle/course:sectionvisibility', $coursecontext)) { + if ($thissection->visible) { // Show the hide/show eye + echo ''. + ''.$strtopichide.'
'; + } else { + echo ''. + ''.$strtopicshow.'
'; + } } - if ($section > 1) { // Add a arrow to move section up - echo ''. - ''.$strmoveup.'
'; - } - - if ($section < $course->numsections) { // Add a arrow to move section down - echo ''. - ''.$strmovedown.'
'; + if (has_capability('moodle/course:update', $coursecontext)) { + if ($section > 1) { // Add a arrow to move section up + echo ''. + ''.$strmoveup.'
'; + } + if ($section < $course->numsections) { // Add a arrow to move section down + echo ''. + ''.$strmovedown.'
'; + } } } echo ''; diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index c5c78faf139..9ae93f12d83 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -192,22 +192,26 @@ defined('MOODLE_INTERNAL') || die(); ''.$strshowonlyweek.'
'; } - if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { - if ($thissection->visible) { // Show the hide/show eye - echo ''. - ''.$strweekhide.'
'; - } else { - echo ''. - ''.$strweekshow.'
'; + $coursecontext = context_course::instance($course->id); + if ($PAGE->user_is_editing()) { + if (has_capability('moodle/course:sectionvisibility', $coursecontext)) { + if ($thissection->visible) { // Show the hide/show eye + echo ''. + ''.$strweekhide.'
'; + } else { + echo ''. + ''.$strweekshow.'
'; + } } - if ($section > 1) { // Add a arrow to move section up - echo ''. - ''.$strmoveup.'
'; - } - - if ($section < $course->numsections) { // Add a arrow to move section down - echo ''. - ''.$strmovedown.'
'; + if (has_capability('moodle/course:update', $coursecontext)) { + if ($section > 1) { // Add a arrow to move section up + echo ''. + ''.$strmoveup.'
'; + } + if ($section < $course->numsections) { // Add a arrow to move section down + echo ''. + ''.$strmovedown.'
'; + } } } echo ''; diff --git a/course/rest.php b/course/rest.php index 5125ffb72d3..3f996a7c4fb 100644 --- a/course/rest.php +++ b/course/rest.php @@ -78,7 +78,6 @@ switch($requestmethod) { case 'section': require_login($course); $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); - require_capability('moodle/course:update', $coursecontext); if (!$DB->record_exists('course_sections', array('course'=>$course->id, 'section'=>$id))) { error_log('AJAX commands.php: Bad Section ID '.$id); @@ -87,10 +86,12 @@ switch($requestmethod) { switch ($field) { case 'visible': + require_capability('moodle/course:sectionvisibility', $coursecontext); set_section_visible($course->id, $id, $value); break; case 'move': + require_capability('moodle/course:update', $coursecontext); move_section_to($course, $id, $value); break; } @@ -158,7 +159,7 @@ switch($requestmethod) { case 'marker': require_login($course); $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); - require_capability('moodle/course:update', $coursecontext); + require_capability('moodle/course:setcurrentsection', $coursecontext); course_set_marker($course->id, $value); break; } diff --git a/course/view.php b/course/view.php index 8b2621f38a0..816265efd18 100644 --- a/course/view.php +++ b/course/view.php @@ -127,15 +127,16 @@ } } - if (has_capability('moodle/course:update', $context)) { + if (has_capability('moodle/course:sectionvisibility', $context)) { if ($hide && confirm_sesskey()) { set_section_visible($course->id, $hide, '0'); } - if ($show && confirm_sesskey()) { set_section_visible($course->id, $show, '1'); } + } + if (has_capability('moodle/course:update', $context)) { if (!empty($section)) { if (!empty($move) and confirm_sesskey()) { if (move_section($course, $section, $move)) {