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