diff --git a/enrol/authorize/action.php b/enrol/authorize/action.php index 196af10cbb7..fbb2e810de3 100644 --- a/enrol/authorize/action.php +++ b/enrol/authorize/action.php @@ -17,14 +17,11 @@ function getsettletime($time) { global $CFG; - $hrs = intval($CFG->an_cutoff_hour); - $mins = intval($CFG->an_cutoff_min); + $cutoff = intval($CFG->an_cutoff); $hrs = $cutoff / 60; $mins = $cutoff % 60; $cutofftime = strtotime("$hrs:$mins", $time); - if ($cutofftime < $time) { $cutofftime = strtotime("$hrs:$mins", $time + (24 * 3600)); } - return $cutofftime; } diff --git a/enrol/authorize/config.html b/enrol/authorize/config.html index 9bd06726030..d240323fbb4 100755 --- a/enrol/authorize/config.html +++ b/enrol/authorize/config.html @@ -15,6 +15,11 @@ if (!isset($frm->an_test)) $frm->an_test = ''; if (!isset($frm->an_review)) $frm->an_review = ''; if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5'; if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2'; + +if (isset($CFG->an_cutoff)) { + $frm->an_cutoff_hour = intval($CFG->an_cutoff) / 60; + $frm->an_cutoff_min = intval($CFG->an_cutoff) % 60; +} if (!isset($frm->an_cutoff_hour)) $frm->an_cutoff_hour = '0'; if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5'; diff --git a/enrol/authorize/db/mysql.php b/enrol/authorize/db/mysql.php index 3353bb27ff2..06301a8373c 100755 --- a/enrol/authorize/db/mysql.php +++ b/enrol/authorize/db/mysql.php @@ -79,11 +79,23 @@ function authorize_upgrade($oldversion=0) { execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false); } - if ($oldversion < 2006010200) { - if (isset($CFG->an_review_day)) { // rename an_review_day - set_config('an_capture_day', $CFG->an_review_day); - delete_records('config', 'name', 'an_review_day'); - } + if ($oldversion < 2006010200) { // rename an_review_day + if (isset($CFG->an_review_day)) { + set_config('an_capture_day', $CFG->an_review_day); + delete_records('config', 'name', 'an_review_day'); + } + } + + if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff + if (isset($CFG->an_cutoff_hour) && isset($CFG->an_cutoff_min)) { + $an_cutoff_hour = intval($CFG->an_cutoff_hour); + $an_cutoff_min = intval($CFG->an_cutoff_min); + $an_cutoff = ($an_cutoff_hour * 60) + $an_cutoff_min; + if (set_config('an_cutoff', $an_cutoff)) { + delete_records('config', 'name', 'an_cutoff_hour'); + delete_records('config', 'name', 'an_cutoff_min'); + } + } } return $result; diff --git a/enrol/authorize/db/postgres7.php b/enrol/authorize/db/postgres7.php index 7b0ce3bad5f..43985d13084 100644 --- a/enrol/authorize/db/postgres7.php +++ b/enrol/authorize/db/postgres7.php @@ -79,13 +79,25 @@ function authorize_upgrade($oldversion=0) { execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false); } - if ($oldversion < 2006010200) { - if (isset($CFG->an_review_day)) { // rename an_review_day + if ($oldversion < 2006010200) { // rename an_review_day + if (isset($CFG->an_review_day)) { set_config('an_capture_day', $CFG->an_review_day); delete_records('config', 'name', 'an_review_day'); } } + if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff + if (isset($CFG->an_cutoff_hour) && isset($CFG->an_cutoff_min)) { + $an_cutoff_hour = intval($CFG->an_cutoff_hour); + $an_cutoff_min = intval($CFG->an_cutoff_min); + $an_cutoff = ($an_cutoff_hour * 60) + $an_cutoff_min; + if (set_config('an_cutoff', $an_cutoff)) { + delete_records('config', 'name', 'an_cutoff_hour'); + delete_records('config', 'name', 'an_cutoff_min'); + } + } + } + return $result; } diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 835b1ebda08..3f8bca934a4 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -463,8 +463,10 @@ class enrolment_plugin extends enrolment_base set_config('an_avs', optional_param('an_avs', '')); set_config('an_test', optional_param('an_test', '')); set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL)); - set_config('an_cutoff_hour', optional_param('an_cutoff_hour', 0, PARAM_INT)); - set_config('an_cutoff_min', optional_param('an_cutoff_min', 5, PARAM_INT)); + + $cutoff_hour = optional_param('an_cutoff_hour', 0, PARAM_INT); + $cutoff_min = optional_param('an_cutoff_min', 5, PARAM_INT); + set_config('an_cutoff', $cutoff_hour * 60 + $cutoff_min); $reviewval = optional_param('an_review', ''); $captureday = optional_param('an_capture_day', 5, PARAM_INT); @@ -604,7 +606,7 @@ class enrolment_plugin extends enrolment_base } if (empty($CFG->an_review) || (!empty($CFG->an_test)) || - intval($CFG->an_capture_day < 1) || (!$this->check_openssl_loaded())) { + (intval($CFG->an_capture_day) < 1) || (!$this->check_openssl_loaded())) { return; } diff --git a/enrol/authorize/version.php b/enrol/authorize/version.php index ee4f9b9da75..1bc67c1ae6b 100755 --- a/enrol/authorize/version.php +++ b/enrol/authorize/version.php @@ -1,6 +1,6 @@ version = 2006010200; +$module->version = 2006020100; $module->requires = 2005072200; ?>