mirrored from git://git.moodle.org/moodle.git
/
view.php
115 lines (93 loc) · 3.4 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?PHP // $Id$
// Display the course home page.
require("../config.php");
require("lib.php");
require_login($id);
if (! $course = get_record("course", "id", $id) ) {
error("That's an invalid course id");
}
add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
if ( isteacher($course->id) ) {
if ($edit == "on") {
$USER->editing = true;
} else if ($edit == "off") {
$USER->editing = false;
}
}
if ($help == "on") {
$USER->help = true;
} else if ($help == "off") {
$USER->help = false;
}
if (! $course->category) { // This course is not a real course.
redirect("$CFG->wwwroot");
}
$courseword = get_string("course");
print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
update_course_icon($course->id));
if (! $modtypes = get_records_sql_menu("SELECT name,fullname FROM modules ORDER BY fullname") ) {
error("No modules are installed!");
}
if ( $rawmods = get_records_sql("SELECT cm.*, m.name as modname, m.fullname as modfullname
FROM modules m, course_modules cm
WHERE cm.course = '$course->id'
AND cm.deleted = '0'
AND cm.module = m.id") ) {
foreach($rawmods as $mod) { // Index the mods
$mods[$mod->id] = $mod;
$modtype[$mod->modname] = $mod->modfullname;
}
ksort($modtype);
}
switch ($course->format) {
case "weeks":
include("weeks.php");
break;
case "social":
include("social.php");
break;
case "topics":
include("topics.php");
break;
default:
error("Course format not defined yet!");
}
print_footer($course);
/// FUNCTIONS ////////
function make_editing_buttons($moduleid) {
$delete = get_string("delete");
$moveup = get_string("moveup");
$movedown = get_string("movedown");
$update = get_string("update");
return "
<A HREF=mod.php?delete=$moduleid><IMG
SRC=../pix/t/delete.gif BORDER=0 ALT=\"$delete\"></A>
<A HREF=mod.php?id=$moduleid&move=-1><IMG
SRC=../pix/t/up.gif BORDER=0 ALT=\"$moveup\"></A>
<A HREF=mod.php?id=$moduleid&move=1><IMG
SRC=../pix/t/down.gif BORDER=0 ALT=\"$movedown\"></A>
<A HREF=mod.php?update=$moduleid><IMG
SRC=../pix/t/edit.gif BORDER=0 ALT=\"$update\"></A>";
}
function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
echo "<TABLE WIDTH=100%>\n";
echo "<TR><TD COLSPAN=2><P><B><FONT SIZE=2>$heading</TD></TR>\n";
if ($list) {
foreach($list as $key => $string) {
echo "<TR><TD VALIGN=top WIDTH=12>";
if ($icons[$key]) {
echo $icons[$key];
} else {
echo "";
}
echo "</TD>\n<TD WIDTH=100% VALIGN=top>";
echo "<P><FONT SIZE=2>$string</FONT></P>";
echo "</TD></TR>\n";
}
}
if ($footer) {
echo "<TR><TD></TD><TD ALIGN=left><P><FONT SIZE=2>$footer</TD></TR>\n";
}
echo "</TABLE><BR>\n\n";
}
?>