MDL-28207 Course: Showing/hiding/marking a section respect capabilities
This commit is contained in:
@@ -186,29 +186,33 @@ while ($section <= $course->numsections) {
|
||||
'<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon" alt="'.$strshowonlytopic.'" /></a><br />';
|
||||
}
|
||||
|
||||
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 '<a href="view.php?id='.$course->id.'&marker=0&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marked') . '" alt="'.$strmarkedthistopic.'" class="icon"/></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&marker='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marker') . '" alt="'.$strmarkthistopic.'" class="icon"/></a><br />';
|
||||
$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 '<a href="view.php?id='.$course->id.'&marker=0&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marked') . '" alt="'.$strmarkedthistopic.'" class="icon"/></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&marker='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marker') . '" alt="'.$strmarkthistopic.'" class="icon"/></a><br />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopichide.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strtopichide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopicshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strtopicshow.'" /></a><br />';
|
||||
if (has_capability('moodle/course:sectionvisibility', $coursecontext)) {
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopichide.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strtopichide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopicshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strtopicshow.'" /></a><br />';
|
||||
}
|
||||
}
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
|
||||
}
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
@@ -192,22 +192,26 @@ defined('MOODLE_INTERNAL') || die();
|
||||
'<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
|
||||
}
|
||||
|
||||
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 '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
|
||||
$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 '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekshow.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
|
||||
}
|
||||
}
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
|
||||
if (has_capability('moodle/course:update', $coursecontext)) {
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
|
||||
}
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
+3
-2
@@ -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;
|
||||
}
|
||||
|
||||
+3
-2
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user