]> git.mjollnir.org Git - moodle.git/commitdiff
Tweaks to category display
authormartin <martin>
Mon, 9 Sep 2002 12:37:34 +0000 (12:37 +0000)
committermartin <martin>
Mon, 9 Sep 2002 12:37:34 +0000 (12:37 +0000)
course/index.php
course/lib.php
lang/en/moodle.php

index 76675a7c3730aaa8331f4bcf2b7836e260531664..3e2238b8372ecf4f8c3af888ce701c077662c5e9 100644 (file)
@@ -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);
     }
 
index 9b31878cf265963360d7b23f2be1c233343d3f11..552e091b25620e2d8e9c25b872c40dd88d56c0d9 100644 (file)
@@ -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) {
index 3f8e07a7a4e4858b2e2acd197fbc4691025b0d99..395a019ad17aa4b4eade9ca5ddd4b1966c1c00fb 100644 (file)
@@ -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";