Commented out code that adds the new admin user to user_admins and

user_teachers tables from user.php.

Fixed notices in roles/assign.php.
This commit is contained in:
vyshane
2006-08-11 03:24:37 +00:00
parent 0c30fdc924
commit abd896a114
2 changed files with 19 additions and 12 deletions
+11 -10
View File
@@ -6,7 +6,7 @@
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);
@@ -14,7 +14,7 @@
$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()) {
@@ -24,19 +24,20 @@
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');
@@ -56,7 +57,7 @@
/// 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
@@ -150,4 +151,4 @@
}
print_footer($course);
?>
?>
+8 -2
View File
@@ -43,9 +43,11 @@
$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)");
@@ -58,16 +60,20 @@
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.
@@ -76,7 +82,7 @@
$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();