Permalink
Browse files

* $CFG->teachermanagepayments will have to go since we are moving awa…

…y from the rigid hardcoded teacher role concept.

* If a teacher has_capability('enrol/authorize:managepayments'), send email about pending orders expiring.

* All isteacher converted to has_capability.
  • Loading branch information...
1 parent 4503e31 commit 839958faf62ac5db903f8d79714127f1aa00b0cb ethem committed Aug 14, 2006
@@ -18,7 +18,6 @@
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);
@@ -59,12 +58,6 @@
</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>
@@ -117,6 +117,12 @@ function enrol_authorize_upgrade($oldversion=0) {
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;
}
@@ -128,6 +128,12 @@ function enrol_authorize_upgrade($oldversion=0) {
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;
}
View
@@ -477,7 +477,6 @@ function process_config($config)
// 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',
@@ -884,8 +883,8 @@ function cron_daily()
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;
@@ -914,8 +913,11 @@ function cron_daily()
$a->url = $CFG->wwwroot.'/enrol/authorize/index.php?course='.
$lastcourse.'&amp;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);
+ }
}
}
}
@@ -26,7 +26,8 @@ function authorize_print_orders()
$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;
}
@@ -182,8 +183,9 @@ function authorize_print_order_details($orderno)
}
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.");
}
}
@@ -1,6 +1,6 @@
<?PHP // $Id$
-$plugin->version = 2006081400;
+$plugin->version = 2006081401;
$plugin->requires = 2005072200;
?>

0 comments on commit 839958f

Please sign in to comment.