]> git.mjollnir.org Git - moodle.git/commitdiff
Commented out code that adds the new admin user to user_admins and
authorvyshane <vyshane>
Fri, 11 Aug 2006 03:24:37 +0000 (03:24 +0000)
committervyshane <vyshane>
Fri, 11 Aug 2006 03:24:37 +0000 (03:24 +0000)
user_teachers tables from user.php.

Fixed notices in roles/assign.php.

admin/roles/assign.php
admin/user.php

index c72aa71cfbe0c49cbecc3b0b11606567e4bd7e16..8c40b3f3bd934eb4fcbf7ec8413ee87dec4345a0 100755 (executable)
@@ -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()) {
     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
 
     }
     print_footer($course);
 
-?>
+?>
\ No newline at end of file
index 7e906aa2f262ffb0a32c5f2f9e91737e52881ced..bbf79da5b08316978f7de4cec6c99ad60ae2f942 100644 (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.
@@ -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();