]> git.mjollnir.org Git - moodle.git/commitdiff
* enrol_into_course() doesn't send welcome message unless $course->welcomemessage...
authorethem <ethem>
Tue, 3 Oct 2006 18:00:48 +0000 (18:00 +0000)
committerethem <ethem>
Tue, 3 Oct 2006 18:00:48 +0000 (18:00 +0000)
  This is actually good thing, because we can send our welcome message.

* enrol_into_course() added in Moodle(2006091700), so authorize plugin requires this version.

enrol/authorize/enrol.php
enrol/authorize/locallib.php
enrol/authorize/version.php

index 1ab01e1f2b2f3adfd44fa29ed282745909b19f47..a822d1f2043eb4b3d571559d8293fe09f463b097 100755 (executable)
@@ -234,6 +234,13 @@ class enrolment_plugin_authorize
         }
 
         // Credit card captured, ENROL student now...
+        if (!empty($CFG->enrol_mailstudents)) {
+            $a = new stdClass;
+            $a->courses = $course->fullname;
+            $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id";
+            $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$USER->id";
+            $course->welcomemessage = get_string('welcometocoursesemail', 'enrol_authorize', $a);
+        }
         if (enrol_into_course($course, $USER, 'manual')) {
             $teacher = get_teacher($course->id);
             if (!empty($CFG->enrol_mailteachers)) {
@@ -342,6 +349,13 @@ class enrolment_plugin_authorize
         }
 
         // ENROL student now ...
+        if (!empty($CFG->enrol_mailstudents)) {
+            $a = new stdClass;
+            $a->courses = $course->fullname;
+            $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id";
+            $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$USER->id";
+            $course->welcomemessage = get_string('welcometocoursesemail', 'enrol_authorize', $a);
+        }
         if (enrol_into_course($course, $USER, 'manual')) {
             $teacher = get_teacher($course->id);
             if (!empty($CFG->enrol_mailteachers)) {
@@ -643,7 +657,6 @@ class enrolment_plugin_authorize
                 }
                 $user = get_record('user', 'id', $order->userid);
                 if (role_assign($role->id, $user->id, 0, $context->id, $timestart, $timeend, 0, 'manual')) {
-                /// enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'manual');
                     $this->log .= "User($user->id) has been enrolled to course($course->id).\n";
                     if (!empty($CFG->enrol_mailstudents)) {
                         $sendem[] = $order->id;
index d26c866ee339a09b8a487d73e3ed0c9c8c14ac9f..47e160d67741b98f99767ad47071b8c08e59ef44 100644 (file)
@@ -171,11 +171,7 @@ function authorize_print_order_details($orderno)
     $table->size = array('30%', '70%');
     $table->align = array('right', 'left');
 
-    $sql = "SELECT e.*, c.shortname FROM {$CFG->prefix}enrol_authorize e " .
-           "INNER JOIN {$CFG->prefix}course c ON c.id = e.courseid " .
-           "WHERE e.id = '$orderno'";
-
-    $order = get_record_sql($sql);
+    $order = get_record('enrol_authorize', 'id', $orderno);
     if (!$order) {
         notice("Order $orderno not found.", "index.php");
         return;
@@ -204,7 +200,7 @@ function authorize_print_order_details($orderno)
     $table->data[] = array("<b>$authstrs->amount:</b>", "$order->currency $order->amount");
     if (empty($cmdcapture) and empty($cmdrefund) and empty($cmdvoid) and empty($cmddelete)) {
         $color = authorize_get_status_color($status->status);
-        $table->data[] = array("<b>$strs->course:</b>", $order->shortname);
+        $table->data[] = array("<b>$strs->course:</b>", $course->shortname);
         $table->data[] = array("<b>$strs->status:</b>", "<font style='color:$color'>" . $authstrs->{$status->status} . "</font>");
         if ($order->paymentmethod == AN_METHOD_CC) {
             $table->data[] = array("<b>$authstrs->nameoncard:</b>", $order->ccname);
@@ -242,12 +238,19 @@ function authorize_print_order_details($orderno)
             else {
                 if (empty($CFG->an_test)) {
                     $user = get_record('user', 'id', $order->userid);
+                    if (!empty($CFG->enrol_mailstudents)) {
+                        $a = new stdClass;
+                        $a->courses = $course->fullname;
+                        $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
+                        $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$user->id";
+                        $course->welcomemessage = get_string('welcometocoursesemail', 'enrol_authorize', $a);
+                    }
                     if (enrol_into_course($course, $user, 'manual')) {
                         redirect("index.php?order=$orderno");
                     }
                     else {
                         $table->data[] = array("<b><font color=red>$strs->error:</font></b>",
-                        "Error while trying to enrol ".fullname($user)." in '$order->shortname'");
+                        "Error while trying to enrol ".fullname($user)." in '$course->shortname'");
                     }
                 }
                 else {
@@ -305,7 +308,6 @@ function authorize_print_order_details($orderno)
                         else {
                             if (!empty($unenrol)) {
                                 role_unassign(0, $order->userid, 0, $coursecontext->id);
-                                //unenrol_student($order->userid, $order->courseid);
                             }
                             redirect("index.php?order=$orderno");
                         }
@@ -395,7 +397,6 @@ function authorize_print_order_details($orderno)
                         if (empty($CFG->an_test)) {
                             if (!empty($unenrol)) {
                                 role_unassign(0, $order->userid, 0, $coursecontext->id);
-                                //unenrol_student($order->userid, $order->courseid);
                             }
                             redirect("index.php?order=$orderno");
                         }
@@ -430,7 +431,6 @@ function authorize_print_order_details($orderno)
         else {
             if (!empty($unenrol)) {
                 role_unassign(0, $order->userid, 0, $coursecontext->id);
-                //unenrol_student($order->userid, $order->courseid);
             }
             delete_records('enrol_authorize', 'id', $orderno);
             redirect("index.php");
index d038af9a372b2b7b9591827bf8623f3129161371..abe785a6602b38b2254277cbe88d49cfe67cc337 100755 (executable)
@@ -1,6 +1,6 @@
 <?php // $Id$
 
 $plugin->version  = 2006083100;
-$plugin->requires = 2005072200;
+$plugin->requires = 2006091700;
 
 ?>