From: skodak Date: Wed, 28 Jun 2006 12:45:28 +0000 (+0000) Subject: Bug #5941 - Myriad of problems with Paypal enrollmemts, part 1; merged from MOODLE_16... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=44adc9032b97f0636423f085c11572db2c7ea248;p=moodle.git Bug #5941 - Myriad of problems with Paypal enrollmemts, part 1; merged from MOODLE_16_STABLE --- diff --git a/enrol/manual/enrol.php b/enrol/manual/enrol.php index 28ff6aefb5..0e216a8461 100644 --- a/enrol/manual/enrol.php +++ b/enrol/manual/enrol.php @@ -210,6 +210,12 @@ function check_entry($form, $course) { $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) ) { @@ -240,7 +246,7 @@ function check_entry($form, $course) { $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)) { @@ -272,8 +278,6 @@ function check_entry($form, $course) { /** * 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 */ @@ -304,8 +308,6 @@ function config_form($page) { /** * 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) { @@ -406,8 +408,6 @@ function cron() { /** * 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) { diff --git a/enrol/paypal/enrol.php b/enrol/paypal/enrol.php index 64908c74f1..b4ad5de73c 100644 --- a/enrol/paypal/enrol.php +++ b/enrol/paypal/enrol.php @@ -174,35 +174,38 @@ function process_config($config) { //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 diff --git a/enrol/paypal/ipn.php b/enrol/paypal/ipn.php index ab33b51fe7..212123e7f1 100644 --- a/enrol/paypal/ipn.php +++ b/enrol/paypal/ipn.php @@ -150,7 +150,14 @@ 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 {