Skip to content

Commit

Permalink
Roles support added: enrol/authorize:managepayments
Browse files Browse the repository at this point in the history
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
ethem committed Aug 14, 2006
1 parent 10f5c89 commit 4503e31
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions enrol/authorize/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand Down

0 comments on commit 4503e31

Please sign in to comment.