Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-28207-23' of git://github.com/FMCorz/moodle into MO…

…ODLE_23_STABLE
  • Loading branch information...
commit cfe10a46986123dcde60775cc7aede41b682216c 2 parents 01672d5 + 84af401
@danpoltawski danpoltawski authored
View
36 course/format/renderer.php
@@ -205,9 +205,7 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
return array();
}
- if (!has_capability('moodle/course:update', context_course::instance($course->id))) {
- return array();
- }
+ $coursecontext = context_course::instance($course->id);
if ($onsectionpage) {
$baseurl = course_get_url($course, $section->section);
@@ -219,23 +217,25 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
$controls = array();
$url = clone($baseurl);
- if ($section->visible) { // Show the hide/show eye.
- $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
- $url->param('hide', $section->section);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'),
- 'class' => 'icon hide', 'alt' => $strhidefromothers)),
- array('title' => $strhidefromothers, 'class' => 'editing_showhide'));
- } else {
- $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
- $url->param('show', $section->section);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'),
- 'class' => 'icon hide', 'alt' => $strshowfromothers)),
- array('title' => $strshowfromothers, 'class' => 'editing_showhide'));
+ if (has_capability('moodle/course:sectionvisibility', $coursecontext)) {
+ if ($section->visible) { // Show the hide/show eye.
+ $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
+ $url->param('hide', $section->section);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'),
+ 'class' => 'icon hide', 'alt' => $strhidefromothers)),
+ array('title' => $strhidefromothers, 'class' => 'editing_showhide'));
+ } else {
+ $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
+ $url->param('show', $section->section);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'),
+ 'class' => 'icon hide', 'alt' => $strshowfromothers)),
+ array('title' => $strshowfromothers, 'class' => 'editing_showhide'));
+ }
}
- if (!$onsectionpage) {
+ if (!$onsectionpage && has_capability('moodle/course:update', $coursecontext)) {
$url = clone($baseurl);
if ($section->section > 1) { // Add a arrow to move section up.
$url->param('section', $section->section);
View
30 course/format/topics/renderer.php
@@ -74,9 +74,7 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
return array();
}
- if (!has_capability('moodle/course:update', context_course::instance($course->id))) {
- return array();
- }
+ $coursecontext = context_course::instance($course->id);
if ($onsectionpage) {
$url = course_get_url($course, $section->section);
@@ -86,18 +84,20 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
$url->param('sesskey', sesskey());
$controls = array();
- if ($course->marker == $section->section) { // Show the "light globe" on/off.
- $url->param('marker', 0);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'),
- 'class' => 'icon ', 'alt' => get_string('markedthistopic'))),
- array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight'));
- } else {
- $url->param('marker', $section->section);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'),
- 'class' => 'icon', 'alt' => get_string('markthistopic'))),
- array('title' => get_string('markthistopic'), 'class' => 'editing_highlight'));
+ if (has_capability('moodle/course:setcurrentsection', $coursecontext)) {
+ if ($course->marker == $section->section) { // Show the "light globe" on/off.
+ $url->param('marker', 0);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'),
+ 'class' => 'icon ', 'alt' => get_string('markedthistopic'))),
+ array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight'));
+ } else {
+ $url->param('marker', $section->section);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'),
+ 'class' => 'icon', 'alt' => get_string('markthistopic'))),
+ array('title' => get_string('markthistopic'), 'class' => 'editing_highlight'));
+ }
}
return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage));
View
5 course/rest.php
@@ -75,7 +75,6 @@
switch ($class) {
case 'section':
- require_capability('moodle/course:update', $coursecontext);
if (!$DB->record_exists('course_sections', array('course'=>$course->id, 'section'=>$id))) {
throw new moodle_exception('AJAX commands.php: Bad Section ID '.$id);
@@ -83,11 +82,13 @@
switch ($field) {
case 'visible':
+ require_capability('moodle/course:sectionvisibility', $coursecontext);
$resourcestotoggle = set_section_visible($course->id, $id, $value);
echo json_encode(array('resourcestotoggle' => $resourcestotoggle));
break;
case 'move':
+ require_capability('moodle/course:update', $coursecontext);
move_section_to($course, $id, $value);
// See if format wants to do something about it
$libfile = $CFG->dirroot.'/course/format/'.$course->format.'/lib.php';
@@ -178,7 +179,7 @@
case 'course':
switch($field) {
case 'marker':
- require_capability('moodle/course:update', $coursecontext);
+ require_capability('moodle/course:setcurrentsection', $coursecontext);
course_set_marker($course->id, $value);
break;
}
View
4 course/view.php
@@ -162,7 +162,7 @@
set_user_preference('usemodchooser', $modchooser);
}
- 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');
redirect($PAGE->url);
@@ -172,7 +172,9 @@
set_section_visible($course->id, $show, '1');
redirect($PAGE->url);
}
+ }
+ if (has_capability('moodle/course:update', $context)) {
if (!empty($section)) {
if (!empty($move) and confirm_sesskey()) {
$destsection = $section + $move;
Please sign in to comment.
Something went wrong with that request. Please try again.