Added missing parameter to update_module_icon (courseid)
[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
600149be 15 add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
f9903ed0 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
c629ec1b 34 print_header("Course: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
5575a053 35 update_course_icon($course->id));
f9903ed0 36
37 if (! $modtypes = get_records_sql_menu("SELECT name,fullname FROM modules ORDER BY fullname") ) {
38 error("No modules are installed!");
39 }
40
41 if ( $rawmods = get_records_sql("SELECT cm.*, m.name as modname, m.fullname as modfullname
42 FROM modules m, course_modules cm
43 WHERE cm.course = '$course->id'
44 AND cm.deleted = '0'
45 AND cm.module = m.id") ) {
46
47 foreach($rawmods as $mod) { // Index the mods
48 $mods[$mod->id] = $mod;
49 $modtype[$mod->modname] = $mod->modfullname;
50 }
13c7e271 51 ksort($modtype);
f9903ed0 52 }
53
54 switch ($course->format) {
b5fe4c93 55 case "weeks":
f9903ed0 56 include("weeks.php");
57 break;
b5fe4c93 58 case "social":
4567fb71 59 include("social.php");
60 break;
b5fe4c93 61 case "topics":
0b35af18 62 include("topics.php");
63 break;
4567fb71 64 default:
65 error("Course format not defined yet!");
f9903ed0 66 }
67
68 print_footer($course);
69
70
71/// FUNCTIONS ////////
72
73
74function make_editing_buttons($moduleid) {
75 return "&nbsp; &nbsp;
76 <A HREF=mod.php?delete=$moduleid><IMG
77 SRC=../pix/t/delete.gif BORDER=0 ALT=Delete></A>
78 <A HREF=mod.php?id=$moduleid&move=-1><IMG
79 SRC=../pix/t/up.gif BORDER=0 ALT=\"Move up\"></A>
80 <A HREF=mod.php?id=$moduleid&move=1><IMG
81 SRC=../pix/t/down.gif BORDER=0 ALT=\"Move down\"></A>
82 <A HREF=mod.php?update=$moduleid><IMG
83 SRC=../pix/t/edit.gif BORDER=0 ALT=Update></A>";
84}
85
86function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
87
88 echo "<TABLE WIDTH=100%>\n";
89 echo "<TR><TD COLSPAN=2><P><B><FONT SIZE=2>$heading</TD></TR>\n";
90 if ($list) {
91 foreach($list as $key => $string) {
92 echo "<TR><TD VALIGN=top WIDTH=12>";
93 if ($icons[$key]) {
94 echo $icons[$key];
95 } else {
96 echo "";
97 }
77775bff 98 echo "</TD>\n<TD WIDTH=100% VALIGN=top>";
e07635f4 99 echo "<P><FONT SIZE=2>$string</FONT></P>";
f9903ed0 100 echo "</TD></TR>\n";
101 }
102 }
103 if ($footer) {
104 echo "<TR><TD></TD><TD ALIGN=left><P><FONT SIZE=2>$footer</TD></TR>\n";
105 }
106 echo "</TABLE><BR>\n\n";
107}
108
109?>