diff --git a/enrol/authorize/db/upgrade.php b/enrol/authorize/db/upgrade.php
index 500185fbb3e..9cf84b361a8 100644
--- a/enrol/authorize/db/upgrade.php
+++ b/enrol/authorize/db/upgrade.php
@@ -25,9 +25,38 @@ function xmldb_enrol_authorize_upgrade($oldversion=0) {
if ($result && $oldversion < 2006101701) {
$table = new XMLDBTable('enrol_authorize');
- $field = new XMLDBField('cclastfour');
- $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'paymentmethod');
- $result = $result && rename_field($table, $field, 'refundinfo');
+ if (!field_exists($table, new XMLDBField('refundinfo'))) {
+ $field = new XMLDBField('cclastfour');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'paymentmethod');
+ $result = $result && rename_field($table, $field, 'refundinfo');
+ }
+ }
+
+ if ($result && $oldversion < 2006101702) {
+ if (isset($CFG->an_login)) {
+ if (empty($CFG->an_login)) {
+ unset_config('an_login');
+ }
+ else {
+ $result = $result && set_config('an_login', rc4encrypt($CFG->an_login), 'enrol/authorize') && unset_config('an_login');
+ }
+ }
+ if (isset($CFG->an_tran_key)) {
+ if (empty($CFG->an_tran_key)) {
+ unset_config('an_tran_key');
+ }
+ else {
+ $result = $result && set_config('an_tran_key', rc4encrypt($CFG->an_tran_key), 'enrol/authorize') && unset_config('an_tran_key');
+ }
+ }
+ if (isset($CFG->an_password)) {
+ if (empty($CFG->an_password)) {
+ unset_config('an_password');
+ }
+ else {
+ $result = $result && set_config('an_password', rc4encrypt($CFG->an_password), 'enrol/authorize') && unset_config('an_password');
+ }
+ }
}
return $result;
diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php
index c2d261f3fa2..d94dacc786b 100755
--- a/enrol/authorize/enrol.php
+++ b/enrol/authorize/enrol.php
@@ -394,6 +394,7 @@ class enrolment_plugin_authorize
function config_form($frm)
{
global $CFG;
+ $mconfig = get_config('enrol/authorize');
if (! check_openssl_loaded()) {
notify('PHP must be compiled with SSL support (--with-openssl)');
@@ -416,7 +417,6 @@ class enrolment_plugin_authorize
$captureday = intval($frm->an_capture_day);
$emailexpired = intval($frm->an_emailexpired);
if ($captureday > 0 || $emailexpired > 0) {
- $mconfig = get_config('enrol/authorize');
if ((time() - intval($mconfig->an_lastcron) > 3600 * 24)) {
notify(get_string('admincronsetup', 'enrol_authorize'));
}
@@ -431,10 +431,10 @@ class enrolment_plugin_authorize
}
if (data_submitted()) {
- if (empty($frm->an_login)) {
+ if (empty($mconfig->an_login)) {
notify("an_login required");
}
- if (empty($frm->an_tran_key) && empty($frm->an_password)) {
+ if (empty($mconfig->an_tran_key) && empty($mconfig->an_password)) {
notify("an_tran_key or an_password required");
}
}
@@ -453,6 +453,7 @@ class enrolment_plugin_authorize
function process_config($config)
{
global $CFG;
+ $mconfig = get_config('enrol/authorize');
// site settings
if (($cost = optional_param('enrol_cost', 5, PARAM_INT)) > 0) {
@@ -490,7 +491,6 @@ class enrolment_plugin_authorize
$emailexpired = ($emailexpired > 5) ? 5 : (($emailexpired < 0) ? 0 : $emailexpired);
if (!empty($reviewval) && ($captureday > 0 || $emailexpired > 0)) {
- $mconfig = get_config('enrol/authorize');
if (time() - intval($mconfig->an_lastcron) > 3600 * 24) {
return false;
}
@@ -508,30 +508,35 @@ class enrolment_plugin_authorize
return false;
}
- // required fields
+ // REQUIRED fields;
+ // an_login
$loginval = optional_param('an_login', '');
- if (empty($loginval)) {
+ if (empty($loginval) && empty($mconfig->an_login)) {
return false;
}
- set_config('an_login', $loginval);
+ $loginval = !empty($loginval) ? rc4encrypt($loginval) : strval($mconfig->an_login);
+ set_config('an_login', $loginval, 'enrol/authorize');
+ // an_tran_key, an_password
$tranval = optional_param('an_tran_key', '');
+ $tranval = !empty($tranval) ? rc4encrypt($tranval) : (isset($mconfig->an_tran_key)?$mconfig->an_tran_key:'');
$passwordval = optional_param('an_password', '');
- $deletecurrent = optional_param('delete_current', '');
-
- if (!empty($passwordval)) { // password is changing
- set_config('an_password', $passwordval);
+ $passwordval = !empty($passwordval) ? rc4encrypt($passwordval) :(isset($mconfig->an_password)?$mconfig->an_password:'');
+ $deletecurrent = optional_param('delete_current', '0', PARAM_BOOL);
+ if (!empty($deletecurrent) and !empty($tranval)) {
+ unset_config('an_password', 'enrol/authorize');
+ $passwordval = '';
}
- elseif (!empty($deletecurrent) and !empty($tranval)) {
- set_config('an_password', '');
- $CFG->an_password = '';
+ elseif (!empty($passwordval)) {
+ set_config('an_password', $passwordval, 'enrol/authorize');
}
-
- if (empty($tranval) and empty($CFG->an_password)) {
+ if (empty($tranval) and empty($passwordval)) {
return false;
}
+ if (!empty($tranval)) {
+ set_config('an_tran_key', $tranval, 'enrol/authorize');
+ }
- set_config('an_tran_key', $tranval);
return true;
}
diff --git a/enrol/authorize/version.php b/enrol/authorize/version.php
index 256deede8c1..6db393460a6 100755
--- a/enrol/authorize/version.php
+++ b/enrol/authorize/version.php
@@ -1,6 +1,6 @@
version = 2006101701;
+$plugin->version = 2006101702;
$plugin->requires = 2006100401;
?>
diff --git a/lang/en_utf8/enrol_authorize.php b/lang/en_utf8/enrol_authorize.php
index e6116a9bce2..9e0da20bfd5 100644
--- a/lang/en_utf8/enrol_authorize.php
+++ b/lang/en_utf8/enrol_authorize.php
@@ -103,6 +103,7 @@ $string['invalidaba'] = 'Invalid ABA number';
$string['invalidaccnum'] = 'Invalid account number';
$string['invalidacctype'] = 'Invalid account type';
$string['logindesc'] = 'This option must be ON.
Please ensure that you have turned url\">loginhttps ON in Admin >> Variables >> Security.
Turning this on will make Moodle use a secure https connection just for the login and payment pages.';
+$string['logininfo'] = 'Login name, password and transaction key aren\'t shown due to security measure. There is no need to enter again if you have configured these fields before. You see a green text near the field if some fields were configured. If you enter first time these fields, the login name (*) is required and you must enter either the transaction key (#1) or the password (#2) in the appropriate box. We recommend you enter the transaction key due to more security measure. If you want to delete the current password tick the checkbox.';
$string['methodcc'] = 'Credit Card';
$string['methodecheck'] = 'eCheck (ACH)';
$string['missingaba'] = 'Missing ABA number';