New translationd added.
[moodle.git] / course / view.php
blobc26a162bde1a324026af0e4323f6a10678d14a4f
1 <?PHP // $Id$
3 // Display the course home page.
5 require_once("../config.php");
6 require_once("lib.php");
8 optional_variable($id);
9 optional_variable($name);
11 if (!$id and !$name) {
12 error("Must specify course id or short name");
15 if ($name) {
16 if (! $course = get_record("course", "shortname", $name) ) {
17 error("That's an invalid short course name");
19 } else {
20 if (! $course = get_record("course", "id", $id) ) {
21 error("That's an invalid course id");
25 require_login($course->id);
27 add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
29 if (isteacher($course->id)) {
30 if (isset($edit)) {
31 if ($edit == "on") {
32 $USER->editing = true;
33 } else if ($edit == "off") {
34 $USER->editing = false;
38 if (isset($hide)) {
39 set_section_visible($course->id, $hide, "0");
42 if (isset($show)) {
43 set_section_visible($course->id, $show, "1");
46 if (!empty($section)) {
47 if (!empty($move)) {
48 move_section($course, $section, $move);
53 $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
55 if (! $course->category) { // This course is not a real course.
56 redirect("$CFG->wwwroot/");
59 if (empty($THEME->custompix)) {
60 $pixpath = "../pix";
61 $modpixpath = "../mod";
62 } else {
63 $pixpath = "../theme/$CFG->theme/pix";
64 $modpixpath = "../theme/$CFG->theme/pix/mod";
67 $courseword = get_string("course");
69 $loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
71 print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
72 update_course_icon($course->id), $loggedinas);
74 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
76 if (! $sections = get_all_sections($course->id)) { // No sections found
77 // Double-check to be extra sure
78 if (! $section = get_record("course_sections", "course", $course->id, "section", 0)) {
79 $section->course = $course->id; // Create a default section.
80 $section->section = 0;
81 $section->visible = 1;
82 $section->id = insert_record("course_sections", $section);
84 if (! $sections = get_all_sections($course->id) ) { // Try again
85 error("Error finding or creating section structures for this course");
89 if (!file_exists("$CFG->dirroot/course/format/$course->format.php")) { // Default format is weeks
90 $course->format = "weeks";
93 require("$CFG->dirroot/course/format/$course->format.php"); // Include the actual course format
95 print_footer();