]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14617 removed legacy enrol and unenrol student code
authorskodak <skodak>
Thu, 1 May 2008 22:09:00 +0000 (22:09 +0000)
committerskodak <skodak>
Thu, 1 May 2008 22:09:00 +0000 (22:09 +0000)
enrol/flatfile/enrol.php
lib/deprecatedlib.php

index 2295c6b4bbede97013ff4b57cc9f5c6631e5adee..752beba7e5599832d8e883b330133bef031d2e70 100644 (file)
@@ -190,49 +190,6 @@ function get_access_icons($course) {
                         role_unassign($roleid, $user->id, null, $context->id);
                     }
                     
-                    /*
-                    switch ($fields[1]) {
-                        case "student":
-                            if ($fields[0] == "add") {
-                                if (! enrol_student($user->id, $course->id, $fields[4], $fields[5], 'flatfile')) {
-                                    $elog = "Error enrolling in course\n";
-                                }
-                            } else {
-                                if (! unenrol_student($user->id, $course->id)) {
-                                    $elog = "Error unenrolling from course\n";
-                                }
-                            }
-                            break;
-
-                        case "teacher":
-                            if ($fields[0] == "add") {
-                                if (! add_teacher($user->id, $course->id, 0, '', $fields[4], $fields[5], 'flatfile')) {
-                                    $elog = "Error adding teacher to course\n";
-                                }
-                            } else {
-                                if (! remove_teacher($user->id, $course->id)) {
-                                    $elog = "Error removing teacher from course\n";
-                                }
-                            }
-                            break;
-
-                        case "teacheredit":
-                            if ($fields[0] == "add") {
-                                if (! add_teacher($user->id, $course->id, 1, '', $fields[4], $fields[5], 'flatfile')) {
-                                    $elog = "Error adding teacher to course\n";
-                                }
-                            } else {
-                                if (! remove_teacher($user->id, $course->id)) {
-                                    $elog = "Error removing teacher from course\n";
-                                }
-                            }
-                            break;
-
-                        default: // should never get here as checks made above for correct values of $fields[1]
-
-                    } // end of switch*/
-
-
 
                     if ( empty($elog) and ($fields[0] == "add") ) {
    
index 4c368aab6fac095b3a10f14510a4dff18291c05e..cc4d20e134908e6fab5a41e49ef5a720d20dd2f8 100644 (file)
@@ -240,86 +240,6 @@ function isguest($userid=0) {
     return has_capability('moodle/legacy:guest', $context, $userid, false);
 }
 
-/**
- * Enrols (or re-enrols) a student in a given course
- *
- * NOTE: Defaults to 'manual' enrolment - enrolment plugins
- * must set it explicitly.
- *
- * @uses $CFG
- * @param int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user.
- * @param int $courseid The id of the course that is being viewed
- * @param int $timestart ?
- * @param int $timeend ?
- * @param string $enrol ?
- * @return bool
- */
-function enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='manual') {
-
-    global $CFG;
-
-    if (!$user = get_record('user', 'id', $userid)) {        // Check user
-        return false;
-    }
-
-    if (!$roles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-        return false;
-    }
-
-    $role = array_shift($roles);      // We can only use one, let's use the first one
-
-    if (!$context = get_context_instance(CONTEXT_COURSE, $courseid)) {
-        return false;
-    }
-
-    $res = role_assign($role->id, $user->id, 0, $context->id, $timestart, $timeend, 0, $enrol);
-
-    return $res;
-}
-
-/**
- * Unenrols a student from a given course
- *
- * @param int $courseid The id of the course that is being viewed, if any
- * @param int $userid The id of the user that is being tested against.
- * @return bool
- */
-function unenrol_student($userid, $courseid=0) {
-    global $CFG;
-
-    $status = true;
-
-    if ($courseid) {
-        /// First delete any crucial stuff that might still send mail
-        if ($forums = get_records('forum', 'course', $courseid)) {
-            foreach ($forums as $forum) {
-                delete_records('forum_subscriptions', 'forum', $forum->id, 'userid', $userid);
-            }
-        }
-        /// remove from all legacy student roles
-        if ($courseid == SITEID) {
-            $context = get_context_instance(CONTEXT_SYSTEM);
-        } else if (!$context = get_context_instance(CONTEXT_COURSE, $courseid)) {
-            return false;
-        }
-        if (!$roles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
-            return false;
-        }
-        foreach($roles as $role) {
-            $status = role_unassign($role->id, $userid, 0, $context->id) and $status;
-        }
-    } else {
-        // recursivelly unenroll student from all courses
-        if ($courses = get_records('course')) {
-            foreach($courses as $course) {
-                $status = unenrol_student($userid, $course->id) and $status;
-            }
-        }
-    }
-
-    return $status;
-}
-
 /**
  * Add a teacher to a given course
  *