]> git.mjollnir.org Git - moodle.git/commitdiff
Some more additions to use the new enrolment architecture.
authormoodler <moodler>
Sat, 26 Jun 2004 09:51:13 +0000 (09:51 +0000)
committermoodler <moodler>
Sat, 26 Jun 2004 09:51:13 +0000 (09:51 +0000)
course/enrol.php
course/lib.php

index 73aa213973357c52093c41c3762bf98391df5e01..da7d2d4d3146b2ac9b18616ede6a5f535bc2b3b4 100644 (file)
 
     $enrol = new enrolment_plugin();
 
+/// Refreshing enrolment data in the USER session
+    $enrol->get_student_courses($USER);
+    $enrol->get_teacher_courses($USER);
+
+
+/// Double check just in case they are actually enrolled already 
+/// This might occur if they were enrolled during this session
+
+    if ( $USER->student[$course->id] or $USER->teacher[$course->id] ) {
+
+        if ($SESSION->wantsurl) {
+            $destination = $SESSION->wantsurl;
+            unset($SESSION->wantsurl);
+        } else {
+            $destination = "$CFG->wwwroot/course/view.php?id=$course->id";
+        }
+
+        redirect($destination);
+    }
+
+
 /// Check the submitted enrollment key if there is one
 
     if ($form = data_submitted()) {
index ecdee0bf7a8636f996dc9649910ef40aaa33c423..90e2178594b871f7f512ae76d317e9f5c08b666d 100644 (file)
@@ -1102,10 +1102,18 @@ function print_course($course, $width="100%") {
 
     global $CFG, $THEME;
 
+    static $enrol;
+
+    if (empty($enrol)) {
+        require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
+        $enrol = new enrolment_plugin;
+    }
+
     if (! $site = get_site()) {
         error("Could not find a site!");
     }
 
+
     print_simple_box_start("center", "$width", $THEME->cellcontent, 5, "coursebox");
 
     $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
@@ -1128,17 +1136,8 @@ function print_course($course, $width="100%") {
         }
         echo "</font></p>";
     }
-    if ($course->guest) {
-        $strallowguests = get_string("allowguests");
-        echo "<a title=\"$strallowguests\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
-        echo "<img vspace=4 alt=\"$strallowguests\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/guest.gif\"></a>&nbsp;&nbsp;";
-    }
-    if ($course->password) {
-        $strrequireskey = get_string("requireskey");
-        echo "<a title=\"$strrequireskey\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
-        echo "<img vspace=4 alt=\"$strrequireskey\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/key.gif\"></a>";
-    }
 
+    echo $enrol->get_access_icons($course);
 
     echo "</td><td valign=top width=\"50%\" class=\"courseboxsummary\">";
     echo "<p><font size=2>".filter_text(text_to_html($course->summary), $course->id)."</font></p>";