fixing enrol_allowinternal

This commit is contained in:
ethem 2005-05-26 07:32:26 +00:00
parent b1e0c0f9fd
commit a0419f8716
2 changed files with 23 additions and 11 deletions

View file

@ -20,7 +20,7 @@
</td> </td>
</tr> </tr>
<tr valign="top"><td colspan="3"><hr noshade="noshade" size="1"></td></tr>
<tr valign="top"> <tr valign="top">
<td align="right">an_login:</td> <td align="right">an_login:</td>

View file

@ -18,12 +18,13 @@ class enrolment_plugin extends enrolment_base {
function print_entry($course) { function print_entry($course) {
global $CFG, $USER, $form; global $CFG, $USER, $form;
$strloginto = get_string("loginto", "", $course->shortname);
$strcourses = get_string("courses");
$teacher = get_teacher($course->id);
if ($this->zero_cost($course)) { if ($this->zero_cost($course)) {
parent::print_entry($course); if (!empty($CFG->enrol_allowinternal)) {
parent::print_entry($course);
} else {
print_header();
notice(get_string("enrolmentnointernal"), $CFG->wwwroot);
}
} else { } else {
// check payment // check payment
$this->check_paid(); $this->check_paid();
@ -35,6 +36,10 @@ function print_entry($course) {
exit; exit;
} }
$strloginto = get_string("loginto", "", $course->shortname);
$strcourses = get_string("courses");
$teacher = get_teacher($course->id);
print_header($strloginto, $course->fullname, "<a href=\"$CFG->wwwroot/course/\">$strcourses</a> -> $strloginto"); print_header($strloginto, $course->fullname, "<a href=\"$CFG->wwwroot/course/\">$strcourses</a> -> $strloginto");
print_course($course, "80%"); print_course($course, "80%");
print_simple_box_start("center"); print_simple_box_start("center");
@ -75,7 +80,12 @@ function print_entry($course) {
/// Override: check_entry() /// Override: check_entry()
function check_entry($form, $course) { function check_entry($form, $course) {
if ($this->zero_cost($course)) { if ($this->zero_cost($course)) {
parent::check_entry($form, $course); if (!empty($CFG->enrol_allowinternal)) {
parent::check_entry($form, $course);
} else {
print_header();
notice(get_string("enrolmentnointernal"), $CFG->wwwroot);
}
} else { } else {
$this->cc_submit($form, $course); $this->cc_submit($form, $course);
} }
@ -93,7 +103,9 @@ function cc_submit($form, $course)
return; return;
} }
if (! CCVal($form->cc, $form->cctype)) { $exp_date = (($form->ccexpiremm<10) ? strval('0'.$form->ccexpiremm) : strval($form->ccexpiremm)) . ($form->ccexpireyyyy);
if (! CCVal($form->cc, $form->cctype, $exp_date)) {
$this->errormsg = get_string("ccinvalid", "enrol_authorize"); $this->errormsg = get_string("ccinvalid", "enrol_authorize");
return; return;
} }
@ -122,7 +134,7 @@ function cc_submit($form, $course)
'x_card_code' => $form->cvv, 'x_card_code' => $form->cvv,
'x_currency_code' => $CFG->enrol_currency, 'x_currency_code' => $CFG->enrol_currency,
'x_amount' => $this->get_course_cost($course), 'x_amount' => $this->get_course_cost($course),
'x_exp_date' => (($form->ccexpiremm<10) ? strval('0'.$form->ccexpiremm) : strval($form->ccexpiremm)) . ($form->ccexpireyyyy), 'x_exp_date' => $exp_date,
'x_email' => $USER->email, 'x_email' => $USER->email,
'x_email_customer' => 'False', 'x_email_customer' => 'False',
'x_cust_id' => $USER->id, 'x_cust_id' => $USER->id,
@ -242,7 +254,7 @@ function cc_submit($form, $course)
// begin: authorize_table // begin: authorize_table
$cclast4 = substr($form->cc, -4); $cclast4 = substr($form->cc, -4);
$datax->cclastfour = ($cclast4 === false) ? '0000' : $cclast4; $datax->cclastfour = ($cclast4 === false) ? '0000' : $cclast4;
$datax->ccexp = $formdata['x_exp_date']; $datax->ccexp = $exp_date;
$datax->cvv = $form->cvv; $datax->cvv = $form->cvv;
$datax->ccname = $formdata['x_first_name'] . " " . $formdata['x_last_name']; $datax->ccname = $formdata['x_first_name'] . " " . $formdata['x_last_name'];
$datax->courseid = $course->id; $datax->courseid = $course->id;
@ -353,7 +365,7 @@ function config_form($frm) {
notify("an_tran_key or an_password required"); notify("an_tran_key or an_password required");
} }
} }
include("$CFG->dirroot/enrol/authorize/config.html"); include($CFG->dirroot.'/enrol/authorize/config.html');
} }
function check_openssl_loaded() { function check_openssl_loaded() {