Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…p this.
  • Loading branch information...
commit 843d9bdc42c45bb861220ff18733151a6cc4389b 1 parent f95310d
authored March 13, 2006
7  enrol/authorize/config.html
@@ -15,6 +15,7 @@
15 15
 if (!isset($frm->an_review)) $frm->an_review = '';
16 16
 if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5';
17 17
 if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2';
  18
+if (!isset($frm->an_teachermanagepay)) $frm->an_teachermanagepay = '';
18 19
 
19 20
 if (isset($CFG->an_cutoff)) {
20 21
     $frm->an_cutoff_hour = intval($CFG->an_cutoff) / 60;
@@ -103,6 +104,12 @@
103 104
 </tr>
104 105
 
105 106
 <tr valign="top">
  107
+    <td align="right">an_teachermanagepay:</td>
  108
+    <td><input type="checkbox" value="1" name="an_teachermanagepay" <?php if (!empty($frm->an_teachermanagepay)) echo "checked=\"true\"" ?> /></td>
  109
+    <td><?php print_string("adminteachermanagepay", "enrol_authorize") ?></td>
  110
+</tr>
  111
+
  112
+<tr valign="top">
106 113
     <td align="right">an_review:</td>
107 114
     <td><input type="checkbox" value="1" name="an_review" <?php if (!empty($frm->an_review)) echo "checked=\"true\"" ?> />
108 115
         <?php helpbutton('', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol_authorize',
3  enrol/authorize/enrol.php
@@ -7,7 +7,7 @@
7 7
  * enrolment_plugin_authorize
8 8
  *
9 9
  */
10  
-class enrolment_plugin_authorize 
  10
+class enrolment_plugin_authorize
11 11
 {
12 12
     /**
13 13
      * Credit card error messages.
@@ -467,6 +467,7 @@ function process_config($config)
467 467
         // optional authorize.net settings
468 468
         set_config('an_avs', optional_param('an_avs', ''));
469 469
         set_config('an_test', optional_param('an_test', ''));
  470
+        set_config('an_teachermanagepay', optional_param('an_teachermanagepay', ''));
470 471
         set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL));
471 472
 
472 473
         $cutoff_hour = optional_param('an_cutoff_hour', 0, PARAM_INT);
36  enrol/authorize/index.php
@@ -43,20 +43,17 @@
43 43
 
44 44
 function authorize_orders()
45 45
 {
46  
-    global $CFG;
  46
+    global $CFG, $USER;
47 47
     global $strs, $authstrs;
48 48
     require_once $CFG->libdir.'/tablelib.php';
49 49
 
50 50
     $perpage = 10;
51 51
     $userid = optional_param('user', 0, PARAM_INT);
52  
-    $courseid = optional_param('course', 0, PARAM_INT);
  52
+    $courseid = optional_param('course', SITEID, PARAM_INT);
53 53
     $status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
54  
-    if ($courseid == SITEID) {
55  
-    	$courseid = 0; // no filter
56  
-    }
57 54
 
58  
-    if (!isstudent($courseid, $userid) && !isteacher($courseid, $userid)) {
59  
-         error("You must be a teacher/student to use this page.");
  55
+    if (!isteacher($courseid)) {
  56
+        $userid = $USER->id;
60 57
     }
61 58
 
62 59
     $baseurl = $CFG->wwwroot."/enrol/authorize/index.php?user=$userid";
@@ -122,7 +119,7 @@ function authorize_orders()
122 119
     if ($userid > 0) {
123 120
         $where .= "AND (userid = '" . $userid . "') ";
124 121
     }
125  
-    if ($courseid > 0) {
  122
+    if ($courseid != SITEID) {
126 123
         $where .= "AND (courseid = '" . $courseid . "') ";
127 124
     }
128 125
 
@@ -198,9 +195,9 @@ function authorize_order_details($orderno) {
198 195
         return;
199 196
     }
200 197
 
201  
-    if ($USER->id != $order->userid) {
202  
-        if (! (isadmin() || isteacher($order->courseid, $order->userid))) {
203  
-            error("Students can view their order.");
  198
+    if ($USER->id != $order->userid) { // Current user viewing someone else's order
  199
+        if (!isteacher($order->courseid)) {
  200
+           error("Students can view their order.");
204 201
         }
205 202
     }
206 203
 
@@ -489,12 +486,12 @@ function authorize_order_details($orderno) {
489 486
 
490 487
 function get_order_status_desc($order)
491 488
 {
492  
-    global $CFG;
  489
+    global $CFG, $USER;
493 490
 
494 491
     $ret = new stdClass();
495 492
 
496 493
     if (intval($order->transid) == 0) { // test transaction
497  
-        if (isadmin()) {
  494
+        if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
498 495
         	$ret->actions = array(ORDER_DELETE);
499 496
         }
500 497
         $ret->status = 'tested';
@@ -507,13 +504,13 @@ function get_order_status_desc($order)
507 504
         if (getsettletime($order->timecreated) < $timediff30) {
508 505
             $order->status = AN_STATUS_EXPIRE;
509 506
             update_record("enrol_authorize", $order);
510  
-            if (isadmin()) {
  507
+            if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
511 508
             	$ret->actions = array(ORDER_DELETE);
512 509
             }
513 510
             $ret->status = 'expired';
514 511
         }
515 512
         else {
516  
-            if (isadmin()) {
  513
+            if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
517 514
             	$ret->actions = array(ORDER_CAPTURE, ORDER_VOID);
518 515
             }
519 516
             $ret->status = 'authorizedpendingcapture';
@@ -522,13 +519,13 @@ function get_order_status_desc($order)
522 519
 
523 520
     case AN_STATUS_AUTHCAPTURE:
524 521
         if (settled($order)) {
525  
-            if (isadmin()) {
  522
+            if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
526 523
             	$ret->actions = array(ORDER_REFUND);
527 524
             }
528 525
             $ret->status = 'capturedsettled';
529 526
         }
530 527
         else {
531  
-            if (isadmin()) {
  528
+            if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
532 529
             	$ret->actions = array(ORDER_VOID);
533 530
             }
534 531
             $ret->status = 'capturedpendingsettle';
@@ -541,7 +538,7 @@ function get_order_status_desc($order)
541 538
             $ret->status = 'settled';
542 539
         }
543 540
         else {
544  
-            if (isadmin()) {
  541
+            if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
545 542
             	$ret->actions = array(ORDER_VOID);
546 543
             }
547 544
             $ret->status = 'refunded';
@@ -554,8 +551,7 @@ function get_order_status_desc($order)
554 551
         return $ret;
555 552
 
556 553
     case AN_STATUS_EXPIRE:
557  
-
558  
-        if (isadmin()) {
  554
+        if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
559 555
         	$ret->actions = array(ORDER_DELETE);
560 556
         }
561 557
         $ret->status = 'expired';

0 notes on commit 843d9bd

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