* If a teacher has_capability('enrol/authorize:managepayments'), send email about pending orders expiring.
* All isteacher converted to has_capability.
if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2';
if (!isset($frm->an_emailexpiredteacher)) $frm->an_emailexpiredteacher = '';
if (!isset($frm->an_sorttype)) $frm->an_sorttype = 'ttl';
-if (!isset($frm->an_teachermanagepay)) $frm->an_teachermanagepay = '';
if (isset($CFG->an_cutoff)) {
$cutoff = intval($CFG->an_cutoff);
</td>
</tr>
-<tr valign="top">
- <td align="right">an_teachermanagepay:</td>
- <td><?php print_checkbox('an_teachermanagepay', '1', !empty($frm->an_teachermanagepay)) ?></td>
- <td><?php print_string("adminteachermanagepay", "enrol_authorize") ?></td>
-</tr>
-
<?php if (substr($CFG->wwwroot, 0, 5) !== 'https') { /* https && loginhttps */ ?>
<tr valign="top">
<td align="right">loginhttps:</td>
delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
}
+ if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
+ if (isset($CFG->an_teachermanagepay)) {
+ delete_records('config', 'name', 'an_teachermanagepay');
+ }
+ }
+
return $result;
}
delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
}
+ if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
+ if (isset($CFG->an_teachermanagepay)) {
+ delete_records('config', 'name', 'an_teachermanagepay');
+ }
+ }
+
return $result;
}
// optional authorize.net settings
set_config('an_avs', optional_param('an_avs', 0, PARAM_BOOL));
set_config('an_test', optional_param('an_test', 0, PARAM_BOOL));
- set_config('an_teachermanagepay', optional_param('an_teachermanagepay', 0, PARAM_BOOL));
set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL));
$acceptccs = optional_param('acceptccs',
email_to_user($adminuser, $adminuser, $subject, $message);
// Email to teachers
- if (empty($CFG->an_teachermanagepay) or empty($CFG->an_emailexpiredteacher)) {
- return; // teachers can't manage payments or email feature disabled for teachers.
+ if (empty($CFG->an_emailexpiredteacher)) {
+ return; // email feature disabled for teachers.
}
$sorttype = empty($CFG->an_sorttype) ? 'ttl' : $CFG->an_sorttype;
$a->url = $CFG->wwwroot.'/enrol/authorize/index.php?course='.
$lastcourse.'&status='.AN_STATUS_AUTH;
$message = get_string('pendingordersemailteacher', 'enrol_authorize', $a);
+ $context = get_context_instance(CONTEXT_COURSE, $lastcourse);
foreach ($teachers as $teacher) {
- email_to_user($teacher, $adminuser, $subject, $message);
+ if (has_capability('enrol/authorize:managepayments', $context, $teacher->id)) {
+ email_to_user($teacher, $adminuser, $subject, $message);
+ }
}
}
}
$perpage = 10;
$status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
- if (! isteacher($courseid)) {
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ if (! has_capability('enrol/authorize:managepayments', $context)) {
$userid = $USER->id;
}
}
if ($USER->id != $order->userid) { // Current user viewing someone else's order
- if (! isteacher($order->courseid)) {
- error("Students can view their order.");
+ $context = get_context_instance(CONTEXT_COURSE, $order->courseid);
+ if (! has_capability('enrol/authorize:managepayments', $context)) {
+ error("You don't have access rights on this order.");
}
}
<?PHP // $Id$
-$plugin->version = 2006081400;
+$plugin->version = 2006081401;
$plugin->requires = 2005072200;
?>