if ($courseid) {
$course = get_record('course', 'id', $courseid);
+ } else {
+ $course = $SITE;
}
- if (! $site = get_site()) {
- redirect("$CFG->wwwroot/$CFG->admin/index.php");
- }
-
if (! $context = get_context_instance_by_id($contextid)) {
error("Context ID was incorrect (can't find it)");
}
-
require_capability('moodle/role:assign', $context);
$assignableroles = get_assignable_roles($context);
+
+/// Get some language strings
+
$strassignusers = get_string('assignusers', 'role');
$strpotentialusers = get_string('potentialusers', 'role');
$strexistingusers = get_string('existingusers', 'role');
$strcurrentcontext = get_string('currentcontext', 'role');
$strsearch = get_string('search');
$strshowall = get_string('showall');
+ $strparticipants = get_string("participants");
error ('you can not override this role in this context');
}
}
-
- $participants = get_string("participants");
- $user = get_record('user', 'id', $userid);
- $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
+
+ if ($userid) {
+ $user = get_record('user', 'id', $userid);
+ $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
+ }
/// Print the header and tabs
if ($courseid!= SITEID) {
print_header("$fullname", "$fullname",
"<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> ->
- <a href=\"".$CFG->wwwroot."/user/index.php?id=$course->id\">$participants</a> -> <a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$courseid."\">$fullname</a> ->".$straction,
+ <a href=\"".$CFG->wwwroot."/user/index.php?id=$course->id\">$strparticipants</a> -> <a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$courseid."\">$fullname</a> ->".$straction,
"", "", true, " ", navmenu($course));
/// site header
} else { // Print overview table
+ $userparam = (!empty($userid)) ? '&userid='.$userid : '';
+
$table->tablealign = 'center';
$table->cellpadding = 5;
$table->cellspacing = 0;
if ($contextusers = get_role_users($roleid, $context)) {
$countusers = count($contextusers);
}
- $table->data[] = array('<a href="assign.php?contextid='.$context->id.'&roleid='.$roleid.'">'.$rolename.'</a>', $countusers);
+ $table->data[] = array('<a href="assign.php?contextid='.$context->id.'&roleid='.$roleid.$userparam.'">'.$rolename.'</a>', $countusers);
}
print_table($table);
print_footer($course);
-?>
\ No newline at end of file
+?>
if ($courseid) {
$course = get_record('course', 'id', $courseid);
+ } else {
+ $course = $SITE;
}
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
error ('can not override base role capabilities');
}
- if (! $site = get_site()) {
- redirect("$CFG->wwwroot/$CFG->admin/index.php");
- }
+/// Get some language strings
$strroletooverride = get_string('roletooverride', 'role');
$stroverrideusers = get_string('overrideusers', 'role');
$strcurrentcontext = get_string('currentcontext', 'role');
$strsearch = get_string('search');
$strshowall = get_string('showall');
+ $strparticipants = get_string("participants");
+ $straction = get_string('overrideroles', 'role');
$context = get_record('context', 'id', $contextid);
$overridableroles = get_overridable_roles($context);
- // role overriding permission checking
+/// Make sure this user can override that role
if ($roleid) {
if (!user_can_override($context, $roleid)) {
error ('you can not override this role in this context');
}
}
- $participants = get_string("participants");
- $user = get_record('user', 'id', $userid);
- $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
- $straction = get_string('overrideroles', 'role');
-
-
+ if ($userid) {
+ $user = get_record('user', 'id', $userid);
+ $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
+ }
- // we got a few tabs there
+/// Print the header and tabs
+
if ($context->aggregatelevel == CONTEXT_USER) {
/// course header
- if ($courseid!= SITEID) {
+ if ($course->id != SITEID) {
print_header("$fullname", "$fullname",
"<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> ->
- <a href=\"".$CFG->wwwroot."/user/index.php?id=$course->id\">$participants</a> -> <a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$courseid."\">$fullname</a> -> $straction",
+ <a href=\"".$CFG->wwwroot."/user/index.php?id=$course->id\">$strparticipants</a> -> <a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$course->id."\">$fullname</a> -> $straction",
"", "", true, " ", navmenu($course));
/// site header
} else {
print_header("$course->fullname: $fullname", "$course->fullname",
- "<a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$courseid."\">$fullname</a> -> $straction", "", "", true, " ", navmenu($course));
+ "<a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$course->id."\">$fullname</a> -> $straction", "", "", true, " ", navmenu($course));
}
$showroles = 1;
$currenttab = 'override';
}
- /*************************
- * form processing here *
- *************************/
+/// Process incoming role override
if ($data = data_submitted()) {
-
$localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
'', 'capability, permission, id');
}
} else { // Print overview table
+
+ $userparam = (!empty($userid)) ? '&userid='.$userid : '';
$table->tablealign = 'center';
$table->cellpadding = 5;
foreach ($overridableroles as $roleid => $rolename) {
$countusers = 0;
$overridecount = count_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id");
- $table->data[] = array('<a href="override.php?contextid='.$context->id.'&roleid='.$roleid.'">'.$rolename.'</a>', $overridecount);
+ $table->data[] = array('<a href="override.php?contextid='.$context->id.'&roleid='.$roleid.$userparam.'">'.$rolename.'</a>', $overridecount);
}
print_table($table);