]> git.mjollnir.org Git - moodle.git/commitdiff
* $CFG->teachermanagepayments will have to go since we are moving away from the rigid...
authorethem <ethem>
Mon, 14 Aug 2006 15:06:11 +0000 (15:06 +0000)
committerethem <ethem>
Mon, 14 Aug 2006 15:06:11 +0000 (15:06 +0000)
* If a teacher has_capability('enrol/authorize:managepayments'), send email about pending orders expiring.

* All isteacher converted to has_capability.

enrol/authorize/config.html
enrol/authorize/db/mysql.php
enrol/authorize/db/postgres7.php
enrol/authorize/enrol.php
enrol/authorize/locallib.php
enrol/authorize/version.php

index 54ad840b233a4b06111f5ac5184aafbc4150a52c..ee5ad3c9b20996250883bb57904b1753fdebbd6b 100755 (executable)
@@ -18,7 +18,6 @@ if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5';
 if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2';
 if (!isset($frm->an_emailexpiredteacher)) $frm->an_emailexpiredteacher = '';
 if (!isset($frm->an_sorttype)) $frm->an_sorttype = 'ttl';
-if (!isset($frm->an_teachermanagepay)) $frm->an_teachermanagepay = '';
 
 if (isset($CFG->an_cutoff)) {
     $cutoff = intval($CFG->an_cutoff);
@@ -59,12 +58,6 @@ if (!isset($frm->acceptccs)) {
     </td>
 </tr>
 
-<tr valign="top">
-    <td align="right">an_teachermanagepay:</td>
-    <td><?php print_checkbox('an_teachermanagepay', '1', !empty($frm->an_teachermanagepay)) ?></td>
-    <td><?php print_string("adminteachermanagepay", "enrol_authorize") ?></td>
-</tr>
-
 <?php if (substr($CFG->wwwroot, 0, 5) !== 'https') { /* https && loginhttps */ ?>
 <tr valign="top">
     <td align="right">loginhttps:</td>
index 72976ed740ca021ed6c04399624a02ea7fbe9c01..de260e330e439e842923a511202dfb9b3b88cc67 100755 (executable)
@@ -117,6 +117,12 @@ function enrol_authorize_upgrade($oldversion=0) {
         delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
     }
 
+    if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
+        if (isset($CFG->an_teachermanagepay)) {
+            delete_records('config', 'name', 'an_teachermanagepay');
+        }
+    }
+
     return $result;
 }
 
index a5b2c4a73c007d093ea5ae7cbae7594f82f421aa..78aec0c5982e8591f9c84d94ae1228531d61743b 100644 (file)
@@ -128,6 +128,12 @@ function enrol_authorize_upgrade($oldversion=0) {
         delete_records('config_plugins', 'name', 'an_nextmail'); // run twice.
     }
 
+    if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7
+        if (isset($CFG->an_teachermanagepay)) {
+            delete_records('config', 'name', 'an_teachermanagepay');
+        }
+    }
+
     return $result;
 }
 
index df1c9870c12d863cf11a7c6ba885114e427152b3..6f0a5af8e403b5b4b8b32566000990aec0bfc387 100755 (executable)
@@ -477,7 +477,6 @@ class enrolment_plugin_authorize
         // optional authorize.net settings
         set_config('an_avs', optional_param('an_avs', 0, PARAM_BOOL));
         set_config('an_test', optional_param('an_test', 0, PARAM_BOOL));
-        set_config('an_teachermanagepay', optional_param('an_teachermanagepay', 0, PARAM_BOOL));
         set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL));
 
         $acceptccs = optional_param('acceptccs',
@@ -884,8 +883,8 @@ class enrolment_plugin_authorize
         email_to_user($adminuser, $adminuser, $subject, $message);
 
         // Email to teachers
-        if (empty($CFG->an_teachermanagepay) or empty($CFG->an_emailexpiredteacher)) {
-            return; // teachers can't manage payments or email feature disabled for teachers.
+        if (empty($CFG->an_emailexpiredteacher)) {
+            return; // email feature disabled for teachers.
         }
 
         $sorttype = empty($CFG->an_sorttype) ? 'ttl' : $CFG->an_sorttype;
@@ -914,8 +913,11 @@ class enrolment_plugin_authorize
                 $a->url = $CFG->wwwroot.'/enrol/authorize/index.php?course='.
                           $lastcourse.'&amp;status='.AN_STATUS_AUTH;
                 $message = get_string('pendingordersemailteacher', 'enrol_authorize', $a);
+                $context = get_context_instance(CONTEXT_COURSE, $lastcourse);
                 foreach ($teachers as $teacher) {
-                    email_to_user($teacher, $adminuser, $subject, $message);
+                    if (has_capability('enrol/authorize:managepayments', $context, $teacher->id)) {
+                        email_to_user($teacher, $adminuser, $subject, $message);
+                    }
                 }
             }
         }
index 98c5550892ec7285ad8d88b25df3237db04e45e4..0c8f72bfe7e07d75d0e0184067aec8d37c65d4b2 100644 (file)
@@ -26,7 +26,8 @@ function authorize_print_orders()
     $perpage = 10;
     $status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
 
-    if (! isteacher($courseid)) {
+    $context = get_context_instance(CONTEXT_COURSE, $courseid);
+    if (! has_capability('enrol/authorize:managepayments', $context)) {
         $userid = $USER->id;
     }
 
@@ -182,8 +183,9 @@ function authorize_print_order_details($orderno)
     }
 
     if ($USER->id != $order->userid) { // Current user viewing someone else's order
-        if (! isteacher($order->courseid)) {
-           error("Students can view their order.");
+        $context = get_context_instance(CONTEXT_COURSE, $order->courseid);
+        if (! has_capability('enrol/authorize:managepayments', $context)) {
+           error("You don't have access rights on this order.");
         }
     }
 
index 7b8e8c13c3eb3e47ce62b0611f80b79a2ea6c585..b00449357a83338a0f4d4e33813f038fde6a279a 100755 (executable)
@@ -1,6 +1,6 @@
 <?PHP // $Id$
 
-$plugin->version  = 2006081400;
+$plugin->version  = 2006081401;
 $plugin->requires = 2005072200;
 
 ?>