Moving some images around - cleaning up organisation
[moodle.git] / course / 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)) {
9 if ($week == "all") {
b5fe4c93 10 unset($USER->section);
600149be 11 } else {
72e62a9e 12 $USER->section = $week;
600149be 13 }
14 }
15
9a223597 16 if ($course->newsitems) {
17 $news = forum_get_course_forum($course->id, "news");
18 }
d897cae4 19
20 $streditsummary = get_string("editsummary");
21 $stradd = get_string("add");
22 $stractivities = get_string("activities");
9a223597 23
600149be 24
9a223597 25/// Layout the whole page as three big columns.
600149be 26 echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>";
f9903ed0 27
9a223597 28/// The left column ...
13c7e271 29
9a223597 30 echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
13c7e271 31
9a223597 32/// Links to people
59a7100c 33 $moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
2c0411e2 34 $modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
583a7283 35 $editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/edit.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
2c0411e2 36 if ($USER->description) {
37 $moddata[]= $editmyprofile;
38 } else {
9a223597 39 $moddata[]= $editmyprofile." <BLINK>*</BLINK>";
2c0411e2 40 }
41 $modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
5e367a2d 42 print_side_block(get_string("people"), "", $moddata, $modicon);
13c7e271 43
f9903ed0 44
9a223597 45/// Then all the links to activities by type
f9903ed0 46 $moddata = array();
47 $modicon = array();
90845098 48 if ($modnamesused) {
49 foreach ($modnamesused as $modname => $modfullname) {
50 $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
2c0411e2 51 $modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
f9903ed0 52 }
53 }
5e367a2d 54 print_side_block($stractivities, "", $moddata, $modicon);
f9903ed0 55
9a223597 56/// Print a form to search forums
5e367a2d 57 $searchform = forum_print_search_form($course, "", true);
58 $searchform = "<DIV ALIGN=\"CENTER\">$searchform</DIV>";
59 print_side_block(get_string("search","forum"), $searchform);
9a223597 60
13c7e271 61
9a223597 62/// Admin links and controls
13469b82 63 print_course_admin_links($course);
f9903ed0 64
9a223597 65
66/// Start main column
f51ab26b 67 echo "</TD><TD WIDTH=\"*\">";
7541bc3e 68 print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock");
e5454458 69 print_spacer(8, 1, true);
9a223597 70
7541bc3e 71 echo "<table class=\"weeklyoutline\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\" width=\"100%\">";
9a223597 72
73/// Print Week 0 with general activities
74
75 $week = 0;
76 $thisweek = $sections[$week];
77
78 if ($thisweek->summary or $thisweek->sequence or isediting($course->id)) {
79 echo "<TR>";
6daa3c23 80 echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" class=\"weeklyoutlineside\" VALIGN=top WIDTH=20>&nbsp;</TD>";
81 echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\" WIDTH=\"100%\">";
9a223597 82
83 if (isediting($course->id)) {
84 $thisweek->summary .= "&nbsp;<A TITLE=\"$streditsummary\" ".
85 "HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" ".
86 "BORDER=0 ALT=\"$streditsummary\"></A></P>";
87 }
88
89 echo text_to_html($thisweek->summary);
90
d897cae4 91 print_section($course, $thisweek, $mods, $modnamesused);
9a223597 92
93 if (isediting($course->id)) {
94 echo "<DIV ALIGN=right>";
15ac9065 95 popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$week&add=",
d897cae4 96 $modnames, "section$week", "", "$stradd...", "mods", $stractivities);
9a223597 97 echo "</DIV>";
98 }
99
100 echo "</TD>";
6daa3c23 101 echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\" class=\"weeklyoutlineside\" VALIGN=top ALIGN=CENTER WIDTH=10>";
bfca4cff 102 echo "&nbsp;</TD>";
9a223597 103 echo "</TR>";
104 echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
105 }
106
107
108/// Now all the weekly sections
f9903ed0 109 $timenow = time();
110 $weekdate = $course->startdate; // this should be 0:00 Monday of that week
111 $week = 1;
112 $weekofseconds = 604800;
b5fe4c93 113 $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
f9903ed0 114
dcde9f02 115 $strftimedateshort = " ".get_string("strftimedateshort");
116
e3f0a6a7 117 while ($weekdate < $course->enddate) {
f9903ed0 118
119 $nextweekdate = $weekdate + ($weekofseconds);
600149be 120
72e62a9e 121 if (isset($USER->section)) { // Just display a single week
122 if ($USER->section != $week) {
600149be 123 $week++;
124 $weekdate = $nextweekdate;
125 continue;
126 }
127 }
128
f9903ed0 129 $thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
130
dcde9f02 131 $weekday = userdate($weekdate, $strftimedateshort);
132 $endweekday = userdate($weekdate+518400, $strftimedateshort);
f9903ed0 133
134 if ($thisweek) {
bfca4cff 135 $colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"weeklyoutlinesidehighlight\"";
136 $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontenthighlight\"";
f9903ed0 137 } else {
bfca4cff 138 $colorsides = "bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\"";
139 $colormain = "bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\"";
f9903ed0 140 }
141
600149be 142 echo "<TR>";
bfca4cff 143 echo "<TD NOWRAP $colorsides VALIGN=top WIDTH=20>";
f9903ed0 144 echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>";
145 echo "</TD>";
146
bfca4cff 147 echo "<TD $colormain VALIGN=top WIDTH=\"100%\">";
f9903ed0 148 echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>";
149
f8430195 150 if (!empty($sections[$week])) {
151 $thisweek = $sections[$week];
152 } else {
c1d9daca 153 unset($thisweek);
f9903ed0 154 $thisweek->course = $course->id; // Create a new week structure
ad14a10e 155 $thisweek->section = $week;
f9903ed0 156 $thisweek->summary = "";
ad14a10e 157 if (!$thisweek->id = insert_record("course_sections", $thisweek)) {
158 notify("Error inserting new week!");
159 }
f9903ed0 160 }
161
2c309dc2 162 if (isediting($course->id)) {
2c0411e2 163 $thisweek->summary .= "&nbsp;<A TITLE=\"$streditsummary\" HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"$streditsummary\"></A></P>";
f9903ed0 164 }
165
166 echo text_to_html($thisweek->summary);
167
d897cae4 168 print_section($course, $thisweek, $mods, $modnamesused);
f9903ed0 169
2c309dc2 170 if (isediting($course->id)) {
f9903ed0 171 echo "<DIV ALIGN=right>";
15ac9065 172 popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$week&add=",
9c9f7d77 173 $modnames, "section$week", "", "$stradd...");
f9903ed0 174 echo "</DIV>";
175 }
176
177 echo "</TD>";
bfca4cff 178 echo "<TD NOWRAP $colorsides VALIGN=top ALIGN=CENTER WIDTH=10>";
600149be 179 echo "<FONT SIZE=1>";
72e62a9e 180 if (isset($USER->section)) {
2c0411e2 181 $strshowallweeks = get_string("showallweeks");
182 echo "<A HREF=\"view.php?id=$course->id&week=all\" TITLE=\"$strshowallweeks\"><IMG SRC=../pix/i/all.gif BORDER=0></A></FONT>";
600149be 183 } else {
2c0411e2 184 $strshowonlyweek = get_string("showonlyweek", "", $week);
185 echo "<A HREF=\"view.php?id=$course->id&week=$week\" TITLE=\"$strshowonlyweek\"><IMG SRC=../pix/i/one.gif BORDER=0></A></FONT>";
600149be 186 }
187 echo "</TD>";
f9903ed0 188 echo "</TR>";
600149be 189 echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
f9903ed0 190
191 $week++;
192 $weekdate = $nextweekdate;
193 }
194 echo "</TABLE>";
f9903ed0 195
ce78926d 196 if (!empty($news) or !empty($course->showrecent)) {
13beeacb 197 echo "</TD><TD WIDTH=210>";
198
199 // Print all the news items.
200
ce78926d 201 if (!empty($news)) {
7541bc3e 202 print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews");
1d43ffde 203 echo "<FONT SIZE=\"-2\">";
32dcc874 204 forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "", false);
13beeacb 205 echo "</FONT>";
7541bc3e 206 print_side_block_end();
13beeacb 207 }
208
209 // Print all the recent activity
ce78926d 210 if (!empty($course->showrecent)) {
7541bc3e 211 print_side_block_start(get_string("recentactivity"), 210, "sideblockrecentactivity");
13beeacb 212 print_recent_activity($course);
7541bc3e 213 print_side_block_end();
13beeacb 214 }
600149be 215
7541bc3e 216 print_spacer(1, 120, true);
13beeacb 217 }
19a55d67 218
f51ab26b 219 echo "</TD></TR></TABLE>\n";
f9903ed0 220
221?>