From 4503e31d9ad1b747363cf9a344d5127b9657eabc Mon Sep 17 00:00:00 2001 From: ethem Date: Mon, 14 Aug 2006 14:23:01 +0000 Subject: [PATCH] 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. --- enrol/authorize/locallib.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index ce52e6b1cd..98c5550892 100644 --- a/enrol/authorize/locallib.php +++ b/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'; -- 2.39.5