* @return boolean
* @todo Finish documenting this function
*/
-function enrol_student($userid, $courseid, $timestart=0, $timeend=0) {
+function enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='manual') {
global $CFG;
$student->timestart = $timestart;
$student->timeend = $timeend;
$student->time = time();
+ $student->enrol = $enrol;
return update_record('user_students', $student);
-
+
} else {
require_once("$CFG->dirroot/mod/forum/lib.php");
forum_add_user($userid, $courseid);
$student->timestart = $timestart;
$student->timeend = $timeend;
$student->time = time();
+ $student->enrol = $enrol;
return insert_record('user_students', $student);
}
}
* @return boolean
* @todo Finish documenting this function
*/
-function add_teacher($userid, $courseid, $editall=1, $role='', $timestart=0, $timeend=0) {
+function add_teacher($userid, $courseid, $editall=1, $role='', $timestart=0, $timeend=0, $enrol='manual') {
global $CFG;
if ($teacher = get_record('user_teachers', 'userid', $userid, 'course', $courseid)) {
$newteacher = NULL;
$newteacher->id = $teacher->id;
$newteacher->editall = $editall;
+ $newteacher->enrol = $enrol;
if ($role) {
$newteacher->role = $role;
}
if (!record_exists('user_admins', 'userid', $userid)) {
if (record_exists('user', 'id', $userid)) {
$admin->userid = $userid;
-
+
// any admin is also a teacher on the site course
if (!record_exists('user_teachers', 'course', SITEID, 'userid', $userid)) {
if (!add_teacher($userid, SITEID)) {
return false;
}
}
-
+
return insert_record('user_admins', $admin);
}
return false;