define("MAX_USERS_PER_PAGE", 5000);
$contextid = required_param('contextid',PARAM_INT); // context id
- $roleid = optional_param('roleid', 0, PARAM_INT); // required role id
+ $roleid = optional_param('roleid', 0, PARAM_INT); // required role id
$add = optional_param('add', 0, PARAM_BOOL);
$remove = optional_param('remove', 0, PARAM_BOOL);
$showall = optional_param('showall', 0, PARAM_BOOL);
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
$hidden = optional_param('hidden', 0, PARAM_BOOL); // whether this assignment is hidden
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
- $timestart = optional_param('timestart', 0, PARAM_INT);
+ $timestart = optional_param('timestart', 0, PARAM_INT);
$timeend = optional_param('timened', 0, PARAM_INT);
if (! $site = get_site()) {
if (! $context = get_record("context", "id", $contextid)) {
error("Context ID was incorrect (can't find it)");
}
+ if (!has_capability('moodle/role:assign', $context->id)) {
+ error('You do not have the required permission to assign roles to users.');
+ }
- /* permission check to see whether this user can assign people to this role
+ /**
+ * TO DO:
+ * Permission check to see whether this user can assign people to this role
* needs to be:
* 1) has the capability to assign
* 2) not in role_deny_grant
* end of permission checking
*/
- require_login($course->id);
-
- if (!isteacheredit($course->id)) {
- error("You must be an editing teacher in this course, or an admin");
- }
+ require_login();
$strassignusers = get_string('assignusers', 'role');
$strpotentialusers = get_string('potentialusers', 'role');
/// Don't allow restricted teachers to even see this page (because it contains
/// a lot of email addresses and access to all student on the server
- check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
+ check_for_restricted_user($USER->username, $CFG->wwwroot);
/// Print a help notice about the need to use this page
}
print_footer($course);
-?>
+?>
\ No newline at end of file
$admin->userid = $user->id;
+ /*
if (! insert_record("user_admins", $admin)) {
error("Could not make user $user->id an admin !!!");
}
+ */
if (! $user = get_record("user", "id", $user->id)) { // Double check.
error("User ID was incorrect (can't find it)");
set_config('rolesactive', 1);
- // Assign as a teacher in the site-level course.
if (! $site = get_site()) {
error("Could not find site-level course");
}
+
+
+ /*
+ // Assign as a teacher in the site-level course.
$teacher->userid = $user->id;
$teacher->course = $site->id;
$teacher->authority = 1;
if (! insert_record("user_teachers", $teacher)) {
error("Could not make user $id a teacher of site-level course !!!");
}
+ */
// Log the user in.
$USER->sessionIP = md5(getremoteaddr()); // Store the current IP in the session
$USER->site = $CFG->wwwroot;
$USER->admin = true;
- $USER->teacher["$site->id"] = true;
+ //$USER->teacher["$site->id"] = true;
$USER->newadminuser = true;
sesskey(); // For added security, used to check script parameters
load_user_capability();