$form->password = '';
}
+ if (empty($course->password)) {
+ // do not allow entry when no course password set
+ // automatic login when manual primary, no login when secondary at all!!
+ error("illegal enrolment attempted");
+ }
+
$groupid = $this->check_group_entry($course->id, $form->password);
if (($form->password == $course->password) or ($groupid !== false) ) {
$subject = get_string("welcometocourse", "", $course->fullname);
$a->coursename = $course->fullname;
- $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id";
+ $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id";
$message = get_string("welcometocoursetext", "", $a);
if (! $teacher = get_teacher($course->id)) {
/**
* Check if the given enrolment key matches a group enrolment key for the given course
*
-* Check if the given enrolment key matches a group enrolment key for the given course
-*
* @param courseid the current course id
* @param password the submitted enrolment key
*/
/**
* Processes and stored configuration data for the enrolment plugin
*
-* Processes and stored configuration data for the enrolment plugin
-*
* @param config all the configuration data as entered by the admin
*/
function process_config($config) {
/**
* Returns the relevant icons for a course
*
-* Returns the relevant icons for a course
-*
* @param course the current course, as an object
*/
function get_access_icons($course) {
//To avoid wrong (for PayPal) characters in sent data
function sanitise_for_paypal($text) {
- global $CFG;
-
- if (!empty($CFG->sanitise_for_paypal)) {
- //Array of characters to replace (not allowed by PayPal)
- //Can be expanded as necessary to add other diacritics
- $replace = array('á' => 'a', //Spanish characters
- 'é' => 'e',
- 'í' => 'i',
- 'ó' => 'o',
- 'ú' => 'u',
- 'Á' => 'A',
- 'É' => 'E',
- 'Í' => 'I',
- 'Ó' => 'O',
- 'Ú' => 'U',
- 'ñ' => 'n',
- 'Ñ' => 'N',
- 'ü' => 'u',
- 'Ü' => 'U');
- $text = strtr($text, $replace);
-
- //Make here other sanities if necessary
-
- }
-
+ $textlib = textlib_get_instance();
+ $text = $textlib->specialtoascii($text, current_charset());
+ // TODO: characters that have no ascii equivalents are not sanitized properly :-(
return $text;
+}
+/**
+* This function enables internal enrolment when PayPal is primary and course key is set at the same time.
+*
+* @param form the form data submitted, as an object
+* @param course the current course, as an object
+*/
+function check_entry($form, $course) {
+ $manual = enrolment_factory::factory('manual');
+ $manual->check_entry($form, $course);
+ if (isset($manual->errormsg)) {
+ $this->errormsg = $manual->errormsg;
+ }
}
+/**
+* Returns information about the courses a student has access to
+*
+* Set the $user->student course array
+* Set the $user->timeaccess course array
+*
+* @param user referenced object, must contain $user->id already set
+*/
+function get_student_courses(&$user) {
+ $manual = enrolment_factory::factory('manual');
+ $manual->get_student_courses($user);
+}
} // end of class definition
email_paypal_error_to_admin("Error while trying to insert valid transaction", $data);
}
- if (!enrol_student($user->id, $course->id)) { // Enrol the student
+ if ($course->enrolperiod) {
+ $timestart = time();
+ $timeend = time() + $course->enrolperiod;
+ } else {
+ $timestart = $timeend = 0;
+ }
+
+ if (!enrol_student($user->id, $course->id, $timestart, $timeend, 'manual')) {
email_paypal_error_to_admin("Error while trying to enrol ".fullname($user)." in '$course->fullname'", $data);
die;
} else {