private function other_method_available($currentmethod) { $course = $this->_customdata['course']; if ($currentmethod == AN_METHOD_CC) { $otheravailable = in_array(AN_METHOD_ECHECK, get_list_of_payment_methods()); $url = 'enrol.php?id=' . $course->id . '&paymentmethod=' . AN_METHOD_ECHECK; $stringtofetch = 'usingecheckmethod'; } else { $otheravailable = in_array(AN_METHOD_CC, get_list_of_payment_methods()); $url = 'enrol.php?id=' . $course->id . '&paymentmethod=' . AN_METHOD_CC; $stringtofetch = 'usingccmethod'; } if ($otheravailable) { $a = new stdClass(); $a->url = $url; return get_string($stringtofetch, "enrol_authorize", $a); } else { return ''; } }
/** * process_config * * @param object $config * @return bool true if it will be saved. * @access public */ function process_config($config) { global $CFG; $mconfig = get_config('enrol/authorize'); // site settings if (($cost = optional_param('enrol_cost', 5, PARAM_INT)) > 0) { set_config('enrol_cost', $cost); } set_config('enrol_currency', optional_param('enrol_currency', 'USD', PARAM_ALPHA)); set_config('enrol_mailstudents', optional_param('enrol_mailstudents', 0, PARAM_BOOL)); set_config('enrol_mailteachers', optional_param('enrol_mailteachers', 0, PARAM_BOOL)); set_config('enrol_mailadmins', optional_param('enrol_mailadmins', 0, PARAM_BOOL)); // optional authorize.net settings set_config('an_avs', optional_param('an_avs', 0, PARAM_BOOL)); set_config('an_authcode', optional_param('an_authcode', 0, PARAM_BOOL)); set_config('an_test', optional_param('an_test', 0, PARAM_BOOL)); set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL)); $acceptmethods = optional_param('acceptmethods', get_list_of_payment_methods(), PARAM_ALPHA); set_config('an_acceptmethods', implode(',', $acceptmethods)); $acceptccs = optional_param('acceptccs', array_keys(get_list_of_creditcards()), PARAM_ALPHA); set_config('an_acceptccs', implode(',', $acceptccs)); $acceptechecktypes = optional_param('acceptechecktypes', get_list_of_bank_account_types(), PARAM_ALPHA); set_config('an_acceptechecktypes', implode(',', $acceptechecktypes)); $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); // cron depencies $reviewval = optional_param('an_review', 0, PARAM_BOOL); $captureday = optional_param('an_capture_day', 5, PARAM_INT); $emailexpired = optional_param('an_emailexpired', 2, PARAM_INT); $emailexpiredteacher = optional_param('an_emailexpiredteacher', 0, PARAM_BOOL); $sorttype = optional_param('an_sorttype', 'ttl', PARAM_ALPHA); $captureday = $captureday > 29 ? 29 : ($captureday < 0 ? 0 : $captureday); $emailexpired = $emailexpired > 5 ? 5 : ($emailexpired < 0 ? 0 : $emailexpired); if (!empty($reviewval) && ($captureday > 0 || $emailexpired > 0)) { $lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules'); if (time() - intval($lastcron) > 3600 * 24) { return false; } } set_config('an_review', $reviewval); set_config('an_capture_day', $captureday); set_config('an_emailexpired', $emailexpired); set_config('an_emailexpiredteacher', $emailexpiredteacher); set_config('an_sorttype', $sorttype); // https and openssl library is required if (substr($CFG->wwwroot, 0, 5) !== 'https' and empty($CFG->loginhttps) or !check_openssl_loaded()) { return false; } // REQUIRED fields; // an_login $loginval = optional_param('an_login', ''); if (empty($loginval) && empty($mconfig->an_login)) { return false; } $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', ''); $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($passwordval)) { set_config('an_password', $passwordval, 'enrol/authorize'); } if (empty($tranval) and empty($passwordval)) { return false; } if (!empty($tranval)) { set_config('an_tran_key', $tranval, 'enrol/authorize'); } return true; }
?> <br /> <?php print_string("antestmode", "enrol_authorize"); ?> </td> </tr> <tr valign="top"> <td align="right">accepts:</td> <td><?php print_string("adminaccepts", "enrol_authorize"); ?> <br /><br /><?php $paymentmethodsenabled = get_list_of_payment_methods(); $allpaymentmethods = get_list_of_payment_methods(true); foreach ($allpaymentmethods as $key) { if ($key == AN_METHOD_CC) { print_checkbox('acceptmethods[]', AN_METHOD_CC, in_array(AN_METHOD_CC, $paymentmethodsenabled), get_string('method' . AN_METHOD_CC, 'enrol_authorize')); echo "<ul>"; // blockquote breaks <span> and <br> tags $acceptedccs = array_keys(get_list_of_creditcards()); $allccs = get_list_of_creditcards(true); foreach ($allccs as $key => $val) { echo "<li>"; print_checkbox('acceptccs[]', $key, in_array($key, $acceptedccs), $val); echo "</li>"; } echo "</ul>"; } elseif ($key == AN_METHOD_ECHECK) { print_checkbox('acceptmethods[]', AN_METHOD_ECHECK, in_array(AN_METHOD_ECHECK, $paymentmethodsenabled), get_string('method' . AN_METHOD_ECHECK, 'enrol_authorize'));