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);
}
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");
}
}
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>";
$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) {
$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";
$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";