]> git.mjollnir.org Git - moodle.git/commitdiff
Pass custom data "$course" to enrol_authorize_form class.
authorethem <ethem>
Mon, 5 Feb 2007 13:51:27 +0000 (13:51 +0000)
committerethem <ethem>
Mon, 5 Feb 2007 13:51:27 +0000 (13:51 +0000)
enrol/authorize/enrol.php
enrol/authorize/enrol_form.php

index cc0afe5659e7b571eeef3e4bff6ca6d852b0a2bc..cd89ebd86eef096fbd94d20017e003331420a56e 100755 (executable)
@@ -74,7 +74,7 @@ class enrolment_plugin_authorize
         }
         else {
             require_once($CFG->dirroot.'/enrol/authorize/enrol_form.php');
-            $frmenrol = new enrol_authorize_form();
+            $frmenrol = new enrol_authorize_form('enrol.php', compact('course'));
             if ($frmenrol->get_data()) {
                 $authorizeerror = '';
                 switch ($form->paymentmethod) {
index 67439100942b4bdb9483d7722d0831f01f1513fe..5a91b0eb0b6fa2b17d2701194e503fa744b0303c 100755 (executable)
@@ -6,7 +6,6 @@ class enrol_authorize_form extends moodleform
 {
     function definition()
     {
-        global $course;
         global $CFG, $USER;
 
         $paymentmethodsenabled = get_list_of_payment_methods();
@@ -16,9 +15,10 @@ class enrol_authorize_form extends moodleform
         }
 
         $mform =& $this->_form;
+        $course = $this->_customdata['course'];
 
         $mform->addElement('header', '', '&nbsp;&nbsp;' . get_string('paymentrequired'), '');
-        if ($othermethodstr = other_method($paymentmethod)) {
+        if ($othermethodstr = $this->other_method_available($paymentmethod)) {
             $mform->addElement('static', '', '<div align="right">' . $othermethodstr . '&nbsp;&nbsp;</div>', '');
         }
 
@@ -216,32 +216,33 @@ class enrol_authorize_form extends moodleform
         return (empty($errors) ? true : $errors);
     }
 
-}
-
-function other_method($currentmethod)
-{
-    global $course;
+    function other_method_available($currentmethod)
+    {
+        $course = $this->_customdata['course'];
 
-    if ($currentmethod == AN_METHOD_CC) {
-        $otheravailable = in_array(AN_METHOD_ECHECK, get_list_of_payment_methods());
-        $url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_ECHECK;
-        $stringtofetch = 'usingecheckmethod';
-    }
-    else {
-        $otheravailable = in_array(AN_METHOD_CC, get_list_of_payment_methods());
-        $url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_CC;
-        $stringtofetch = 'usingccmethod';
-    }
-    if ($otheravailable) {
-        $a = new stdClass;
-        $a->url = $url;
-        return get_string($stringtofetch, "enrol_authorize", $a);
-    }
-    else {
-       return '';
+        if ($currentmethod == AN_METHOD_CC) {
+            $otheravailable = in_array(AN_METHOD_ECHECK, get_list_of_payment_methods());
+            $url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_ECHECK;
+            $stringtofetch = 'usingecheckmethod';
+        }
+        else {
+            $otheravailable = in_array(AN_METHOD_CC, get_list_of_payment_methods());
+            $url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_CC;
+            $stringtofetch = 'usingccmethod';
+        }
+        if ($otheravailable) {
+            $a = new stdClass;
+            $a->url = $url;
+            return get_string($stringtofetch, "enrol_authorize", $a);
+        }
+        else {
+            return '';
+        }
     }
+
 }
 
+
 function ABAVal($aba)
 {
     if (ereg("^[0-9]{9}$", $aba)) {