Skip to content
Browse files

Roles support added: enrol/authorize:managepayments

TO DO:
* $CFG->an_teachermanagepay will be removed.
   XXX??? What will be do while sending email to teachers about pending orders expiring???
   If this feature enabled and a teacher no role in managepayments, this will send an email and the teacher cannot manage payments.
   Extra work: get_course_teachers and a teacher has_capability(at course level), send this email.

* convert isteacher to has_capability.
  • Loading branch information...
1 parent 10f5c89 commit 4503e31d9ad1b747363cf9a344d5127b9657eabc ethem committed Aug 14, 2006
Showing with 9 additions and 7 deletions.
  1. +9 −7 enrol/authorize/locallib.php
View
16 enrol/authorize/locallib.php
@@ -498,9 +498,11 @@ function authorize_get_status_action($order)
$ret = new stdClass();
$ret->actions = array();
+ $context = get_context_instance(CONTEXT_COURSE, $order->courseid);
+
if (intval($order->transid) == 0) { // test transaction or new order
if ($order->timecreated < $newordertime) {
- if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
+ if (has_capability('enrol/authorize:managepayments', $context)) {
$ret->actions = array(ORDER_DELETE);
}
$ret->status = 'tested';
@@ -514,13 +516,13 @@ function authorize_get_status_action($order)
switch ($order->status) {
case AN_STATUS_AUTH:
if (authorize_expired($order)) {
- if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
+ if (has_capability('enrol/authorize:managepayments', $context)) {
$ret->actions = array(ORDER_DELETE);
}
$ret->status = 'expired';
}
else {
- if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
+ if (has_capability('enrol/authorize:managepayments', $context)) {
$ret->actions = array(ORDER_CAPTURE, ORDER_VOID);
}
$ret->status = 'authorizedpendingcapture';
@@ -529,13 +531,13 @@ function authorize_get_status_action($order)
case AN_STATUS_AUTHCAPTURE:
if (authorize_settled($order)) {
- if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
+ if (has_capability('enrol/authorize:managepayments', $context)) {
$ret->actions = array(ORDER_REFUND);
}
$ret->status = 'capturedsettled';
}
else {
- if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
+ if (has_capability('enrol/authorize:managepayments', $context)) {
$ret->actions = array(ORDER_VOID);
}
$ret->status = 'capturedpendingsettle';
@@ -547,7 +549,7 @@ function authorize_get_status_action($order)
$ret->status = 'settled';
}
else {
- if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
+ if (has_capability('enrol/authorize:managepayments', $context)) {
$ret->actions = array(ORDER_VOID);
}
$ret->status = 'refunded';
@@ -559,7 +561,7 @@ function authorize_get_status_action($order)
return $ret;
case AN_STATUS_EXPIRE:
- if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
+ if (has_capability('enrol/authorize:managepayments', $context)) {
$ret->actions = array(ORDER_DELETE);
}
$ret->status = 'expired';

0 comments on commit 4503e31

Please sign in to comment.
Something went wrong with that request. Please try again.