]> git.mjollnir.org Git - moodle.git/commitdiff
Bug #5941 - Myriad of problems with Paypal enrollmemts, part 1; merged from MOODLE_16...
authorskodak <skodak>
Wed, 28 Jun 2006 12:45:28 +0000 (12:45 +0000)
committerskodak <skodak>
Wed, 28 Jun 2006 12:45:28 +0000 (12:45 +0000)
enrol/manual/enrol.php
enrol/paypal/enrol.php
enrol/paypal/ipn.php

index 28ff6aefb5de6332e58cd3502cbf0a7bb481caf4..0e216a8461dd72eda14fec567a3291cef5e31766 100644 (file)
@@ -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&amp;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) {
index 64908c74f10e214a726598f2ebd9f432ae948d1f..b4ad5de73c85f307411dd3521f8af896d2d593c1 100644 (file)
@@ -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
 
index ab33b51fe773f52207ab19ab05b2993c0abc015f..212123e7f1fc8cba99c5f48081b1d41cbba85055 100644 (file)
                 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 {