From 843d9bdc42c45bb861220ff18733151a6cc4389b Mon Sep 17 00:00:00 2001 From: ethem Date: Mon, 13 Mar 2006 16:47:44 +0000 Subject: [PATCH] Now, teachers can manage the payments in their courses if admin set up this. --- enrol/authorize/config.html | 7 +++++++ enrol/authorize/enrol.php | 3 ++- enrol/authorize/index.php | 36 ++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/enrol/authorize/config.html b/enrol/authorize/config.html index c643a32e12..55e190f089 100755 --- a/enrol/authorize/config.html +++ b/enrol/authorize/config.html @@ -15,6 +15,7 @@ if (!isset($frm->an_test)) $frm->an_test = ''; if (!isset($frm->an_review)) $frm->an_review = ''; if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5'; if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2'; +if (!isset($frm->an_teachermanagepay)) $frm->an_teachermanagepay = ''; if (isset($CFG->an_cutoff)) { $frm->an_cutoff_hour = intval($CFG->an_cutoff) / 60; @@ -102,6 +103,12 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5'; + + an_teachermanagepay: + an_teachermanagepay)) echo "checked=\"true\"" ?> /> + + + an_review: an_review)) echo "checked=\"true\"" ?> /> diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 5c4cbe0199..83de133447 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -7,7 +7,7 @@ require_once $CFG->dirroot.'/enrol/authorize/const.php'; * enrolment_plugin_authorize * */ -class enrolment_plugin_authorize +class enrolment_plugin_authorize { /** * Credit card error messages. @@ -467,6 +467,7 @@ class enrolment_plugin_authorize // optional authorize.net settings set_config('an_avs', optional_param('an_avs', '')); set_config('an_test', optional_param('an_test', '')); + set_config('an_teachermanagepay', optional_param('an_teachermanagepay', '')); set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL)); $cutoff_hour = optional_param('an_cutoff_hour', 0, PARAM_INT); diff --git a/enrol/authorize/index.php b/enrol/authorize/index.php index 394248bdbc..c483defea8 100644 --- a/enrol/authorize/index.php +++ b/enrol/authorize/index.php @@ -43,20 +43,17 @@ print_footer(); function authorize_orders() { - global $CFG; + global $CFG, $USER; global $strs, $authstrs; require_once $CFG->libdir.'/tablelib.php'; $perpage = 10; $userid = optional_param('user', 0, PARAM_INT); - $courseid = optional_param('course', 0, PARAM_INT); + $courseid = optional_param('course', SITEID, PARAM_INT); $status = optional_param('status', AN_STATUS_NONE, PARAM_INT); - if ($courseid == SITEID) { - $courseid = 0; // no filter - } - if (!isstudent($courseid, $userid) && !isteacher($courseid, $userid)) { - error("You must be a teacher/student to use this page."); + if (!isteacher($courseid)) { + $userid = $USER->id; } $baseurl = $CFG->wwwroot."/enrol/authorize/index.php?user=$userid"; @@ -122,7 +119,7 @@ function authorize_orders() if ($userid > 0) { $where .= "AND (userid = '" . $userid . "') "; } - if ($courseid > 0) { + if ($courseid != SITEID) { $where .= "AND (courseid = '" . $courseid . "') "; } @@ -198,9 +195,9 @@ function authorize_order_details($orderno) { return; } - if ($USER->id != $order->userid) { - if (! (isadmin() || isteacher($order->courseid, $order->userid))) { - error("Students can view their order."); + if ($USER->id != $order->userid) { // Current user viewing someone else's order + if (!isteacher($order->courseid)) { + error("Students can view their order."); } } @@ -489,12 +486,12 @@ function authorize_order_details($orderno) { function get_order_status_desc($order) { - global $CFG; + global $CFG, $USER; $ret = new stdClass(); if (intval($order->transid) == 0) { // test transaction - if (isadmin()) { + if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) { $ret->actions = array(ORDER_DELETE); } $ret->status = 'tested'; @@ -507,13 +504,13 @@ function get_order_status_desc($order) if (getsettletime($order->timecreated) < $timediff30) { $order->status = AN_STATUS_EXPIRE; update_record("enrol_authorize", $order); - if (isadmin()) { + if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) { $ret->actions = array(ORDER_DELETE); } $ret->status = 'expired'; } else { - if (isadmin()) { + if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) { $ret->actions = array(ORDER_CAPTURE, ORDER_VOID); } $ret->status = 'authorizedpendingcapture'; @@ -522,13 +519,13 @@ function get_order_status_desc($order) case AN_STATUS_AUTHCAPTURE: if (settled($order)) { - if (isadmin()) { + if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) { $ret->actions = array(ORDER_REFUND); } $ret->status = 'capturedsettled'; } else { - if (isadmin()) { + if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) { $ret->actions = array(ORDER_VOID); } $ret->status = 'capturedpendingsettle'; @@ -541,7 +538,7 @@ function get_order_status_desc($order) $ret->status = 'settled'; } else { - if (isadmin()) { + if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) { $ret->actions = array(ORDER_VOID); } $ret->status = 'refunded'; @@ -554,8 +551,7 @@ function get_order_status_desc($order) return $ret; case AN_STATUS_EXPIRE: - - if (isadmin()) { + if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) { $ret->actions = array(ORDER_DELETE); } $ret->status = 'expired'; -- 2.39.5