} else {
error('Invalid course id');
}
+ $coursecontext = $context;
+
} else if (!empty($courseid)){ // we need this for user tabs in user context
if (!$course = get_record('course', 'id', $courseid)) {
error('Invalid course id');
}
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
} else {
$courseid = SITEID;
$course = clone($SITE);
/// needed for tabs.php
$overridableroles = get_overridable_roles($context);
- $assignableroles = get_assignable_roles($context);
+ $assignableroles = get_assignable_roles($context); // Plain role names, may be altered later
+
/// Get some language strings
include_once('tabs.php');
}
+
+/// Rename some of the role names if needed
+ if (isset($coursecontext)) {
+ if ($aliasnames = get_records('role_names', 'contextid', $coursecontext->id)) {
+ foreach ($aliasnames as $alias) {
+ if (isset($assignableroles[$alias->roleid])) {
+ $assignableroles[$alias->roleid] = $alias->text.' ('.$assignableroles[$alias->roleid].')';
+ }
+ }
+ }
+ }
+
+
/// Process incoming role assignment
if ($frm = data_submitted()) {
if (!$course = get_record('course', 'id', $courseid)) {
error('Bad course ID');
}
+
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
} else {
$course = clone($SITE);
$courseid = SITEID;
include_once('tabs.php');
}
+/// Rename some of the role names if needed
+ if (isset($coursecontext)) {
+ if ($aliasnames = get_records('role_names', 'contextid', $coursecontext->id)) {
+ foreach ($aliasnames as $alias) {
+ if (isset($overridableroles[$alias->roleid])) {
+ $overridableroles[$alias->roleid] = $alias->text.' ('.$overridableroles[$alias->roleid].')';
+ }
+ }
+ }
+ }
+
+
print_heading_with_help(get_string('overrides', 'role'), 'overrides');
if ($roleid) {
require_login($course);
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // for role names later
+
$fullmodulename = get_string("modulename", $module->name);
$streditinga = get_string("editinga", "moodle", $fullmodulename);
$strmodulenameplural = get_string("modulenameplural", $module->name);
$navlinks[0] = array('name' => $course->shortname,
'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
'type' => 'misc');
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // for role names later
}
$navigation = build_navigation($navlinks);
print_header("$straction: $blockname", $course->fullname, $navigation);