From 0a263205322bb753defe709bb1a7de20827d1b4c Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 9 Sep 2002 12:37:34 +0000 Subject: [PATCH] Tweaks to category display --- course/index.php | 27 +++++++++++++++++++-------- course/lib.php | 23 +++++++++++++++++++---- lang/en/moodle.php | 3 ++- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/course/index.php b/course/index.php index 76675a7c37..3e2238b837 100644 --- a/course/index.php +++ b/course/index.php @@ -4,39 +4,50 @@ require("../config.php"); require("lib.php"); - optional_variable($category, 0); + optional_variable($category, ""); $strcourses = get_string("courses"); + $strcategories = get_string("categories"); + $strmycourses = get_string("mycourses"); + $strfulllistofcourses = get_string("fulllistofcourses"); if (!$categories = get_all_categories()) { error("Could not find any course categories!"); } - if (isset($categories[$category])) { - $thiscatname = $categories[$category]->name; - $navigation = "$strcourses -> $thiscatname"; + if ($category == "all") { + $title = $strfulllistofcourses; + $navigation = "$strcourses -> $title"; + } else if ($category == "my") { + $title = $strmycourses; + $navigation = "$strcourses -> $title"; + } else if (isset($categories[$category])) { + $title = $categories[$category]->name; + $navigation = "$strcourses -> $title"; } else { $navigation = $strcourses; } + print_header($strcourses, $strcourses, $navigation); $showcategories = (count($categories) > 1); if ($showcategories) { echo ""; echo "
"; - print_simple_box(get_string("categories"), "CENTER", 180, $THEME->cellheading); + print_simple_box($strcategories, "CENTER", 180, $THEME->cellheading); print_course_categories($categories, $category, 180); echo ""; } else { echo "
"; $category="all"; + unset($title); } if ($category) { - if ($category != "all") { - print_simple_box($categories[$category]->name, "CENTER", "100%", $THEME->cellheading); - echo "
"; + if (isset($title)) { + print_simple_box($title, "CENTER", "100%", $THEME->cellheading); } + echo "
"; print_all_courses($category); } diff --git a/course/lib.php b/course/lib.php index 9b31878cf2..552e091b25 100644 --- a/course/lib.php +++ b/course/lib.php @@ -173,10 +173,22 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") { function print_all_courses($category="all", $style="full", $maxcount=999) { - global $CFG; + global $CFG, $USER; if ($category == "all") { $courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC"); + + } else if ($category == "my") { + if (isset($USER->id)) { + if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC")) { + foreach ($courses as $key => $course) { + if (!isteacher($course->id) and !isstudent($course->id)) { + unset($courses[$key]); + } + } + } + } + } else { $courses = get_records("course", "category", $category, "fullname ASC"); } @@ -583,7 +595,7 @@ function print_course_admin_links($course, $width=180) { } function print_course_categories($categories, $selected="none", $width=180) { - global $CFG, $THEME; + global $CFG, $THEME, $USER; foreach ($categories as $cat) { $caticon[]="wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>"; @@ -593,8 +605,11 @@ function print_course_categories($categories, $selected="none", $width=180) { $catdata[]="wwwroot/course/index.php?category=$cat->id\">$cat->name"; } } - $showall = "

wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."..."; - print_side_block("", $catdata, $showall, $caticon, $width); + $catdata[] = "wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses").""; + if (isset($USER->id)) { + $catdata[] = "wwwroot/course/index.php?category=my\">".get_string("mycourses").""; + } + print_side_block("", $catdata, $showall.$mine, $caticon, $width); } function print_log_graph($course, $userid=0, $type="course.png", $date=0) { diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 3f8e07a7a4..395a019ad1 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -143,7 +143,7 @@ $string[formattopics] = "Topics format"; $string[formatweeks] = "Weekly format"; $string[frontpagedescription] = "Front page description"; $string[frontpageformat] = "Front page format"; -$string[fulllistofcourses] = "Show all courses"; +$string[fulllistofcourses] = "All courses"; $string[fullprofile] = "Full profile"; $string[fullname] = "Full name"; $string[fullsitename] = "Full site name"; @@ -252,6 +252,7 @@ $string[moveup] = "Move up"; $string[movetoanotherfolder] = "Move to another folder"; $string[movefilestohere] = "Move files to here"; $string[mustconfirm] = "You need to confirm your login"; +$string[mycourses] = "My courses"; $string[name] = "Name"; $string[namesocial] = "section"; $string[nametopics] = "topic"; -- 2.39.5