mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36: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
|
@ -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) {
|
||||
|
@ -2271,35 +2284,39 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-
|
|||
} else {
|
||||
$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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue