Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Now, teachers can manage the payments in their courses if admin set u…

…p this.
  • Loading branch information...
commit 843d9bdc42c45bb861220ff18733151a6cc4389b 1 parent f95310d
ethem authored
View
7 enrol/authorize/config.html
@@ -15,6 +15,7 @@
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;
@@ -103,6 +104,12 @@
</tr>
<tr valign="top">
+ <td align="right">an_teachermanagepay:</td>
+ <td><input type="checkbox" value="1" name="an_teachermanagepay" <?php if (!empty($frm->an_teachermanagepay)) echo "checked=\"true\"" ?> /></td>
+ <td><?php print_string("adminteachermanagepay", "enrol_authorize") ?></td>
+</tr>
+
+<tr valign="top">
<td align="right">an_review:</td>
<td><input type="checkbox" value="1" name="an_review" <?php if (!empty($frm->an_review)) echo "checked=\"true\"" ?> />
<?php helpbutton('', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol_authorize',
View
3  enrol/authorize/enrol.php
@@ -7,7 +7,7 @@
* enrolment_plugin_authorize
*
*/
-class enrolment_plugin_authorize
+class enrolment_plugin_authorize
{
/**
* Credit card error messages.
@@ -467,6 +467,7 @@ function process_config($config)
// 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);
View
36 enrol/authorize/index.php
@@ -43,20 +43,17 @@
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';
Please sign in to comment.
Something went wrong with that request. Please try again.