MDL-22388 Added some checks to kill these scripts dead with an unequivocal notice...
[moodle.git] / enrol / authorize / config_form.php
1 <?php
3 if (!defined('MOODLE_INTERNAL')) {
4     die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
5 }
8 if (!isset($frm->enrol_cost)) $frm->enrol_cost = '5';
9 if (!isset($frm->enrol_currency)) $frm->enrol_currency = 'USD';
10 if (!isset($frm->enrol_mailstudents)) $frm->enrol_mailstudents = '';
11 if (!isset($frm->enrol_mailteachers)) $frm->enrol_mailteachers = '';
12 if (!isset($frm->enrol_mailadmins)) $frm->enrol_mailadmins = '';
14 if (!isset($frm->an_login)) $frm->an_login = '';
15 if (!isset($frm->an_tran_key)) $frm->an_tran_key = '';
16 if (!isset($frm->an_password)) $frm->an_password = '';
17 if (!isset($frm->delete_current)) $frm->delete_current = '';
18 if (!isset($frm->an_referer)) $frm->an_referer = 'http://';
19 if (!isset($frm->an_avs)) $frm->an_avs = '';
20 if (!isset($frm->an_authcode)) $frm->an_authcode = '';
21 if (!isset($frm->an_test)) $frm->an_test = '';
22 if (!isset($frm->an_review)) $frm->an_review = '';
23 if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5';
24 if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2';
25 if (!isset($frm->an_emailexpiredteacher)) $frm->an_emailexpiredteacher = '';
26 if (!isset($frm->an_sorttype)) $frm->an_sorttype = 'ttl';
28 if (isset($CFG->an_cutoff)) {
29     $cutoff = intval($CFG->an_cutoff);
30     $mins = $cutoff % 60; $hrs = ($cutoff - $mins) / 60;
31     $frm->an_cutoff_hour = $hrs; $frm->an_cutoff_min = $mins;
32 }
33 if (!isset($frm->an_cutoff_hour)) {
34     $timezone = round(get_user_timezone_offset(), 1);
35     $frm->an_cutoff_hour = intval($timezone);
36     $frm->an_cutoff_min = (intval(round($timezone)) != intval($timezone)) ? 35 : 5;
37 }
39 if (!isset($frm->acceptmethods)) {
40     $frm->acceptmethods = get_list_of_payment_methods();
41     $CFG->an_acceptmethods = implode(',', $frm->acceptmethods);
42 }
44 if (!isset($frm->acceptccs)) {
45     $frm->acceptccs = array_keys(get_list_of_creditcards());
46     $CFG->an_acceptccs = implode(',', $frm->acceptccs);
47 }
49 if (!isset($frm->acceptechecktypes)) {
50     $frm->acceptechecktypes = get_list_of_bank_account_types();
51     $CFG->an_acceptechecktypes = implode(',', $frm->acceptechecktypes);
52 }
54 ?>
56 <table cellspacing="0" cellpadding="5" border="0" class="boxaligncenter">
58 <tr valign="top">
59     <td colspan="2" align="right"><a href="../enrol/authorize/index.php"><?php print_string("paymentmanagement", "enrol_authorize") ?></a></td>
60 </tr>
62 <tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizewide", "enrol_authorize") ?></h4></td></tr>
64 <tr valign="top">
65     <td align="right">enrol_cost:</td>
66     <td><input type="text" size="5" name="enrol_cost" value="<?php p($frm->enrol_cost) ?>" /><br />
67         <?php print_string("costdefault") ?>. <?php print_string("costdefaultdesc", "enrol_authorize") ?></td>
68 </tr>
70 <tr valign="top">
71     <td align="right">enrol_currency:</td>
72     <td><?php
73         echo html_writer::select(get_string_manager()->get_list_of_currencies(), "enrol_currency", $frm->enrol_currency, false);
74         ?>
75         <br />
76         <?php print_string("currency") ?>
77     </td>
78 </tr>
80 <tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizesettings", "enrol_authorize") ?></h4></td></tr>
82 <tr valign="top">
83     <td align="right">&nbsp;&nbsp;</td>
84     <td><?php print_string("logininfo", "enrol_authorize") ?><br />
85     <?php if (!optional_param('verifyaccount', 0, PARAM_INT) && isset($mconfig->an_login) && (isset($mconfig->an_tran_key) || isset($mconfig->an_password))) { ?>
86         <br /><a href="enrol_config.php?enrol=authorize&amp;verifyaccount=1"><b><?php print_string("verifyaccount", "enrol_authorize") ?></b></a><br />
87     <?php } ?></td>
88 </tr>
90 <tr valign="top">
91     <td align="right">an_login:<br /><?php echo (isset($mconfig->an_login)) ? '<span style="color:green">'.get_string('dataentered', 'enrol_authorize').'</span>' : ''; ?></td>
92     <td><?php print_string("anlogin", "enrol_authorize") ?><br /><input type="text" name="an_login" size="26" value="" /><sup>*</sup></td>
93 </tr>
95 <tr valign="top">
96     <td align="right">an_tran_key:<br /><?php echo (isset($mconfig->an_tran_key)) ? '<span style="color:green">'.get_string('dataentered', 'enrol_authorize').'</span>' : ''; ?></td>
97     <td><?php print_string("antrankey", "enrol_authorize") ?><br /><input type="text" name="an_tran_key" size="26" value="" /><sup>#1</sup></td>
98 </tr>
100 <tr valign="top">
101     <td align="right">an_password:<br /><?php echo (isset($mconfig->an_password)) ? '<span style="color:green">'.get_string('dataentered', 'enrol_authorize').'</span>' : ''; ?></td>
102     <td><?php print_string("anpassword", "enrol_authorize") ?><br /><input type="text" name="an_password" size="26" value="" /><sup>#2</sup></td>
103 </tr>
105 <tr valign="top">
106     <td align="right">delete_current:</td>
107     <td><?php echo html_writer::checkbox('delete_current', '1', !empty($frm->delete_current), get_string("deletecheck", "moodle", get_string('oldpassword')));?> <br />
108         <hr /></td>
109 </tr>
111 <tr valign="top">
112     <td align="right">an_referer:</td>
113     <td><input type="text" name="an_referer" size="35" value="<?php p($frm->an_referer) ?>" /><br />
114         <?php print_string("anreferer", "enrol_authorize") ?></td>
115 </tr>
117 <tr valign="top">
118     <td align="right">an_cutoff:</td>
119     <td><?php
120         $curtime = make_timestamp(2000,1,1,$frm->an_cutoff_hour,$frm->an_cutoff_min);
121         $hourselector = html_writer::select_time('hours', 'an_cutoff_hour', $curtime);
122         $minselector = html_writer::select_time('minutes', 'an_cutoff_min', $curtime);
123         echo $hourselector . $minselector;
124         ?><br />
125         <?php print_string("cutofftime", "enrol_authorize") ?></td>
126 </tr>
128 <tr valign="top">
129     <td align="right">an_avs:</td>
130     <td><?php echo html_writer::checkbox('an_avs', '1', !empty($frm->an_avs), get_string("adminavs", "enrol_authorize")); ?><br />
131     </td>
132 </tr>
134 <tr valign="top">
135     <td align="right">an_authcode:</td>
136     <td><?php echo html_writer::checkbox('an_authcode', '1', !empty($frm->an_authcode), get_string("adminauthcode", "enrol_authorize"));  ?>
137         <?php echo $OUTPUT->old_help_icon('authorize/authcode', 'authcode', 'enrol'); ?><br />
138     </td>
139 </tr>
141 <tr valign="top">
142     <td align="right">an_test:</td>
143     <td><?php echo html_writer::checkbox('an_test', '1', !empty($frm->an_test), get_string("antestmode", "enrol_authorize"));  ?><br />
144     </td>
145 </tr>
147 <tr valign="top">
148     <td align="right">accepts:</td>
149     <td><?php print_string("adminaccepts", "enrol_authorize") ?><br /><br /><?php
150     $paymentmethodsenabled = get_list_of_payment_methods();
151     $allpaymentmethods = get_list_of_payment_methods(true);
152     foreach ($allpaymentmethods as $key) {
153         if ($key == AN_METHOD_CC) {
154             echo html_writer::checkbox('acceptmethods[]', AN_METHOD_CC, in_array(AN_METHOD_CC, $paymentmethodsenabled), get_string('method'.AN_METHOD_CC,'enrol_authorize'));
155             echo("<ul>"); // blockquote breaks <span> and <br> tags
156             $acceptedccs = array_keys(get_list_of_creditcards());
157             $allccs = get_list_of_creditcards(true);
158             foreach ($allccs as $key => $val) {
159                 echo "<li>";
160                 echo html_writer::checkbox('acceptccs[]', $key, in_array($key, $acceptedccs), $val);
161                 echo "</li>";
162             }
163             echo("</ul>");
164         }
165         elseif ($key == AN_METHOD_ECHECK) {
166             echo html_writer::checkbox('acceptmethods[]', AN_METHOD_ECHECK, in_array(AN_METHOD_ECHECK, $paymentmethodsenabled), get_string('method'.AN_METHOD_ECHECK, 'enrol_authorize'));
167             echo("<ul>"); // blockquote breaks <span> and <br> tags
168             $echecktypesenabled = get_list_of_bank_account_types();
169             $allechecktypes = get_list_of_bank_account_types(true);
170             foreach ($allechecktypes as $key) {
171                 echo "<li>";
172                 echo html_writer::checkbox('acceptechecktypes[]', $key, in_array($key, $echecktypesenabled), get_string('echeck'.strtolower($key)));
173                 echo "</li>";
174             }
175             echo("</ul>");
176         }
177     }
178     ?><br /></td>
179 </tr>
181 <tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?>
182                                      <?php echo $OUTPUT->old_help_icon('authorize/orderreview', 'orderreview', 'enrol'); ?>
183                                  </h4></td></tr>
185 <tr valign="top">
186     <td align="right">an_review:</td>
187     <td><?php echo html_writer::checkbox('an_review', '1', !empty($frm->an_review), get_string("adminreview", "enrol_authorize")); ?>
188         <?php echo $OUTPUT->old_help_icon('authorize/review', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol'); ?><br />
189     </td>
190 </tr>
192 <tr valign="top">
193     <td align="right">an_capture_day:</td>
194     <td><input type="text" name="an_capture_day" size="2" maxlength="2" value="<?php p($frm->an_capture_day) ?>" />
195         <?php echo $OUTPUT->old_help_icon('authorize/captureday', get_string('adminhelpcapturetitle', 'enrol_authorize'), 'enrol'); ?><br />
196         <?php print_string("reviewday", "enrol_authorize", $frm->an_capture_day) ?></td>
197 </tr>
199 <tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizeemail", "enrol_authorize") ?></h4></td></tr>
201 <tr valign="top">
202     <td align="right">an_emailexpired:</td>
203     <td><input type="text" name="an_emailexpired" size="1" maxlength="1" value="<?php p($frm->an_emailexpired) ?>" /><br />
204         <?php print_string("adminemailexpired", "enrol_authorize", $frm->an_emailexpired) ?><br />
205         <?php print_string("adminemailexpsetting", "enrol_authorize") ?></td>
206 </tr>
208 <tr valign="top">
209     <td align="right">an_emailexpiredteacher:</td>
210     <td><?php echo html_writer::checkbox('an_emailexpiredteacher', '1', !empty($frm->an_emailexpiredteacher), get_string("adminemailexpiredteacher", "enrol_authorize"));  ?><br />
211     </td>
212 </tr>
214 <tr valign="top">
215     <td align="right">an_sorttype:</td>
216     <td><?php
217     $sorts = array('ttl' => get_string('adminemailexpiredsortsum', 'enrol_authorize'),
218                    'cnt' => get_string('adminemailexpiredsortcount', 'enrol_authorize'));
219     echo html_writer::select($sorts, "an_sorttype", $frm->an_sorttype, false);
220     ?>
221     <br />
222     <?php print_string("adminemailexpiredsort", "enrol_authorize") ?></td>
223 </tr>
225 <tr valign="top">
226     <td align="right">enrol_mailstudents:</td>
227     <td><?php echo html_writer::checkbox('enrol_mailstudents', '1', !empty($frm->enrol_mailstudents), get_string("mailstudents")); ?><br />
228     </td>
229 </tr>
231 <tr valign="top">
232     <td align="right">enrol_mailteachers:</td>
233     <td><?php echo html_writer::checkbox('enrol_mailteachers', '1', !empty($frm->enrol_mailteachers), get_string("mailteachers"));  ?><br />
234     </td>
235 </tr>
237 <tr valign="top">
238     <td align="right">enrol_mailadmins:</td>
239     <td><?php echo html_writer::checkbox('enrol_mailadmins', '1', !empty($frm->enrol_mailadmins), get_string("mailadmins"));  ?><br />
240     </td>
241 </tr>
243 </table>