Skip to content
Permalink
Browse files

SOme cleaning up of the code

  • Loading branch information...
moodler
moodler committed May 25, 2005
1 parent 14b7da1 commit f96e334571a079b9c0df20abf4e05b5f45583998
Showing with 42 additions and 31 deletions.
  1. +17 −11 enrol/authorize/config.html
  2. +25 −20 enrol/authorize/enrol.php
@@ -22,21 +22,27 @@




<tr valign="top">
<td align="right">an_login:</td>
<td>
<input type="text" name="an_login" value="<?php echo $frm->an_login ?>" />
<input type="text" name="an_login" value="<?php p($frm->an_login) ?>" />
</td>
<td>
<?php print_string("anlogin", "enrol_authorize") ?>
</td>
</tr>

<tr valign="top">
<td align="right"></td>
<td colspan="2">
<?php print_string("chooseone", "enrol_authorize") ?>
</td>
</tr>

<tr valign="top">
<td align="right">an_tran_key:</td>
<td>
<input type="text" name="an_tran_key" value="<?php echo $frm->an_tran_key ?>" />
<input type="text" name="an_tran_key" value="<?php p($frm->an_tran_key) ?>" />
</td>
<td>
<?php print_string("antrankey", "enrol_authorize") ?>
@@ -46,7 +52,7 @@
<tr valign="top">
<td align="right">an_password:</td>
<td>
<input type="text" name="an_password" value="<?php echo $frm->an_password ?>" />
<input type="text" name="an_password" value="<?php p($frm->an_password) ?>" />
</td>
<td>
<?php print_string("anpassword", "enrol_authorize") ?>
@@ -56,7 +62,7 @@
<tr valign="top">
<td align="right">an_referer:</td>
<td>
<input type="text" name="an_referer" value="<?php echo $frm->an_referer ?>" />
<input type="text" name="an_referer" value="<?php p($frm->an_referer) ?>" />
</td>
<td>
<?php print_string("anreferer", "enrol_authorize") ?>
@@ -66,19 +72,19 @@
<tr valign="top">
<td align="right">an_test:</td>
<td>
<input type="checkbox" value=1 name="an_test" <?php if ($frm->an_test) echo "checked=\"true\"" ?> />
<input type="checkbox" value="1" name="an_test" <?php if (!empty($frm->an_test)) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("antestmode", "enrol_authorize") ?>
</td>
</tr>

<tr valign="top"><td colspan="3"><hr noshade size="1"></td></tr>
<tr valign="top"><td colspan="3"><hr noshade="noshade" size="1"></td></tr>

<tr valign="top">
<td align="right">enrol_mailstudents:</td>
<td>
<input type="checkbox" value=1 name="enrol_mailstudents" <?php if ($frm->enrol_mailstudents) echo "checked=\"true\"" ?> />
<input type="checkbox" value=1 name="enrol_mailstudents" <?php if (!empty($frm->enrol_mailstudents)) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailstudents") ?>
@@ -88,7 +94,7 @@
<tr valign="top">
<td align="right">enrol_mailteachers:</td>
<td>
<input type="checkbox" value=1 name="enrol_mailteachers" <?php if ($frm->enrol_mailteachers) echo "checked=\"true\"" ?> />
<input type="checkbox" value=1 name="enrol_mailteachers" <?php if (!empty($frm->enrol_mailteachers)) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailteachers") ?>
@@ -98,7 +104,7 @@
<tr valign="top">
<td align="right">enrol_mailadmins:</td>
<td>
<input type="checkbox" value=1 name="enrol_mailadmins" <?php if ($frm->enrol_mailadmins) echo "checked=\"true\"" ?> />
<input type="checkbox" value=1 name="enrol_mailadmins" <?php if (!empty($frm->enrol_mailadmins)) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailadmins") ?>
@@ -108,7 +114,7 @@
<tr valign="top">
<td align="right">enrol_allowinternal:</td>
<td>
<input type="checkbox" value="1" name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
<input type="checkbox" value="1" name="enrol_allowinternal" <?php if (!empty($frm->enrol_allowinternal)) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string('allowinternal') ?>
@@ -45,7 +45,7 @@ function print_entry($course) {
$userlastname = $USER->lastname;
$useraddress = $USER->address;
$usercity = $USER->city;
$cost = $this->get_cource_cost($course);
$cost = $this->get_course_cost($course);
$CCTYPES = array(
'mcd' => 'Master Card',
@@ -121,7 +121,7 @@ function cc_submit($form, $course)
'x_card_num' => $form->cc,
'x_card_code' => $form->cvv,
'x_currency_code' => $CFG->enrol_currency,
'x_amount' => $this->get_cource_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_email' => $USER->email,
'x_email_customer' => 'False',
@@ -267,14 +267,14 @@ function cc_submit($form, $course)
function zero_cost($course) {
$cost = $this->get_cource_cost($course);
$cost = $this->get_course_cost($course);
if (abs($cost) < 0.01) { // no cost
return true;
}
return false;
}
function get_cource_cost($course) {
function get_course_cost($course) {
global $CFG;
$cost = (float)0;
@@ -294,7 +294,7 @@ function get_access_icons($course) {
global $CFG;
$str = '';
$cost = $this->get_cource_cost($course);
$cost = $this->get_course_cost($course);
if (abs($cost) < 0.01) {
$str = parent::get_access_icons($course);
@@ -334,29 +334,36 @@ function config_form($frm) {
$vars = array('enrol_cost', 'enrol_currency', 'an_login', 'an_tran_key', 'an_password', 'an_referer', 'an_test',
'enrol_mailstudents', 'enrol_mailteachers', 'enrol_mailadmins', 'enrol_allowinternal');
foreach ($vars as $var) {
if (!isset($frm->$var)) {
$frm->$var = '';
}
}
$this->check_openssl_loaded(false);
if (!$this->check_openssl_loaded()) {
notify('PHP must be compiled with SSL support (--with-openssl)');
}
if (data_submitted()) { // something POSTed
// Some required fields
if (empty($frm->an_login)) {
notify("an_login required");
}
if (empty($frm->an_tran_key) && empty($frm->an_password)) {
notify("an_tran_key or an_password required");
}
}
include("$CFG->dirroot/enrol/authorize/config.html");
}
function check_openssl_loaded($die)
{
if (!extension_loaded('openssl')) {
echo "<font color=red><center>PHP must be compiled --with-openssl</center></font>";
if ($die) {
die;
}
}
function check_openssl_loaded() {
return extension_loaded('openssl');
}
function process_config($config) {
$this->check_openssl_loaded(true);
$return = $this->check_openssl_loaded();
if (!isset($config->an_login)) {
$config->an_login = '';
}
@@ -374,12 +381,10 @@ function process_config($config) {
// Some required fields
if (empty($config->an_login)) {
echo "an_login required";
die;
$return = false;
}
if (empty($config->an_tran_key) && empty($config->an_password)) {
echo "an_tran_key or an_password required";
die;
$return = false;
}
if (empty($config->an_referer)) {
@@ -423,7 +428,7 @@ function process_config($config) {
}
set_config('enrol_allowinternal', $config->enrol_allowinternal);
return true;
return $return;
}
function email_cc_error_to_admin($subject, $data) {

0 comments on commit f96e334

Please sign in to comment.
You can’t perform that action at this time.