From: moodler Date: Sat, 9 Aug 2003 17:17:21 +0000 (+0000) Subject: My Courses is now shown in the course side block if the user is not X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f31200247f0f3b54715955c6258ebdfa5012b5be;p=moodle.git My Courses is now shown in the course side block if the user is not an admin. Also, this block now appears on course main pages (under admin). --- diff --git a/course/format/social.php b/course/format/social.php index 7188f7e6ca..a62297d073 100644 --- a/course/format/social.php +++ b/course/format/social.php @@ -48,6 +48,9 @@ /// Admin links and controls print_course_admin_links($course); +/// My courses + print_courses_sideblock(0, "$leftwidth"); + echo ""; echo ""; diff --git a/course/format/topics.php b/course/format/topics.php index 5709bab198..d2c5df4a90 100644 --- a/course/format/topics.php +++ b/course/format/topics.php @@ -84,6 +84,9 @@ /// Admin links and controls print_course_admin_links($course); +/// My courses + print_courses_sideblock(0, "180"); + /// Start main column echo ""; diff --git a/course/format/weeks.php b/course/format/weeks.php index b94ed72723..686a56fa84 100644 --- a/course/format/weeks.php +++ b/course/format/weeks.php @@ -73,6 +73,8 @@ /// Admin links and controls print_course_admin_links($course); +/// My courses + print_courses_sideblock(0, "180"); /// Start main column echo ""; diff --git a/course/lib.php b/course/lib.php index f6982eb703..c5ee595a4e 100644 --- a/course/lib.php +++ b/course/lib.php @@ -944,7 +944,7 @@ function print_category_info($category, $depth) { } function print_courses_sideblock($category=0, $width="100%") { - global $CFG, $THEME; + global $CFG, $THEME, $USER; if (empty($THEME->custompix)) { $icon = "wwwroot/pix/i/course.gif\"". @@ -954,6 +954,19 @@ function print_courses_sideblock($category=0, $width="100%") { " height=\"16\" width=\"16\" alt=\"".get_string("course")."\">"; } + if (isset($USER->id) and !isadmin()) { // Just print My Courses + if ($courses = get_my_courses($USER->id)) { + foreach ($courses as $course) { + $moddata[]="shortname\" ". + "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname"; + $modicon[]=$icon; + } + $fulllist = "

wwwroot/course/\">".get_string("fulllistofcourses")."..."; + print_side_block( get_string("mycourses"), "", $moddata, $modicon, $fulllist, $width); + return; + } + } + $categories = get_categories(0); // Parent = 0 ie top-level categories only if (count($categories) > 1) { // Just print top level category links foreach ($categories as $category) { @@ -980,7 +993,7 @@ function print_courses_sideblock($category=0, $width="100%") { } } - print_side_block(get_string("courses"), "", $moddata, $modicon, $fulllist, $width); + print_side_block( get_string("courses"), "", $moddata, $modicon, $fulllist, $width); }