f9903ed0 |
1 | <?PHP // $Id$ |
2 | |
3 | // Display the course home page. |
4 | |
9fa49e22 |
5 | include_once("../config.php"); |
6 | include_once("lib.php"); |
f9903ed0 |
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 | |
388f8911 |
25 | require_login($id); |
26 | |
600149be |
27 | add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id"); |
f9903ed0 |
28 | |
0d97d1e3 |
29 | if ( isteacher($course->id) ) { |
f9903ed0 |
30 | if ($edit == "on") { |
31 | $USER->editing = true; |
32 | } else if ($edit == "off") { |
33 | $USER->editing = false; |
34 | } |
35 | } |
36 | if ($help == "on") { |
37 | $USER->help = true; |
38 | } else if ($help == "off") { |
39 | $USER->help = false; |
40 | } |
8223d271 |
41 | save_session("USER"); |
42 | |
4c701e6f |
43 | $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id"; |
44 | save_session("SESSION"); |
45 | |
b8391635 |
46 | if (! $course->category) { // This course is not a real course. |
47 | redirect("$CFG->wwwroot/"); |
48 | } |
49 | |
50 | |
fa0626c6 |
51 | $courseword = get_string("course"); |
52 | |
53 | print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true, |
5575a053 |
54 | update_course_icon($course->id)); |
f9903ed0 |
55 | |
94361e02 |
56 | get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts); |
19801b2b |
57 | |
58 | if (! $sections = get_all_sections($course->id)) { |
59 | $section->course = $course->id; // Create a default section. |
60 | $section->section = 0; |
61 | $section->id = insert_record("course_sections", $section); |
62 | if (! $sections = get_all_sections($course->id) ) { |
63 | error("Error finding or creating section structures for this course"); |
64 | } |
65 | } |
7468bf01 |
66 | |
f9903ed0 |
67 | switch ($course->format) { |
b5fe4c93 |
68 | case "weeks": |
f9903ed0 |
69 | include("weeks.php"); |
70 | break; |
b5fe4c93 |
71 | case "social": |
4567fb71 |
72 | include("social.php"); |
73 | break; |
b5fe4c93 |
74 | case "topics": |
0b35af18 |
75 | include("topics.php"); |
76 | break; |
4567fb71 |
77 | default: |
78 | error("Course format not defined yet!"); |
f9903ed0 |
79 | } |
80 | |
2c26c985 |
81 | print_footer(); |
f9903ed0 |
82 | |
f9903ed0 |
83 | ?> |