$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()) {
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\" ";
}
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> ";
- }
- 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>";