OK, this is working now
[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
fa0626c6 34 $courseword = get_string("course");
35
36 print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
5575a053 37 update_course_icon($course->id));
f9903ed0 38
39 if (! $modtypes = get_records_sql_menu("SELECT name,fullname FROM modules ORDER BY fullname") ) {
40 error("No modules are installed!");
41 }
42
7468bf01 43 get_all_mods($course->id, $mods, $modtype);
44
45 if (isset($modtype["forum"]) and isset($modtype["discuss"])) { // Only need to display one
46 unset($modtype["discuss"]);
f9903ed0 47 }
48
49 switch ($course->format) {
b5fe4c93 50 case "weeks":
f9903ed0 51 include("weeks.php");
52 break;
b5fe4c93 53 case "social":
4567fb71 54 include("social.php");
55 break;
b5fe4c93 56 case "topics":
0b35af18 57 include("topics.php");
58 break;
4567fb71 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) {
fa0626c6 70 $delete = get_string("delete");
71 $moveup = get_string("moveup");
72 $movedown = get_string("movedown");
73 $update = get_string("update");
f9903ed0 74 return "&nbsp; &nbsp;
75 <A HREF=mod.php?delete=$moduleid><IMG
fa0626c6 76 SRC=../pix/t/delete.gif BORDER=0 ALT=\"$delete\"></A>
f9903ed0 77 <A HREF=mod.php?id=$moduleid&move=-1><IMG
fa0626c6 78 SRC=../pix/t/up.gif BORDER=0 ALT=\"$moveup\"></A>
f9903ed0 79 <A HREF=mod.php?id=$moduleid&move=1><IMG
fa0626c6 80 SRC=../pix/t/down.gif BORDER=0 ALT=\"$movedown\"></A>
f9903ed0 81 <A HREF=mod.php?update=$moduleid><IMG
fa0626c6 82 SRC=../pix/t/edit.gif BORDER=0 ALT=\"$update\"></A>";
f9903ed0 83}
84
85function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
86
87 echo "<TABLE WIDTH=100%>\n";
88 echo "<TR><TD COLSPAN=2><P><B><FONT SIZE=2>$heading</TD></TR>\n";
89 if ($list) {
90 foreach($list as $key => $string) {
91 echo "<TR><TD VALIGN=top WIDTH=12>";
92 if ($icons[$key]) {
93 echo $icons[$key];
94 } else {
95 echo "";
96 }
77775bff 97 echo "</TD>\n<TD WIDTH=100% VALIGN=top>";
e07635f4 98 echo "<P><FONT SIZE=2>$string</FONT></P>";
f9903ed0 99 echo "</TD></TR>\n";
100 }
101 }
102 if ($footer) {
103 echo "<TR><TD></TD><TD ALIGN=left><P><FONT SIZE=2>$footer</TD></TR>\n";
104 }
105 echo "</TABLE><BR>\n\n";
106}
107
108?>