f9903ed0 |
1 | <?PHP // $Id$ |
600149be |
2 | // Display the whole course as "weeks" made of of modules |
3 | // Included from "view.php" |
f9903ed0 |
4 | |
765814de |
5 | include_once("$CFG->dirroot/mod/forum/lib.php"); |
f9903ed0 |
6 | |
94361e02 |
7 | if (! $sections = get_all_sections($course->id)) { |
b5fe4c93 |
8 | $section->course = $course->id; // Create a default section. |
9 | $section->section = 0; |
10 | $section->id = insert_record("course_sections", $section); |
94361e02 |
11 | if (! $sections = get_all_sections($course->id) ) { |
b5fe4c93 |
12 | error("Error finding or creating section structures for this course"); |
f9903ed0 |
13 | } |
14 | } |
f9903ed0 |
15 | |
72e62a9e |
16 | if (isset($week)) { |
17 | if ($week == "all") { |
b5fe4c93 |
18 | unset($USER->section); |
600149be |
19 | } else { |
72e62a9e |
20 | $USER->section = $week; |
600149be |
21 | } |
8223d271 |
22 | save_session("USER"); |
600149be |
23 | } |
24 | |
25 | |
f51ab26b |
26 | // Layout the whole page as three big columns. |
600149be |
27 | echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>"; |
f51ab26b |
28 | echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>"; |
f9903ed0 |
29 | |
30 | // Layout the left column |
31 | |
13c7e271 |
32 | |
33 | // Links to people |
34 | |
2c0411e2 |
35 | print_simple_box(get_string("people"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); |
59a7100c |
36 | $moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>"; |
2c0411e2 |
37 | $modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
2415d953 |
38 | $editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>"; |
2c0411e2 |
39 | if ($USER->description) { |
40 | $moddata[]= $editmyprofile; |
41 | } else { |
42 | $moddata[]= $editmyprofile.$blinker; |
43 | } |
44 | $modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
13c7e271 |
45 | print_side_block("", $moddata, "", $modicon); |
46 | |
f9903ed0 |
47 | |
48 | // Then all the links to module types |
49 | |
50 | $moddata = array(); |
51 | $modicon = array(); |
90845098 |
52 | if ($modnamesused) { |
53 | foreach ($modnamesused as $modname => $modfullname) { |
54 | $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>"; |
2c0411e2 |
55 | $modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
f9903ed0 |
56 | } |
57 | } |
2c0411e2 |
58 | print_simple_box(get_string("activities"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); |
600149be |
59 | print_side_block("", $moddata, "", $modicon); |
f9903ed0 |
60 | |
501cdbd8 |
61 | // Print a form to search forums |
5d13db8a |
62 | print_simple_box(get_string("search","forum"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); |
c629ec1b |
63 | echo "<DIV ALIGN=CENTER>"; |
7a12aab4 |
64 | forum_print_search_form($course); |
c629ec1b |
65 | echo "</DIV>"; |
13c7e271 |
66 | |
f9903ed0 |
67 | // Admin links and controls |
0d97d1e3 |
68 | if (isteacher($course->id)) { |
b4d7002e |
69 | print_course_admin_links($course); |
f9903ed0 |
70 | } |
f9903ed0 |
71 | |
f9903ed0 |
72 | // Start main column |
f51ab26b |
73 | echo "</TD><TD WIDTH=\"*\">"; |
f9903ed0 |
74 | |
2c0411e2 |
75 | print_simple_box(get_string("weeklyoutline"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); |
f51ab26b |
76 | |
f51ab26b |
77 | // Now all the weekly modules |
f9903ed0 |
78 | $timenow = time(); |
79 | $weekdate = $course->startdate; // this should be 0:00 Monday of that week |
80 | $week = 1; |
81 | $weekofseconds = 604800; |
b5fe4c93 |
82 | $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); |
f9903ed0 |
83 | |
2c0411e2 |
84 | $streditsummary = get_string("editsummary"); |
85 | $stradd = get_string("add"); |
86 | |
f9903ed0 |
87 | echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>"; |
e3f0a6a7 |
88 | while ($weekdate < $course->enddate) { |
f9903ed0 |
89 | |
90 | $nextweekdate = $weekdate + ($weekofseconds); |
600149be |
91 | |
72e62a9e |
92 | if (isset($USER->section)) { // Just display a single week |
93 | if ($USER->section != $week) { |
600149be |
94 | $week++; |
95 | $weekdate = $nextweekdate; |
96 | continue; |
97 | } |
98 | } |
99 | |
f9903ed0 |
100 | $thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate)); |
101 | |
ed4ed093 |
102 | $weekday = userdate($weekdate, "%e %B"); |
103 | $endweekday = userdate($weekdate+518400, "%e %B"); |
f9903ed0 |
104 | |
105 | if ($thisweek) { |
106 | $highlightcolor = $THEME->cellheading2; |
107 | } else { |
108 | $highlightcolor = $THEME->cellheading; |
109 | } |
110 | |
600149be |
111 | echo "<TR>"; |
d3e2c35a |
112 | echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top WIDTH=20>"; |
f9903ed0 |
113 | echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>"; |
114 | echo "</TD>"; |
115 | |
d3e2c35a |
116 | echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">"; |
f9903ed0 |
117 | echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>"; |
118 | |
b5fe4c93 |
119 | if (! $thisweek = $sections[$week]) { |
f9903ed0 |
120 | $thisweek->course = $course->id; // Create a new week structure |
ad14a10e |
121 | $thisweek->section = $week; |
f9903ed0 |
122 | $thisweek->summary = ""; |
ad14a10e |
123 | if (!$thisweek->id = insert_record("course_sections", $thisweek)) { |
124 | notify("Error inserting new week!"); |
125 | } |
f9903ed0 |
126 | } |
127 | |
2c309dc2 |
128 | if (isediting($course->id)) { |
2c0411e2 |
129 | $thisweek->summary .= " <A TITLE=\"$streditsummary\" HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"$streditsummary\"></A></P>"; |
f9903ed0 |
130 | } |
131 | |
132 | echo text_to_html($thisweek->summary); |
133 | |
94361e02 |
134 | print_section($course->id, $thisweek, $mods, $modnamesused); |
f9903ed0 |
135 | |
2c309dc2 |
136 | if (isediting($course->id)) { |
f9903ed0 |
137 | echo "<DIV ALIGN=right>"; |
b5fe4c93 |
138 | popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=", |
e5dfd0f3 |
139 | $modnames, "section$week", "", "$stradd...", "mods", get_string("activities")); |
f9903ed0 |
140 | echo "</DIV>"; |
141 | } |
142 | |
143 | echo "</TD>"; |
d3e2c35a |
144 | echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top ALIGN=CENTER WIDTH=10>"; |
600149be |
145 | echo "<FONT SIZE=1>"; |
72e62a9e |
146 | if (isset($USER->section)) { |
2c0411e2 |
147 | $strshowallweeks = get_string("showallweeks"); |
148 | echo "<A HREF=\"view.php?id=$course->id&week=all\" TITLE=\"$strshowallweeks\"><IMG SRC=../pix/i/all.gif BORDER=0></A></FONT>"; |
600149be |
149 | } else { |
2c0411e2 |
150 | $strshowonlyweek = get_string("showonlyweek", "", $week); |
151 | echo "<A HREF=\"view.php?id=$course->id&week=$week\" TITLE=\"$strshowonlyweek\"><IMG SRC=../pix/i/one.gif BORDER=0></A></FONT>"; |
600149be |
152 | } |
153 | echo "</TD>"; |
f9903ed0 |
154 | echo "</TR>"; |
600149be |
155 | echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>"; |
f9903ed0 |
156 | |
157 | $week++; |
158 | $weekdate = $nextweekdate; |
159 | } |
160 | echo "</TABLE>"; |
f9903ed0 |
161 | |
162 | |
2c0411e2 |
163 | echo "</TD><TD WIDTH=210>"; |
f51ab26b |
164 | |
600149be |
165 | // Print all the news items. |
f51ab26b |
166 | |
db6395b2 |
167 | if ($course->newsitems) { |
168 | if ($news = forum_get_course_forum($course->id, "news")) { |
169 | print_simple_box(get_string("latestnews"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); |
170 | print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0); |
171 | echo "<FONT SIZE=1>"; |
172 | forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false); |
173 | echo "</FONT>"; |
174 | print_simple_box_end(); |
175 | } |
176 | echo "<BR>"; |
f51ab26b |
177 | } |
600149be |
178 | |
179 | // Print all the recent activity |
4c654ee3 |
180 | print_simple_box(get_string("recentactivity"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); |
600149be |
181 | print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0); |
182 | print_recent_activity($course); |
183 | print_simple_box_end(); |
f51ab26b |
184 | |
19a55d67 |
185 | echo "<BR><IMG SRC=\"../pix/spacer.gif\" WIDTH=210 HEIGHT=1>"; |
186 | |
f51ab26b |
187 | echo "</TD></TR></TABLE>\n"; |
f9903ed0 |
188 | |
189 | ?> |