Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

get_teacher() to get_users_by_capability(). Merged with HEAD.

  • Loading branch information...
commit 0b06840128bfb744fb3978bb5937c54f4a48ac42 1 parent 9abc42b
authored November 03, 2006
14  enrol/authorize/enrol.php
@@ -205,7 +205,7 @@ function cc_submit($form, $course)
205 205
             return;
206 206
         }
207 207
 
208  
-        if ($an_review) { // review enabled, inform site payment managers and redirect the user who have paid to main page.
  208
+        if ($an_review) { // review enabled, inform payment managers and redirect the user who have paid to main page.
209 209
             $a = new stdClass;
210 210
             $a->url = "$CFG->wwwroot/enrol/authorize/index.php?order=$order->id";
211 211
             $a->orderid = $order->id;
@@ -236,12 +236,14 @@ function cc_submit($form, $course)
236 236
             if (!empty($CFG->enrol_mailstudents)) {
237 237
                 send_welcome_messages($order->id);
238 238
             }
239  
-            $teacher = get_teacher($course->id);
240 239
             if (!empty($CFG->enrol_mailteachers)) {
  240
+                $context = get_context_instance(CONTEXT_COURSE, $course->id);
  241
+                $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
  242
+                $paymentmanager = array_shift($paymentmanagers);
241 243
                 $a = new stdClass;
242 244
                 $a->course = "$course->fullname";
243 245
                 $a->user = fullname($USER);
244  
-                email_to_user($teacher,
  246
+                email_to_user($paymentmanager,
245 247
                               $USER,
246 248
                               get_string("enrolmentnew", '', $course->shortname),
247 249
                               get_string('enrolmentnewuser', '', $a));
@@ -259,8 +261,7 @@ function cc_submit($form, $course)
259 261
                 }
260 262
             }
261 263
         } else {
262  
-            email_to_admin("Error while trying to enrol " .
263  
-            fullname($USER) . " in '$course->fullname'", $order);
  264
+            email_to_admin("Error while trying to enrol " . fullname($USER) . " in '$course->fullname'", $order);
264 265
         }
265 266
 
266 267
         if ($SESSION->wantsurl) {
@@ -268,7 +269,8 @@ function cc_submit($form, $course)
268 269
         } else {
269 270
             $destination = "$CFG->wwwroot/course/view.php?id=$course->id";
270 271
         }
271  
-        redirect($destination);
  272
+        load_all_capabilities();
  273
+        redirect($destination, get_string('paymentthanks', 'moodle', $course->fullname), 10);
272 274
     }
273 275
 
274 276
 
15  enrol/authorize/localfuncs.php
@@ -322,7 +322,7 @@ function send_welcome_messages($orderdata)
322 322
     global $CFG, $SITE;
323 323
 
324 324
     if (empty($orderdata)) {
325  
-    	return;
  325
+        return;
326 326
     }
327 327
 
328 328
     if (is_numeric($orderdata)) {
@@ -336,12 +336,11 @@ function send_welcome_messages($orderdata)
336 336
                ORDER BY e.userid";
337 337
 
338 338
     $emailinfo = get_records_sql($select);
339  
-    $emailcount = count($emailinfo);
340  
-    if ($emailcount == 1) {
  339
+    if (1 == count($emailinfo)) {
341 340
         $ei = reset($emailinfo);
342  
-        if (!$sender = get_teacher($ei->courseid)) {
343  
-            $sender = get_admin();
344  
-        }
  341
+        $context = get_context_instance(CONTEXT_COURSE, $ei->courseid);
  342
+        $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
  343
+        $sender = array_shift($paymentmanagers);
345 344
     }
346 345
     else {
347 346
         $sender = get_admin();
@@ -351,8 +350,8 @@ function send_welcome_messages($orderdata)
351 350
     while ($ei !== false) {
352 351
         $usercourses = array();
353 352
         $lastuserid = $ei->userid;
354  
-        for ($current = $ei; $current !== false && $current->userid == $lastuserid; $current = next($emailinfo)) {   
355  
-             $usercourses[] = $current->fullname;
  353
+        for ($current = $ei; $current !== false && $current->userid == $lastuserid; $current = next($emailinfo)) {
  354
+            $usercourses[] = $current->fullname;
356 355
         }
357 356
         $ei = $current;
358 357
         $a = new stdClass;

0 notes on commit 0b06840

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