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 | |
22 | $streditsummary = get_string("editsummary"); |
23 | $stradd = get_string("add"); |
24 | $stractivities = get_string("activities"); |
9a223597 |
25 | |
600149be |
26 | |
9a223597 |
27 | /// Layout the whole page as three big columns. |
dc0dc7d5 |
28 | echo "<table border=0 cellpadding=3 cellspacing=0 width=100%>"; |
f9903ed0 |
29 | |
9a223597 |
30 | /// The left column ... |
13c7e271 |
31 | |
dc0dc7d5 |
32 | echo "<tr valign=top><td valign=top width=180>"; |
13c7e271 |
33 | |
9a223597 |
34 | /// Links to people |
dc0dc7d5 |
35 | $moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>"; |
36 | $modicon[]="<img src=\"$pixpath/i/users.gif\" height=16 width=16 alt=\"\">"; |
37 | $editmyprofile = "<a title=\"$USER->firstname $USER->lastname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</a>"; |
2c0411e2 |
38 | if ($USER->description) { |
39 | $moddata[]= $editmyprofile; |
40 | } else { |
dc0dc7d5 |
41 | $moddata[]= $editmyprofile." <blink>*</blink>"; |
2c0411e2 |
42 | } |
dc0dc7d5 |
43 | $modicon[]="<img src=\"$pixpath/i/user.gif\" height=16 width=16 alt=\"\">"; |
5e367a2d |
44 | print_side_block(get_string("people"), "", $moddata, $modicon); |
13c7e271 |
45 | |
f9903ed0 |
46 | |
9a223597 |
47 | /// Then all the links to activities by type |
f9903ed0 |
48 | $moddata = array(); |
49 | $modicon = array(); |
90845098 |
50 | if ($modnamesused) { |
51 | foreach ($modnamesused as $modname => $modfullname) { |
dc0dc7d5 |
52 | $moddata[] = "<a href=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</a>"; |
53 | $modicon[] = "<img src=\"$modpixpath/$modname/icon.gif\" height=16 width=16 alt=\"\">"; |
f9903ed0 |
54 | } |
55 | } |
5e367a2d |
56 | print_side_block($stractivities, "", $moddata, $modicon); |
f9903ed0 |
57 | |
9a223597 |
58 | /// Print a form to search forums |
5e367a2d |
59 | $searchform = forum_print_search_form($course, "", true); |
b86fc0e2 |
60 | $searchform = "<div align=\"center\">$searchform</div>"; |
5e367a2d |
61 | print_side_block(get_string("search","forum"), $searchform); |
9a223597 |
62 | |
13c7e271 |
63 | |
9a223597 |
64 | /// Admin links and controls |
13469b82 |
65 | print_course_admin_links($course); |
f9903ed0 |
66 | |
9a223597 |
67 | |
68 | /// Start main column |
b86fc0e2 |
69 | echo "</td><td width=\"*\">"; |
7541bc3e |
70 | print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock"); |
e5454458 |
71 | print_spacer(8, 1, true); |
9a223597 |
72 | |
7541bc3e |
73 | echo "<table class=\"weeklyoutline\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\" width=\"100%\">"; |
9a223597 |
74 | |
75 | /// Print Week 0 with general activities |
76 | |
77 | $week = 0; |
78 | $thisweek = $sections[$week]; |
79 | |
80 | if ($thisweek->summary or $thisweek->sequence or isediting($course->id)) { |
dc0dc7d5 |
81 | echo "<tr>"; |
82 | echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top width=20> </td>"; |
83 | echo "<td valign=top bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\" width=\"100%\">"; |
9a223597 |
84 | |
85 | if (isediting($course->id)) { |
dc0dc7d5 |
86 | $thisweek->summary .= " <a title=\"$streditsummary\" ". |
87 | "href=\"editsection.php?id=$thisweek->id\"><img height=11 width=11 src=\"$pixpath/t/edit.gif\" ". |
88 | "border=0 alt=\"$streditsummary\"></a></p>"; |
9a223597 |
89 | } |
90 | |
91 | echo text_to_html($thisweek->summary); |
92 | |
d897cae4 |
93 | print_section($course, $thisweek, $mods, $modnamesused); |
9a223597 |
94 | |
95 | if (isediting($course->id)) { |
dc0dc7d5 |
96 | echo "<div align=right>"; |
15ac9065 |
97 | popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$week&add=", |
d897cae4 |
98 | $modnames, "section$week", "", "$stradd...", "mods", $stractivities); |
dc0dc7d5 |
99 | echo "</div>"; |
9a223597 |
100 | } |
101 | |
b86fc0e2 |
102 | echo "</td>"; |
103 | echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top align=center width=10>"; |
104 | echo " </td>"; |
105 | echo "</tr>"; |
106 | echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>"; |
9a223597 |
107 | } |
108 | |
109 | |
110 | /// Now all the weekly sections |
f9903ed0 |
111 | $timenow = time(); |
112 | $weekdate = $course->startdate; // this should be 0:00 Monday of that week |
113 | $week = 1; |
114 | $weekofseconds = 604800; |
b5fe4c93 |
115 | $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); |
f9903ed0 |
116 | |
dcde9f02 |
117 | $strftimedateshort = " ".get_string("strftimedateshort"); |
118 | |
e3f0a6a7 |
119 | while ($weekdate < $course->enddate) { |
f9903ed0 |
120 | |
121 | $nextweekdate = $weekdate + ($weekofseconds); |
600149be |
122 | |
b86fc0e2 |
123 | if (!empty($displaysection) and $displaysection != $week) { // Check this week is visible |
124 | $week++; |
125 | $weekdate = $nextweekdate; |
126 | continue; |
600149be |
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 | |
dc0dc7d5 |
142 | echo "<tr>"; |
143 | echo "<td nowrap $colorsides valign=top width=20>"; |
144 | echo "<p align=center><font size=3><b>$week</b></font></p>"; |
145 | echo "</td>"; |
f9903ed0 |
146 | |
dc0dc7d5 |
147 | echo "<td $colormain valign=top width=\"100%\">"; |
148 | echo "<p><font size=3 color=\"$THEME->cellheading2\">$weekday - $endweekday</font></p>"; |
f9903ed0 |
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)) { |
dc0dc7d5 |
163 | $thisweek->summary .= " <a title=\"$streditsummary\" href=\"editsection.php?id=$thisweek->id\"><img src=\"$pixpath/t/edit.gif\" height=11 width=11 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)) { |
dc0dc7d5 |
171 | echo "<div align=right>"; |
15ac9065 |
172 | popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$week&add=", |
9c9f7d77 |
173 | $modnames, "section$week", "", "$stradd..."); |
dc0dc7d5 |
174 | echo "</div>"; |
f9903ed0 |
175 | } |
176 | |
dc0dc7d5 |
177 | echo "</td>"; |
178 | echo "<td nowrap $colorsides valign=top align=center width=10>"; |
179 | echo "<font size=1>"; |
b86fc0e2 |
180 | if ($displaysection == $week) { |
2c0411e2 |
181 | $strshowallweeks = get_string("showallweeks"); |
dc0dc7d5 |
182 | echo "<a href=\"view.php?id=$course->id&week=all\" title=\"$strshowallweeks\"><img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a></font>"; |
600149be |
183 | } else { |
2c0411e2 |
184 | $strshowonlyweek = get_string("showonlyweek", "", $week); |
dc0dc7d5 |
185 | echo "<a href=\"view.php?id=$course->id&week=$week\" title=\"$strshowonlyweek\"><img src=\"$pixpath/i/one.gif\" height=16 width=16 border=0></a></font>"; |
600149be |
186 | } |
dc0dc7d5 |
187 | echo "</td>"; |
188 | echo "</tr>"; |
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 | } |
dc0dc7d5 |
194 | echo "</table>"; |
f9903ed0 |
195 | |
ce78926d |
196 | if (!empty($news) or !empty($course->showrecent)) { |
dc0dc7d5 |
197 | echo "</td><td width=210>"; |
13beeacb |
198 | |
199 | // Print all the news items. |
200 | |
ce78926d |
201 | if (!empty($news)) { |
7541bc3e |
202 | print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews"); |
dc0dc7d5 |
203 | echo "<font size=\"-2\">"; |
32dcc874 |
204 | forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "", false); |
dc0dc7d5 |
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 | |
dc0dc7d5 |
219 | echo "</td></tr></table>\n"; |
f9903ed0 |
220 | |
221 | ?> |