Skip to content

Commit

Permalink
Pass custom data "$course" to enrol_authorize_form class.
Browse files Browse the repository at this point in the history
  • Loading branch information
ethem committed Feb 5, 2007
1 parent 1f7d43c commit 2542dea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion enrol/authorize/enrol.php
Expand Up @@ -74,7 +74,7 @@ function print_entry($course) {
}
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) {
Expand Down
49 changes: 25 additions & 24 deletions enrol/authorize/enrol_form.php
Expand Up @@ -6,7 +6,6 @@ class enrol_authorize_form extends moodleform
{
function definition()
{
global $course;
global $CFG, $USER;

$paymentmethodsenabled = get_list_of_payment_methods();
Expand All @@ -16,9 +15,10 @@ function definition()
}

$mform =& $this->_form;
$course = $this->_customdata['course'];

$mform->addElement('header', '', '  ' . 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>', '');
}

Expand Down Expand Up @@ -216,32 +216,33 @@ function validation($data)
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)) {
Expand Down

0 comments on commit 2542dea

Please sign in to comment.