mirrored from git://git.moodle.org/moodle.git
/
weeks.php
219 lines (169 loc) · 8.02 KB
/
weeks.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?PHP // $Id$
// Display the whole course as "weeks" made of of modules
// Included from "view.php"
include_once("$CFG->dirroot/mod/forum/lib.php");
if (isset($week)) {
if ($week == "all") {
unset($USER->section);
} else {
$USER->section = $week;
}
save_session("USER");
}
if ($course->newsitems) {
$news = forum_get_course_forum($course->id, "news");
}
$streditsummary = get_string("editsummary");
$stradd = get_string("add");
$stractivities = get_string("activities");
/// Layout the whole page as three big columns.
echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>";
/// The left column ...
echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
/// Links to people
$moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
if ($USER->description) {
$moddata[]= $editmyprofile;
} else {
$moddata[]= $editmyprofile." <BLINK>*</BLINK>";
}
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
print_side_block(get_string("people"), "", $moddata, $modicon);
/// Then all the links to activities by type
$moddata = array();
$modicon = array();
if ($modnamesused) {
foreach ($modnamesused as $modname => $modfullname) {
$moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
}
}
print_side_block($stractivities, "", $moddata, $modicon);
/// Print a form to search forums
$searchform = forum_print_search_form($course, "", true);
$searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
print_side_block(get_string("search","forum"), $searchform);
/// Admin links and controls
if (isteacher($course->id)) {
print_course_admin_links($course);
}
/// Start main column
echo "</TD><TD WIDTH=\"*\">";
print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock");
print_spacer(8, 1, true);
echo "<table class=\"weeklyoutline\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\" width=\"100%\">";
/// Print Week 0 with general activities
$week = 0;
$thisweek = $sections[$week];
if ($thisweek->summary or $thisweek->sequence or isediting($course->id)) {
echo "<TR>";
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" class=\"weeklyoutlineside\" VALIGN=top WIDTH=20> </TD>";
echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\" WIDTH=\"100%\">";
if (isediting($course->id)) {
$thisweek->summary .= " <A TITLE=\"$streditsummary\" ".
"HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" ".
"BORDER=0 ALT=\"$streditsummary\"></A></P>";
}
echo text_to_html($thisweek->summary);
print_section($course, $thisweek, $mods, $modnamesused);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
$modnames, "section$week", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
echo "</TD>";
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" class=\"weeklyoutlineside\" VALIGN=top ALIGN=CENTER WIDTH=10>";
echo " </TD>";
echo "</TR>";
echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
}
/// Now all the weekly sections
$timenow = time();
$weekdate = $course->startdate; // this should be 0:00 Monday of that week
$week = 1;
$weekofseconds = 604800;
$course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
while ($weekdate < $course->enddate) {
$nextweekdate = $weekdate + ($weekofseconds);
if (isset($USER->section)) { // Just display a single week
if ($USER->section != $week) {
$week++;
$weekdate = $nextweekdate;
continue;
}
}
$thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
$weekday = userdate($weekdate, " %d %B");
$endweekday = userdate($weekdate+518400, " %d %B");
if ($thisweek) {
$colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"weeklyoutlinesidehighlight\"";
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthighlight\"";
} else {
$colorsides = "bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\"";
$colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\"";
}
echo "<TR>";
echo "<TD NOWRAP $colorsides VALIGN=top WIDTH=20>";
echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>";
echo "</TD>";
echo "<TD $colormain VALIGN=top WIDTH=\"100%\">";
echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>";
if (! $thisweek = $sections[$week]) {
$thisweek->course = $course->id; // Create a new week structure
$thisweek->section = $week;
$thisweek->summary = "";
if (!$thisweek->id = insert_record("course_sections", $thisweek)) {
notify("Error inserting new week!");
}
}
if (isediting($course->id)) {
$thisweek->summary .= " <A TITLE=\"$streditsummary\" HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"$streditsummary\"></A></P>";
}
echo text_to_html($thisweek->summary);
print_section($course, $thisweek, $mods, $modnamesused);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
$modnames, "section$week", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
echo "</TD>";
echo "<TD NOWRAP $colorsides VALIGN=top ALIGN=CENTER WIDTH=10>";
echo "<FONT SIZE=1>";
if (isset($USER->section)) {
$strshowallweeks = get_string("showallweeks");
echo "<A HREF=\"view.php?id=$course->id&week=all\" TITLE=\"$strshowallweeks\"><IMG SRC=../pix/i/all.gif BORDER=0></A></FONT>";
} else {
$strshowonlyweek = get_string("showonlyweek", "", $week);
echo "<A HREF=\"view.php?id=$course->id&week=$week\" TITLE=\"$strshowonlyweek\"><IMG SRC=../pix/i/one.gif BORDER=0></A></FONT>";
}
echo "</TD>";
echo "</TR>";
echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
$week++;
$weekdate = $nextweekdate;
}
echo "</TABLE>";
if ($news or $course->showrecent) {
echo "</TD><TD WIDTH=210>";
// Print all the news items.
if ($news) {
print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews");
echo "<FONT SIZE=\"-2\">";
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
echo "</FONT>";
print_side_block_end();
}
// Print all the recent activity
if ($course->showrecent) {
print_side_block_start(get_string("recentactivity"), 210, "sideblockrecentactivity");
print_recent_activity($course);
print_side_block_end();
}
print_spacer(1, 120, true);
}
echo "</TD></TR></TABLE>\n";
?>