Add some comments
[moodle.git] / course / view.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
3// Display the course home page.
4
5 require("../config.php");
6 require("lib.php");
7
388f8911 8 optional_variable($id);
9 optional_variable($name);
f9903ed0 10
388f8911 11 if (!$id and !$name) {
12 error("Must specify course id or short name");
13 }
f9903ed0 14
388f8911 15 if ($name) {
16 if (! $course = get_record("course", "shortname", $name) ) {
17 error("That's an invalid short course name");
18 }
19 } else {
20 if (! $course = get_record("course", "id", $id) ) {
21 error("That's an invalid course id");
22 }
f9903ed0 23 }
24
effbcca2 25 if (! $course->category) { // This course is not a real course.
26 redirect("$CFG->wwwroot");
27 }
28
388f8911 29 require_login($id);
30
600149be 31 add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
f9903ed0 32
0d97d1e3 33 if ( isteacher($course->id) ) {
f9903ed0 34 if ($edit == "on") {
35 $USER->editing = true;
36 } else if ($edit == "off") {
37 $USER->editing = false;
38 }
39 }
40 if ($help == "on") {
41 $USER->help = true;
42 } else if ($help == "off") {
43 $USER->help = false;
44 }
8223d271 45 save_session("USER");
46
4c701e6f 47 $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
48 save_session("SESSION");
49
fa0626c6 50 $courseword = get_string("course");
51
52 print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
5575a053 53 update_course_icon($course->id));
f9903ed0 54
94361e02 55 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
97898ac9 56 $sections = get_all_sections($course->id);
7468bf01 57
f9903ed0 58 switch ($course->format) {
b5fe4c93 59 case "weeks":
f9903ed0 60 include("weeks.php");
61 break;
b5fe4c93 62 case "social":
4567fb71 63 include("social.php");
64 break;
b5fe4c93 65 case "topics":
0b35af18 66 include("topics.php");
67 break;
4567fb71 68 default:
69 error("Course format not defined yet!");
f9903ed0 70 }
71
2c26c985 72 print_footer();
f9903ed0 73
f9903ed0 74?>