Changes to support new logging format
[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
8
9 require_login($id);
10
11 if (! $course = get_record("course", "id", $id) ) {
12 error("That's an invalid course id");
13 }
14
f9903ed0 15 add_to_log("View course: $course->shortname", $id);
16
0d97d1e3 17 if ( isteacher($course->id) ) {
f9903ed0 18 if ($edit == "on") {
19 $USER->editing = true;
20 } else if ($edit == "off") {
21 $USER->editing = false;
22 }
23 }
24 if ($help == "on") {
25 $USER->help = true;
26 } else if ($help == "off") {
27 $USER->help = false;
28 }
29
21ddaf60 30 if (! $course->category) { // This course is not a real course.
31 redirect("$CFG->wwwroot");
32 }
33
f9903ed0 34 print_header("Course: $course->fullname", "$course->fullname", "$course->shortname", "");
35
36 if (! $modtypes = get_records_sql_menu("SELECT name,fullname FROM modules ORDER BY fullname") ) {
37 error("No modules are installed!");
38 }
39
40 if ( $rawmods = get_records_sql("SELECT cm.*, m.name as modname, m.fullname as modfullname
41 FROM modules m, course_modules cm
42 WHERE cm.course = '$course->id'
43 AND cm.deleted = '0'
44 AND cm.module = m.id") ) {
45
46 foreach($rawmods as $mod) { // Index the mods
47 $mods[$mod->id] = $mod;
48 $modtype[$mod->modname] = $mod->modfullname;
49 }
50 }
51
52 switch ($course->format) {
f9903ed0 53 case 1:
54 include("weeks.php");
55 break;
4567fb71 56 case 2:
57 include("social.php");
58 break;
59 default:
60 error("Course format not defined yet!");
f9903ed0 61 }
62
63 print_footer($course);
64
65
66/// FUNCTIONS ////////
67
68
69function make_editing_buttons($moduleid) {
70 return "&nbsp; &nbsp;
71 <A HREF=mod.php?delete=$moduleid><IMG
72 SRC=../pix/t/delete.gif BORDER=0 ALT=Delete></A>
73 <A HREF=mod.php?id=$moduleid&move=-1><IMG
74 SRC=../pix/t/up.gif BORDER=0 ALT=\"Move up\"></A>
75 <A HREF=mod.php?id=$moduleid&move=1><IMG
76 SRC=../pix/t/down.gif BORDER=0 ALT=\"Move down\"></A>
77 <A HREF=mod.php?update=$moduleid><IMG
78 SRC=../pix/t/edit.gif BORDER=0 ALT=Update></A>";
79}
80
81function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
82
83 echo "<TABLE WIDTH=100%>\n";
84 echo "<TR><TD COLSPAN=2><P><B><FONT SIZE=2>$heading</TD></TR>\n";
85 if ($list) {
86 foreach($list as $key => $string) {
87 echo "<TR><TD VALIGN=top WIDTH=12>";
88 if ($icons[$key]) {
89 echo $icons[$key];
90 } else {
91 echo "";
92 }
93 echo "</TD>\n<TD WIDTH=100%>";
94 echo "<P><FONT SIZE=1>$string</FONT></P>";
95 echo "</TD></TR>\n";
96 }
97 }
98 if ($footer) {
99 echo "<TR><TD></TD><TD ALIGN=left><P><FONT SIZE=2>$footer</TD></TR>\n";
100 }
101 echo "</TABLE><BR>\n\n";
102}
103
104?>