From 146bbb8f2d9b5afa7363a5aba090a18a86922f86 Mon Sep 17 00:00:00 2001
From: moodler
Date: Sat, 26 Jun 2004 09:51:13 +0000
Subject: [PATCH] Some more additions to use the new enrolment architecture.
---
course/enrol.php | 21 +++++++++++++++++++++
course/lib.php | 19 +++++++++----------
2 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/course/enrol.php b/course/enrol.php
index 73aa213973..da7d2d4d31 100644
--- a/course/enrol.php
+++ b/course/enrol.php
@@ -23,6 +23,27 @@
$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()) {
diff --git a/course/lib.php b/course/lib.php
index ecdee0bf7a..90e2178594 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -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 "
";
}
- if ($course->guest) {
- $strallowguests = get_string("allowguests");
- echo "wwwroot/course/view.php?id=$course->id\">";
- echo "
pixpath/i/guest.gif\"> ";
- }
- if ($course->password) {
- $strrequireskey = get_string("requireskey");
- echo "wwwroot/course/view.php?id=$course->id\">";
- echo "
pixpath/i/key.gif\">";
- }
+ echo $enrol->get_access_icons($course);
echo "";
echo " ".filter_text(text_to_html($course->summary), $course->id)." ";
--
2.39.5
|