mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
made some changes so that if a user has any roles assigned in context_module or context_block with moodle/site:manageblocks or moodle/course:manageactivities, he will see the "turn editting on" button without needing to have a role assigned at context_course with moodle/course:manageactivies capability. Of course this user would not be able to edit any blocks or modules he/she is not supposed to edit. Ajax for these users with partial editing privilages are locked. Please report bugs asap as we are looking at backporting this change to 1.8. Cheers.
This commit is contained in:
parent
12ce9ea2ee
commit
217a8ee950
13 changed files with 149 additions and 62 deletions
|
@ -108,7 +108,7 @@ if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo '<a title="'.$streditsummary.'" '.
|
||||
' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
|
||||
' class="iconsmall" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
|
@ -263,7 +263,7 @@ while ($section <= $course->numsections) {
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ while ($section <= $course->numsections) {
|
|||
'<img src="'.$CFG->pixpath.'/i/one.gif" height="16" width="16" border="0" alt="'.$strshowonlytopic.'" /></a><br />';
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && 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='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/marked.gif" height="16" width="16" border="0" alt="'.$strmarkedthistopic.'" /></a><br />';
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo '<a title="'.$streditsummary.'" '.
|
||||
' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
|
||||
' alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
|
@ -213,7 +213,7 @@
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
}
|
||||
|
@ -237,7 +237,7 @@
|
|||
'<img src="'.$CFG->pixpath.'/i/one.gif" alt="'.$strshowonlytopic.'" /></a><br />';
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && 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='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/marked.gif" alt="'.$strmarkedthistopic.'" /></a><br />';
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo '<a title="'.$streditsummary.'" '.
|
||||
' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
|
||||
'class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
|
@ -226,7 +226,7 @@
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
}
|
||||
|
@ -251,7 +251,7 @@
|
|||
'<img src="'.$CFG->pixpath.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && 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='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo '<p><a title="'.$streditsummary.'" '.
|
||||
' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
|
||||
' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
|
||||
|
@ -212,7 +212,7 @@
|
|||
'<img src="'.$CFG->pixpath.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && 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='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
|
@ -243,7 +243,7 @@
|
|||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
|
||||
echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
|
||||
}
|
||||
|
|
|
@ -1452,6 +1452,11 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
|||
function print_section_add_menus($course, $section, $modnames, $vertical=false, $return=false) {
|
||||
global $CFG;
|
||||
|
||||
// check to see if user can add menus
|
||||
if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static $resources = false;
|
||||
static $activities = false;
|
||||
|
||||
|
@ -2200,6 +2205,12 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-
|
|||
static $str;
|
||||
static $sesskey;
|
||||
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $mod->id);
|
||||
// no permission to edit
|
||||
if (!has_capability('moodle/course:manageactivities', $modcontext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($str)) {
|
||||
$str->delete = get_string("delete");
|
||||
$str->move = get_string("move");
|
||||
|
@ -2231,16 +2242,18 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-
|
|||
$path = '.';
|
||||
}
|
||||
|
||||
if ($mod->visible) {
|
||||
$hideshow = '<a class="editing_hide" title="'.$str->hide.'" href="'.$path.'/mod.php?hide='.$mod->id.
|
||||
'&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" '.
|
||||
' alt="'.$str->hide.'" /></a>'."\n";
|
||||
} else {
|
||||
$hideshow = '<a class="editing_show" title="'.$str->show.'" href="'.$path.'/mod.php?show='.$mod->id.
|
||||
'&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" '.
|
||||
' alt="'.$str->show.'" /></a>'."\n";
|
||||
if (has_capability('moodle/course:activityvisibility', $modcontext)) {
|
||||
if ($mod->visible) {
|
||||
$hideshow = '<a class="editing_hide" title="'.$str->hide.'" href="'.$path.'/mod.php?hide='.$mod->id.
|
||||
'&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" '.
|
||||
' alt="'.$str->hide.'" /></a>'."\n";
|
||||
} else {
|
||||
$hideshow = '<a class="editing_show" title="'.$str->show.'" href="'.$path.'/mod.php?show='.$mod->id.
|
||||
'&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" '.
|
||||
' alt="'.$str->show.'" /></a>'."\n";
|
||||
}
|
||||
}
|
||||
if ($mod->groupmode !== false) {
|
||||
if ($mod->groupmode == SEPARATEGROUPS) {
|
||||
|
@ -2272,34 +2285,38 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-
|
|||
$groupmode = "";
|
||||
}
|
||||
|
||||
if ($moveselect) {
|
||||
$move = '<a class="editing_move" title="'.$str->move.'" href="'.$path.'/mod.php?copy='.$mod->id.
|
||||
'&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/move.gif" class="iconsmall" '.
|
||||
' alt="'.$str->move.'" /></a>'."\n";
|
||||
} else {
|
||||
$move = '<a class="editing_moveup" title="'.$str->moveup.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&move=-1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/up.gif" class="iconsmall" '.
|
||||
' alt="'.$str->moveup.'" /></a>'."\n".
|
||||
'<a class="editing_movedown" title="'.$str->movedown.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&move=1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/down.gif" class="iconsmall" '.
|
||||
' alt="'.$str->movedown.'" /></a>'."\n";
|
||||
if (has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $mod->course))) {
|
||||
if ($moveselect) {
|
||||
$move = '<a class="editing_move" title="'.$str->move.'" href="'.$path.'/mod.php?copy='.$mod->id.
|
||||
'&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/move.gif" class="iconsmall" '.
|
||||
' alt="'.$str->move.'" /></a>'."\n";
|
||||
} else {
|
||||
$move = '<a class="editing_moveup" title="'.$str->moveup.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&move=-1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/up.gif" class="iconsmall" '.
|
||||
' alt="'.$str->moveup.'" /></a>'."\n".
|
||||
'<a class="editing_movedown" title="'.$str->movedown.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&move=1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/down.gif" class="iconsmall" '.
|
||||
' alt="'.$str->movedown.'" /></a>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
$leftright = "";
|
||||
if ($indent > 0) {
|
||||
$leftright .= '<a class="editing_moveleft" title="'.$str->moveleft.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&indent=-1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/left.gif" class="iconsmall" '.
|
||||
' alt="'.$str->moveleft.'" /></a>'."\n";
|
||||
}
|
||||
if ($indent >= 0) {
|
||||
$leftright .= '<a class="editing_moveright" title="'.$str->moveright.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&indent=1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/right.gif" class="iconsmall" '.
|
||||
' alt="'.$str->moveright.'" /></a>'."\n";
|
||||
if (has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $mod->course))) {
|
||||
if ($indent > 0) {
|
||||
$leftright .= '<a class="editing_moveleft" title="'.$str->moveleft.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&indent=-1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/left.gif" class="iconsmall" '.
|
||||
' alt="'.$str->moveleft.'" /></a>'."\n";
|
||||
}
|
||||
if ($indent >= 0) {
|
||||
$leftright .= '<a class="editing_moveright" title="'.$str->moveright.'" href="'.$path.'/mod.php?id='.$mod->id.
|
||||
'&indent=1&sesskey='.$sesskey.$section.'"><img'.
|
||||
' src="'.$CFG->pixpath.'/t/right.gif" class="iconsmall" '.
|
||||
' alt="'.$str->moveright.'" /></a>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
return '<span class="commands">'."\n".$leftright.$move.
|
||||
|
|
|
@ -326,7 +326,7 @@
|
|||
}
|
||||
|
||||
require_login($cm->course); // needed to setup proper $COURSE
|
||||
$context = get_context_instance(CONTEXT_COURSE, $cm->course);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('moodle/course:activityvisibility', $context);
|
||||
|
||||
set_coursemodule_visible($cm->id, 0);
|
||||
|
@ -379,7 +379,7 @@
|
|||
}
|
||||
|
||||
require_login($cm->course); // needed to setup proper $COURSE
|
||||
$context = get_context_instance(CONTEXT_COURSE, $cm->course);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('moodle/course:manageactivities', $context);
|
||||
|
||||
set_coursemodule_groupmode($cm->id, $groupmode);
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
}
|
||||
|
||||
require_login($course->id); // needed to setup proper $COURSE
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('moodle/course:manageactivities', $context);
|
||||
|
||||
if (! $module = get_record("modules", "id", $cm->module)) {
|
||||
|
@ -167,7 +167,12 @@
|
|||
}
|
||||
|
||||
require_login($course->id); // needed to setup proper $COURSE
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (!empty($fromform->coursemodule)) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $fromform->coursemodule);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
}
|
||||
require_capability('moodle/course:manageactivities', $context);
|
||||
|
||||
$fromform->course = $course->id;
|
||||
|
@ -274,7 +279,11 @@
|
|||
exit;
|
||||
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if (!empty($cm->id)) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
}
|
||||
require_capability('moodle/course:manageactivities', $context);
|
||||
|
||||
$streditinga = get_string("editinga", "moodle", $fullmodulename);
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
|
||||
if ($USER->editing && !empty($USER->ajax) && !empty($CFG->enableajax) && $CFG->ajaxcapable) {
|
||||
|
||||
if (ajaxenabled()) {
|
||||
if (ajaxenabled() && has_capability('moodle/course:manageactivities', $context)) {
|
||||
|
||||
require_js(array('yui_yahoo',
|
||||
'yui_dom',
|
||||
|
@ -203,7 +203,7 @@
|
|||
|
||||
|
||||
// Use AJAX?
|
||||
if ($CFG->useajax) {
|
||||
if ($CFG->useajax && has_capability('moodle/course:manageactivities', $context)) {
|
||||
// At the bottom because we want to process sections and activities
|
||||
// after the relevant html has been generated. We're forced to do this
|
||||
// because of the way in which lib/ajax/ajaxcourse.js is written.
|
||||
|
|
|
@ -269,7 +269,6 @@ function blocks_print_group(&$page, &$pageblocks, $position) {
|
|||
}
|
||||
|
||||
$isediting = $page->user_is_editing();
|
||||
|
||||
foreach($pageblocks[$position] as $instance) {
|
||||
|
||||
// $instance may have ->rec and ->obj
|
||||
|
@ -337,7 +336,7 @@ function blocks_print_group(&$page, &$pageblocks, $position) {
|
|||
} // End foreach
|
||||
|
||||
|
||||
if ($page->blocks_default_position() == $position && $page->user_is_editing()) {
|
||||
if ($page->blocks_default_position() == $position && $page->user_is_editing() && has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
|
||||
blocks_print_adminblock($page, $pageblocks);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2202,7 +2202,29 @@ function isediting($courseid, $user=NULL) {
|
|||
if (empty($user->editing)) {
|
||||
return false;
|
||||
}
|
||||
return ($user->editing and has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $courseid)));
|
||||
|
||||
$capcheck = false;
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $coursecontext) ||
|
||||
has_capability('moodle/site:manageblocks', $coursecontext)) {
|
||||
$capcheck = true;
|
||||
} else {
|
||||
// loop through all child context, see if user has moodle/course:manageactivities or moodle/site:manageblocks
|
||||
if ($children = get_child_contexts($coursecontext)) {
|
||||
foreach ($children as $child) {
|
||||
$childcontext = get_record('context', 'id', $child);
|
||||
if (has_capability('moodle/course:manageactivities', $childcontext) ||
|
||||
has_capability('moodle/site:manageblocks', $childcontext)) {
|
||||
$capcheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ($user->editing && $capcheck);
|
||||
//return ($user->editing and has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $courseid)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -350,7 +350,27 @@ class page_course extends page_base {
|
|||
if (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM)) && defined('ADMIN_STICKYBLOCKS')) {
|
||||
return true;
|
||||
}
|
||||
return has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $this->id));
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $this->id);
|
||||
$capcheck = false;
|
||||
if (has_capability('moodle/course:manageactivities', $coursecontext) ||
|
||||
has_capability('moodle/site:manageblocks', $coursecontext)) {
|
||||
$capcheck = true;
|
||||
} else {
|
||||
// loop through all child context, see if user has moodle/course:manageactivities or moodle/site:manageblocks
|
||||
if ($children = get_child_contexts($coursecontext)) {
|
||||
foreach ($children as $child) {
|
||||
$childcontext = get_record('context', 'id', $child);
|
||||
if (has_capability('moodle/course:manageactivities', $childcontext) ||
|
||||
has_capability('moodle/site:manageblocks', $childcontext)) {
|
||||
$capcheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $capcheck;
|
||||
}
|
||||
|
||||
// Is the user actually editing this course page or "sticky page" right now?
|
||||
|
|
|
@ -3767,7 +3767,27 @@ function update_course_icon($courseid) {
|
|||
|
||||
global $CFG, $USER;
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $coursecontext) ||
|
||||
has_capability('moodle/site:manageblocks', $coursecontext)) {
|
||||
$capcheck = true;
|
||||
} else {
|
||||
// loop through all child context, see if user has moodle/course:manageactivities or moodle/site:manageblocks
|
||||
if ($children = get_child_contexts($coursecontext)) {
|
||||
foreach ($children as $child) {
|
||||
$childcontext = get_record('context', 'id', $child);
|
||||
if (has_capability('moodle/course:manageactivities', $childcontext) ||
|
||||
has_capability('moodle/site:manageblocks', $childcontext)) {
|
||||
$capcheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($capcheck) {
|
||||
if (!empty($USER->editing)) {
|
||||
$string = get_string('turneditingoff');
|
||||
$edit = '0';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue