Permalink
Browse files

Tweaks to category display

  • Loading branch information...
martin
martin committed Sep 9, 2002
1 parent ba2e5d7 commit 0a263205322bb753defe709bb1a7de20827d1b4c
Showing with 40 additions and 13 deletions.
  1. +19 −8 course/index.php
  2. +19 −4 course/lib.php
  3. +2 −1 lang/en/moodle.php
View
@@ -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 = "<A HREF=\"index.php\">$strcourses</A> -> $thiscatname";
+ if ($category == "all") {
+ $title = $strfulllistofcourses;
+ $navigation = "<A HREF=\"index.php\">$strcourses</A> -> $title";
+ } else if ($category == "my") {
+ $title = $strmycourses;
+ $navigation = "<A HREF=\"index.php\">$strcourses</A> -> $title";
+ } else if (isset($categories[$category])) {
+ $title = $categories[$category]->name;
+ $navigation = "<A HREF=\"index.php\">$strcourses</A> -> $title";
} else {
$navigation = $strcourses;
}
+
print_header($strcourses, $strcourses, $navigation);
$showcategories = (count($categories) > 1);
if ($showcategories) {
echo "<TABLE WIDTH=\"100%\" CELLPADDING=10 BORDER=0>";
echo "<TR><TD WIDTH=180 VALIGN=TOP>";
- 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 "</TD><TD WIDTH=\"100%\" VALIGN=TOP>";
} else {
echo "<TABLE WIDTH=80% ALIGN=CENTER><TR><TD VALIGN=top>";
$category="all";
+ unset($title);
}
if ($category) {
- if ($category != "all") {
- print_simple_box($categories[$category]->name, "CENTER", "100%", $THEME->cellheading);
- echo "<BR>";
+ if (isset($title)) {
+ print_simple_box($title, "CENTER", "100%", $THEME->cellheading);
}
+ echo "<BR>";
print_all_courses($category);
}
View
@@ -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[]="<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>";
@@ -593,8 +605,11 @@ function print_course_categories($categories, $selected="none", $width=180) {
$catdata[]="<A HREF=\"$CFG->wwwroot/course/index.php?category=$cat->id\">$cat->name</A>";
}
}
- $showall = "<P><A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>...";
- print_side_block("", $catdata, $showall, $caticon, $width);
+ $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>";
+ if (isset($USER->id)) {
+ $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=my\">".get_string("mycourses")."</A>";
+ }
+ print_side_block("", $catdata, $showall.$mine, $caticon, $width);
}
function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
View
@@ -143,7 +143,7 @@
$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[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";

0 comments on commit 0a26320

Please sign in to comment.