Beispiel #1
0
 function validation($data, $files)
 {
     global $CFG;
     $errors = parent::validation($data, $files);
     if (AN_METHOD_CC == $data['paymentmethod']) {
         if (!in_array($data['cctype'], array_keys(get_list_of_creditcards()))) {
             $errors['cctype'] = get_string('missingcctype', 'enrol_authorize');
         }
         $expdate = sprintf("%02d", intval($data['ccexpiremm'])) . $data['ccexpireyyyy'];
         $validcc = $this->validate_cc($data['cc'], $data['cctype'], $expdate);
         if (!$validcc) {
             if ($validcc === 0) {
                 $errors['ccexpiregrp'] = get_string('ccexpired', 'enrol_authorize');
             } else {
                 $errors['cc'] = get_string('ccinvalid', 'enrol_authorize');
             }
         }
         if (!empty($CFG->an_authcode) && !empty($data['haveauth']) && empty($data['ccauthcode'])) {
             $errors['ccauthgrp'] = get_string('missingccauthcode', 'enrol_authorize');
         }
     } elseif (AN_METHOD_ECHECK == $data['paymentmethod']) {
         if (!$this->validate_aba($data['abacode'])) {
             $errors['abacode'] = get_string('invalidaba', 'enrol_authorize');
         }
         if (!in_array($data['acctype'], get_list_of_bank_account_types())) {
             $errors['acctype'] = get_string('invalidacctype', 'enrol_authorize');
         }
     }
     return $errors;
 }
Beispiel #2
0
 /**
  * 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;
 }
Beispiel #3
0
        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'));
        echo "<ul>";
        // blockquote breaks <span> and <br> tags
        $echecktypesenabled = get_list_of_bank_account_types();
        $allechecktypes = get_list_of_bank_account_types(true);
        foreach ($allechecktypes as $key) {
            echo "<li>";
            print_checkbox('acceptechecktypes[]', $key, in_array($key, $echecktypesenabled), get_string('echeck' . strtolower($key), 'enrol_authorize'));
            echo "</li>";
        }
        echo "</ul>";
    }
}
?>
<br /></td>
</tr>

<tr valign="top"><td colspan="2"><h4><?php 
print_string("adminauthorizeccapture", "enrol_authorize");
?>