f9903ed0 |
1 | <?PHP // $Id$ |
600149be |
2 | // Display the whole course as "weeks" made of of modules |
3 | // Included from "view.php" |
f9903ed0 |
4 | |
b0e3a925 |
5 | require_once("$CFG->dirroot/mod/forum/lib.php"); |
f9903ed0 |
6 | |
f9903ed0 |
7 | |
72e62a9e |
8 | if (isset($week)) { |
b86fc0e2 |
9 | $displaysection = course_set_display($course->id, $week); |
10 | } else { |
11 | if (isset($USER->display[$course->id])) { |
12 | $displaysection = $USER->display[$course->id]; |
600149be |
13 | } else { |
b86fc0e2 |
14 | $displaysection = course_set_display($course->id, 0); |
600149be |
15 | } |
16 | } |
17 | |
9a223597 |
18 | if ($course->newsitems) { |
19 | $news = forum_get_course_forum($course->id, "news"); |
20 | } |
d897cae4 |
21 | |
1ea7c627 |
22 | $streditsummary = get_string("editsummary"); |
23 | $stradd = get_string("add"); |
24 | $stractivities = get_string("activities"); |
25 | $strshowallweeks = get_string("showallweeks"); |
584ec10e |
26 | $strweek = get_string("week"); |
f374fb10 |
27 | $strgroups = get_string("groups"); |
28 | $strgroupmy = get_string("groupmy"); |
1ea7c627 |
29 | if (isediting($course->id)) { |
30 | $strstudents = moodle_strtolower($course->students); |
31 | $strweekhide = get_string("weekhide", "", $strstudents); |
32 | $strweekshow = get_string("weekshow", "", $strstudents); |
d7b97e43 |
33 | $strmoveup = get_string("moveup"); |
34 | $strmovedown = get_string("movedown"); |
1ea7c627 |
35 | } |
9a223597 |
36 | |
600149be |
37 | |
9a223597 |
38 | /// Layout the whole page as three big columns. |
dc0dc7d5 |
39 | echo "<table border=0 cellpadding=3 cellspacing=0 width=100%>"; |
f9903ed0 |
40 | |
9a223597 |
41 | /// The left column ... |
13c7e271 |
42 | |
dc0dc7d5 |
43 | echo "<tr valign=top><td valign=top width=180>"; |
13c7e271 |
44 | |
9a223597 |
45 | /// Links to people |
dc0dc7d5 |
46 | $moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>"; |
c9f6251e |
47 | $modicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">"; |
f374fb10 |
48 | |
49 | if ($course->groupmode or !$course->groupmodeforce) { |
3d575e6f |
50 | if ($course->groupmode == VISIBLEGROUPS or isteacheredit($course->id)) { |
f374fb10 |
51 | $moddata[]="<a title=\"$strgroups\" href=\"groups.php?id=$course->id\">$strgroups</a>"; |
15e06a24 |
52 | $modicon[]="<img src=\"$CFG->pixpath/i/group.gif\" height=16 width=16 alt=\"\">"; |
3d575e6f |
53 | } else if ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce) { |
54 | // Show nothing |
196ca3fe |
55 | } else if ($currentgroup) { |
f374fb10 |
56 | $moddata[]="<a title=\"$strgroupmy\" href=\"group.php?id=$course->id\">$strgroupmy</a>"; |
15e06a24 |
57 | $modicon[]="<img src=\"$CFG->pixpath/i/group.gif\" height=16 width=16 alt=\"\">"; |
f374fb10 |
58 | } |
f374fb10 |
59 | } |
60 | |
5fde0ca6 |
61 | $fullname = fullname($USER, true); |
62 | $editmyprofile = "<a title=\"$fullname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</a>"; |
2c0411e2 |
63 | if ($USER->description) { |
64 | $moddata[]= $editmyprofile; |
65 | } else { |
dc0dc7d5 |
66 | $moddata[]= $editmyprofile." <blink>*</blink>"; |
2c0411e2 |
67 | } |
c9f6251e |
68 | $modicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">"; |
5e367a2d |
69 | print_side_block(get_string("people"), "", $moddata, $modicon); |
13c7e271 |
70 | |
f9903ed0 |
71 | |
9a223597 |
72 | /// Then all the links to activities by type |
f9903ed0 |
73 | $moddata = array(); |
74 | $modicon = array(); |
90845098 |
75 | if ($modnamesused) { |
76 | foreach ($modnamesused as $modname => $modfullname) { |
c9f6251e |
77 | if ($modname != "label") { |
78 | $moddata[] = "<a href=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</a>"; |
79 | $modicon[] = "<img src=\"$CFG->modpixpath/$modname/icon.gif\" height=16 width=16 alt=\"\">"; |
80 | } |
f9903ed0 |
81 | } |
82 | } |
5e367a2d |
83 | print_side_block($stractivities, "", $moddata, $modicon); |
f9903ed0 |
84 | |
0d250ac1 |
85 | /// Print the calendar |
86 | calendar_print_side_blocks(); |
87 | |
9a223597 |
88 | /// Print a form to search forums |
5e367a2d |
89 | $searchform = forum_print_search_form($course, "", true); |
b86fc0e2 |
90 | $searchform = "<div align=\"center\">$searchform</div>"; |
5e367a2d |
91 | print_side_block(get_string("search","forum"), $searchform); |
13c7e271 |
92 | |
9a223597 |
93 | /// Admin links and controls |
13469b82 |
94 | print_course_admin_links($course); |
f9903ed0 |
95 | |
f3120024 |
96 | /// My courses |
97 | print_courses_sideblock(0, "180"); |
9a223597 |
98 | |
99 | /// Start main column |
b86fc0e2 |
100 | echo "</td><td width=\"*\">"; |
7541bc3e |
101 | print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock"); |
e5454458 |
102 | print_spacer(8, 1, true); |
9a223597 |
103 | |
7541bc3e |
104 | echo "<table class=\"weeklyoutline\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\" width=\"100%\">"; |
9a223597 |
105 | |
7977cffd |
106 | /// If currently moving a file then show the current clipboard |
107 | if (ismoving($course->id)) { |
adcedde7 |
108 | $stractivityclipboard = strip_tags(get_string("activityclipboard", "", addslashes($USER->activitycopyname))); |
7977cffd |
109 | $strcancel= get_string("cancel"); |
110 | echo "<tr>"; |
111 | echo "<td colspan=3 valign=top bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlineclip\" width=\"100%\">"; |
112 | echo "<p><font size=2>"; |
113 | echo "$stractivityclipboard (<a href=\"mod.php?cancelcopy=true\">$strcancel</a>)"; |
114 | echo "</font></p>"; |
115 | echo "</td>"; |
116 | echo "</tr>"; |
117 | echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>"; |
118 | } |
119 | |
1ea7c627 |
120 | /// Print Section 0 with general activities |
9a223597 |
121 | |
1ea7c627 |
122 | $section = 0; |
123 | $thissection = $sections[$section]; |
9a223597 |
124 | |
1ea7c627 |
125 | if ($thissection->summary or $thissection->sequence or isediting($course->id)) { |
dc0dc7d5 |
126 | echo "<tr>"; |
127 | echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top width=20> </td>"; |
128 | echo "<td valign=top bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\" width=\"100%\">"; |
9a223597 |
129 | |
5f850588 |
130 | echo format_text($thissection->summary, FORMAT_HTML); |
131 | |
9a223597 |
132 | if (isediting($course->id)) { |
5f850588 |
133 | echo " <a title=\"$streditsummary\" ". |
134 | " href=\"editsection.php?id=$thissection->id\"><img height=11 width=11 src=\"$CFG->pixpath/t/edit.gif\" ". |
135 | " border=0 alt=\"$streditsummary\"></a><br />"; |
9a223597 |
136 | } |
5f850588 |
137 | |
138 | echo '<br clear="all">'; |
9a223597 |
139 | |
1ea7c627 |
140 | print_section($course, $thissection, $mods, $modnamesused); |
9a223597 |
141 | |
142 | if (isediting($course->id)) { |
dc0dc7d5 |
143 | echo "<div align=right>"; |
1ea7c627 |
144 | popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=", |
145 | $modnames, "section$section", "", "$stradd...", "mods", $stractivities); |
dc0dc7d5 |
146 | echo "</div>"; |
9a223597 |
147 | } |
148 | |
b86fc0e2 |
149 | echo "</td>"; |
150 | echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top align=center width=10>"; |
1ea7c627 |
151 | echo " </td></tr>"; |
b86fc0e2 |
152 | echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>"; |
9a223597 |
153 | } |
154 | |
155 | |
156 | /// Now all the weekly sections |
f9903ed0 |
157 | $timenow = time(); |
158 | $weekdate = $course->startdate; // this should be 0:00 Monday of that week |
674416ea |
159 | $weekdate += 7200; // Add two hours to avoid possible DST problems |
1ea7c627 |
160 | $section = 1; |
584ec10e |
161 | $sectionmenu = array(); |
f9903ed0 |
162 | $weekofseconds = 604800; |
b5fe4c93 |
163 | $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); |
f9903ed0 |
164 | |
dcde9f02 |
165 | $strftimedateshort = " ".get_string("strftimedateshort"); |
166 | |
e3f0a6a7 |
167 | while ($weekdate < $course->enddate) { |
f9903ed0 |
168 | |
169 | $nextweekdate = $weekdate + ($weekofseconds); |
1ea7c627 |
170 | $weekday = userdate($weekdate, $strftimedateshort); |
171 | $endweekday = userdate($weekdate+518400, $strftimedateshort); |
600149be |
172 | |
1ea7c627 |
173 | if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible |
584ec10e |
174 | $sectionmenu["week=$section"] = s("$strweek $section | $weekday - $endweekday"); |
1ea7c627 |
175 | $section++; |
b86fc0e2 |
176 | $weekdate = $nextweekdate; |
177 | continue; |
600149be |
178 | } |
179 | |
1ea7c627 |
180 | if (!empty($sections[$section])) { |
181 | $thissection = $sections[$section]; |
f9903ed0 |
182 | |
1ea7c627 |
183 | } else { |
184 | unset($thissection); |
185 | $thissection->course = $course->id; // Create a new week structure |
186 | $thissection->section = $section; |
187 | $thissection->summary = ""; |
188 | $thissection->visible = 1; |
189 | if (!$thissection->id = insert_record("course_sections", $thissection)) { |
190 | notify("Error inserting new week!"); |
191 | } |
192 | } |
f9903ed0 |
193 | |
1ea7c627 |
194 | $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate)); |
195 | |
196 | if (!$thissection->visible) { |
197 | $colorsides = "bgcolor=\"$THEME->hidden\" class=\"weeklyoutlinesidehidden\""; |
198 | $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthidden\""; |
199 | } else if ($currentweek) { |
bfca4cff |
200 | $colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"weeklyoutlinesidehighlight\""; |
201 | $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthighlight\""; |
f9903ed0 |
202 | } else { |
bfca4cff |
203 | $colorsides = "bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\""; |
204 | $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\""; |
f9903ed0 |
205 | } |
206 | |
dc0dc7d5 |
207 | echo "<tr>"; |
208 | echo "<td nowrap $colorsides valign=top width=20>"; |
1ea7c627 |
209 | echo "<p align=center><font size=3><b>$section</b></font></p>"; |
dc0dc7d5 |
210 | echo "</td>"; |
f9903ed0 |
211 | |
1ea7c627 |
212 | echo "<td valign=top $colormain width=\"100%\">"; |
213 | |
214 | if (!isteacher($course->id) and !$thissection->visible) { // Hidden for students |
215 | echo "<p class=\"weeklydatetext\">$weekday - $endweekday "; |
216 | echo "(".get_string("notavailable").")"; |
217 | echo "</p>"; |
218 | echo "</td>"; |
f9903ed0 |
219 | |
f8430195 |
220 | } else { |
f9903ed0 |
221 | |
1ea7c627 |
222 | echo "<p class=\"weeklydatetext\">$weekday - $endweekday</p>"; |
f9903ed0 |
223 | |
5f850588 |
224 | echo format_text($thissection->summary, FORMAT_HTML); |
225 | |
1ea7c627 |
226 | if (isediting($course->id)) { |
5f850588 |
227 | echo " <a title=\"$streditsummary\" href=\"editsection.php?id=$thissection->id\">". |
228 | "<img src=\"$CFG->pixpath/t/edit.gif\" height=11 width=11 border=0></a><br />"; |
1ea7c627 |
229 | } |
f9903ed0 |
230 | |
5f850588 |
231 | echo '<br clear="all">'; |
f9903ed0 |
232 | |
1ea7c627 |
233 | print_section($course, $thissection, $mods, $modnamesused); |
f9903ed0 |
234 | |
1ea7c627 |
235 | if (isediting($course->id)) { |
236 | echo "<div align=right>"; |
237 | popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=", |
238 | $modnames, "section$section", "", "$stradd..."); |
239 | echo "</div>"; |
240 | } |
241 | |
242 | echo "</td>"; |
243 | } |
dc0dc7d5 |
244 | echo "<td nowrap $colorsides valign=top align=center width=10>"; |
245 | echo "<font size=1>"; |
1ea7c627 |
246 | |
247 | if ($displaysection == $section) { |
248 | echo "<a href=\"view.php?id=$course->id&week=all\" title=\"$strshowallweeks\">". |
c9f6251e |
249 | "<img src=\"$CFG->pixpath/i/all.gif\" height=25 width=16 border=0></a><br />"; |
600149be |
250 | } else { |
1ea7c627 |
251 | $strshowonlyweek = get_string("showonlyweek", "", $section); |
252 | echo "<a href=\"view.php?id=$course->id&week=$section\" title=\"$strshowonlyweek\">". |
c9f6251e |
253 | "<img src=\"$CFG->pixpath/i/one.gif\" height=16 width=16 border=0></a><br />"; |
600149be |
254 | } |
1ea7c627 |
255 | |
256 | if (isediting($course->id)) { |
257 | if ($thissection->visible) { // Show the hide/show eye |
258 | echo "<a href=\"view.php?id=$course->id&hide=$section\" title=\"$strweekhide\">". |
c9f6251e |
259 | "<img src=\"$CFG->pixpath/i/hide.gif\" vspace=3 height=16 width=16 border=0></a><br />"; |
1ea7c627 |
260 | } else { |
261 | echo "<a href=\"view.php?id=$course->id&show=$section\" title=\"$strweekshow\">". |
c9f6251e |
262 | "<img src=\"$CFG->pixpath/i/show.gif\" vspace=3 height=16 width=16 border=0></a><br />"; |
1ea7c627 |
263 | } |
12905134 |
264 | |
265 | if ($section > 1) { // Add a arrow to move section up |
d7b97e43 |
266 | echo "<a href=\"view.php?id=$course->id§ion=$section&move=-1\" title=\"$strmoveup\">". |
c9f6251e |
267 | "<img src=\"$CFG->pixpath/t/up.gif\" vspace=3 height=11 width=11 border=0></a><br />"; |
12905134 |
268 | } |
269 | |
270 | if ($section < $course->numsections) { // Add a arrow to move section down |
d7b97e43 |
271 | echo "<a href=\"view.php?id=$course->id§ion=$section&move=1\" title=\"$strmovedown\">". |
c9f6251e |
272 | "<img src=\"$CFG->pixpath/t/down.gif\" vspace=3 height=11 width=11 border=0></a><br />"; |
12905134 |
273 | } |
274 | |
1ea7c627 |
275 | } |
276 | |
dc0dc7d5 |
277 | echo "</td>"; |
278 | echo "</tr>"; |
279 | echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>"; |
f9903ed0 |
280 | |
1ea7c627 |
281 | $section++; |
f9903ed0 |
282 | $weekdate = $nextweekdate; |
283 | } |
dc0dc7d5 |
284 | echo "</table>"; |
584ec10e |
285 | |
286 | if (!empty($sectionmenu)) { |
287 | echo "<center>"; |
288 | echo popup_form("$CFG->wwwroot/course/view.php?id=$course->id&", $sectionmenu, |
289 | "sectionmenu", "", get_string("jumpto"), "", "", true); |
290 | echo "</center>"; |
291 | } |
f9903ed0 |
292 | |
ce78926d |
293 | if (!empty($news) or !empty($course->showrecent)) { |
dc0dc7d5 |
294 | echo "</td><td width=210>"; |
13beeacb |
295 | |
296 | // Print all the news items. |
297 | |
ce78926d |
298 | if (!empty($news)) { |
7541bc3e |
299 | print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews"); |
dc0dc7d5 |
300 | echo "<font size=\"-2\">"; |
196ca3fe |
301 | forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "", $currentgroup); |
dc0dc7d5 |
302 | echo "</font>"; |
7541bc3e |
303 | print_side_block_end(); |
13beeacb |
304 | } |
305 | |
306 | // Print all the recent activity |
ce78926d |
307 | if (!empty($course->showrecent)) { |
7541bc3e |
308 | print_side_block_start(get_string("recentactivity"), 210, "sideblockrecentactivity"); |
13beeacb |
309 | print_recent_activity($course); |
7541bc3e |
310 | print_side_block_end(); |
13beeacb |
311 | } |
600149be |
312 | |
7541bc3e |
313 | print_spacer(1, 120, true); |
13beeacb |
314 | } |
19a55d67 |
315 | |
dc0dc7d5 |
316 | echo "</td></tr></table>\n"; |
f9903ed0 |
317 | |
318 | ?> |