From abd896a114e4d34e4b223fbad5e368340331d30f Mon Sep 17 00:00:00 2001 From: vyshane Date: Fri, 11 Aug 2006 03:24:37 +0000 Subject: [PATCH] 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. --- admin/roles/assign.php | 21 +++++++++++---------- admin/user.php | 10 ++++++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/admin/roles/assign.php b/admin/roles/assign.php index c72aa71cfb..8c40b3f3bd 100755 --- a/admin/roles/assign.php +++ b/admin/roles/assign.php @@ -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); -?> +?> \ No newline at end of file diff --git a/admin/user.php b/admin/user.php index 7e906aa2f2..bbf79da5b0 100644 --- a/admin/user.php +++ b/admin/user.php @@ -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(); -- 2.39.5