Permalink
Browse files

Fixed: MDL-7561

New forms api
  • Loading branch information...
ethem
ethem committed Nov 15, 2006
1 parent e3bc106 commit f5fbea120f5f225c19af8076455db43edac1c7b5
Showing with 225 additions and 321 deletions.
  1. +23 −14 enrol/authorize/enrol.php
  2. +202 −209 enrol/authorize/enrol_form.php
  3. +0 −98 enrol/authorize/localfuncs.php
View
@@ -45,6 +45,7 @@ function print_entry($course) {
return;
}
+ prevent_double_paid($course);
httpsrequired();
if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') {
@@ -69,16 +70,31 @@ function print_entry($course) {
print_heading(get_string('choosemethod', 'enrol_authorize'), 'center');
}
- print_simple_box_start('center');
+ print_simple_box_start('center', '80%');
if (has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) {
$curcost = get_course_cost($course);
echo '<div align="center">';
echo '<p>'.get_string('paymentrequired').'</p>';
echo '<p><b>'.get_string('cost').": $curcost[currency] $curcost[cost]".'</b></p>';
echo '<p><a href="'.$CFG->httpswwwroot.'/login/">'.get_string('loginsite').'</a></p>';
echo '</div>';
- } else {
- include($CFG->dirroot.'/enrol/authorize/enrol_form.php');
+ }
+ else {
+ require_once($CFG->dirroot.'/enrol/authorize/enrol_form.php');
+ $authorize_enrol = new authorize_enrol_form('enrol.php');
+ if ($authorize_enrol->data_submitted() &&
+ (AN_METHOD_CC == $form->paymentmethod || AN_METHOD_ECHECK == $form->paymentmethod)) {
+ switch ($form->paymentmethod) {
+ case AN_METHOD_CC:
+ $this->cc_submit($form, $course);
+ break;
+
+ case AN_METHOD_ECHECK:
+ $this->echeck_submit($form, $course);
+ break;
+ }
+ }
+ $authorize_enrol->display();
}
print_simple_box_end();
@@ -110,17 +126,10 @@ function check_entry($form, $course)
$this->errormsg = $manual->errormsg;
}
}
- elseif (!empty($form->paymentmethod) && in_array($form->paymentmethod, get_list_of_payment_methods())) {
- if ($form->paymentmethod == AN_METHOD_CC && validate_cc_form($form, $this->authorizeerrors)) {
- $this->cc_submit($form, $course);
- }
- elseif($form->paymentmethod == AN_METHOD_ECHECK && validate_echeck_form($form, $this->authorizeerrors)) {
- $this->echeck_submit($form, $course);
- }
- }
}
+
/**
* The user submitted credit card form.
*
@@ -144,7 +153,7 @@ function cc_submit($form, $course)
$order = new stdClass();
$order->paymentmethod = AN_METHOD_CC;
$order->cclastfour = substr($form->cc, -4);
- $order->ccname = $form->ccfirstname . " " . $form->cclastname;
+ $order->ccname = $form->firstname . " " . $form->lastname;
$order->courseid = $course->id;
$order->userid = $USER->id;
$order->status = AN_STATUS_NONE; // it will be changed...
@@ -166,8 +175,8 @@ function cc_submit($form, $course)
$extra->x_exp_date = $exp_date;
$extra->x_currency_code = $curcost['currency'];
$extra->x_amount = $curcost['cost'];
- $extra->x_first_name = $form->ccfirstname;
- $extra->x_last_name = $form->cclastname;
+ $extra->x_first_name = $form->firstname;
+ $extra->x_last_name = $form->lastname;
$extra->x_country = $form->cccountry;
$extra->x_address = $form->ccaddress;
$extra->x_state = $form->ccstate;
Oops, something went wrong.

0 comments on commit f5fbea1

Please sign in to comment.