*** empty log message ***
[moodle.git] / course / topics.php
CommitLineData
0b35af18 1<?PHP // $Id$
2 // Display the whole course as "topics" made of of modules
3 // In fact, this is very similar to the "weeks" format, in that
4 // each "topic" is actually a week. The main difference is that
5 // the dates aren't printed - it's just an aesthetic thing for
6 // courses that aren't so rigidly defined by time.
7 // Included from "view.php"
8
765814de 9 include_once("$CFG->dirroot/mod/forum/lib.php");
0b35af18 10
7468bf01 11 if (! $sections = get_all_sections($course->id) ) {
b5fe4c93 12 $section->course = $course->id; // Create a default section.
13 $section->section = 0;
14 $section->id = insert_record("course_sections", $section);
7468bf01 15 if (! $sections = get_all_sections($course->id) ) {
b5fe4c93 16 error("Error finding or creating section structures for this course");
0b35af18 17 }
18 }
19
0b35af18 20 if (isset($topic)) {
21 if ($topic == "all") {
22 unset($USER->topic);
23 } else {
24 $USER->topic = $topic;
25 }
8223d271 26 save_session("USER");
0b35af18 27 }
28
29 if (isteacher($course->id) and isset($marker)) {
30 $course->marker = $marker;
31 if (! set_field("course", "marker", $marker, "id", $course->id)) {
32 error("Could not mark that topic for this course");
33 }
34 }
35
36
37 // Layout the whole page as three big columns.
38 echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>";
39 echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
40
41 // Layout the left column
42
43
44 // Links to people
45
7ff56f2d 46 $blinker = " <BLINK>*</BLINK>";
47
2c0411e2 48 print_simple_box(get_string("people"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
59a7100c 49 $moddata[]="<A TITLE=\"".get_string("listofallpeople")."\" HREF=\"../user/index.php?id=$course->id\">".get_string("participants")."</A>";
2c0411e2 50 $modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
2415d953 51 $editmyprofile = "<A TITLE=\"$USER->firstname $USER->lastname\" HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
97b37854 52 if ($USER->description) {
7ff56f2d 53 $moddata[]= $editmyprofile;
97b37854 54 } else {
7ff56f2d 55 $moddata[]= $editmyprofile.$blinker;
97b37854 56 }
2c0411e2 57 $modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
0b35af18 58 print_side_block("", $moddata, "", $modicon);
59
60
61 // Then all the links to module types
62
63 $moddata = array();
64 $modicon = array();
90845098 65 if ($modnamesused) {
66 foreach ($modnamesused as $modname => $modfullname) {
67 $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
2c0411e2 68 $modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
0b35af18 69 }
70 }
7b5baeb7 71 print_simple_box(get_string("activities"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
0b35af18 72 print_side_block("", $moddata, "", $modicon);
73
501cdbd8 74 // Print a form to search forums
5d13db8a 75 print_simple_box(get_string("search","forum"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
0b35af18 76 echo "<DIV ALIGN=CENTER>";
7a12aab4 77 forum_print_search_form($course);
0b35af18 78 echo "</DIV>";
79
80 // Admin links and controls
0b35af18 81 if (isteacher($course->id)) {
b4d7002e 82 print_course_admin_links($course);
0b35af18 83 }
84
0b35af18 85 // Start main column
86 echo "</TD><TD WIDTH=\"*\">";
87
2c0411e2 88 print_simple_box(get_string("topicoutline"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
0b35af18 89
b5fe4c93 90 // Everything below uses "section" terminology - each "section" is a topic.
0b35af18 91
b5fe4c93 92 // Now all the sectionly modules
0b35af18 93 $timenow = time();
b5fe4c93 94 $section = 1;
0b35af18 95
2c0411e2 96 $streditsummary = get_string("editsummary");
97 $stradd = get_string("add");
98
0b35af18 99 echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
b5fe4c93 100 while ($section <= $course->numsections) {
0b35af18 101
102 if (isset($USER->topic)) { // Just display a single topic
b5fe4c93 103 if ($USER->topic != $section) {
104 $section++;
0b35af18 105 continue;
106 }
107 }
108
b5fe4c93 109 $currenttopic = ($course->marker == $section);
0b35af18 110
111 if ($currenttopic) {
112 $highlightcolor = $THEME->cellheading2;
113 } else {
114 $highlightcolor = $THEME->cellheading;
115 }
116
117 echo "<TR>";
118 echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top WIDTH=20>";
b5fe4c93 119 echo "<P ALIGN=CENTER><FONT SIZE=3><B>$section</B></FONT></P>";
0b35af18 120 echo "</TD>";
121
122 echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
123
b5fe4c93 124 if (! $thissection = $sections[$section]) {
125 $thissection->course = $course->id; // Create a new section structure
126 $thissection->section = $section;
127 $thissection->summary = "";
5657e2df 128 if (!$thissection->id = insert_record("course_sections", $thissection)) {
129 notify("Error inserting new topic!");
130 }
0b35af18 131 }
132
9dc79114 133 if (isediting($course->id)) {
2c0411e2 134 $thissection->summary .= "&nbsp;<A HREF=editsection.php?id=$thissection->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"$streditsummary\"></A></P>";
0b35af18 135 }
136
b5fe4c93 137 echo text_to_html($thissection->summary);
0b35af18 138
94361e02 139 print_section($course->id, $thissection, $mods, $modnamesused);
0b35af18 140
9dc79114 141 if (isediting($course->id)) {
0b35af18 142 echo "<DIV ALIGN=right>";
b5fe4c93 143 popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
e5dfd0f3 144 $modnames, "section$section", "", "$stradd...", "mods", get_string("activities"));
0b35af18 145 echo "</DIV>";
146 }
147
148 echo "</TD>";
149 echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top ALIGN=CENTER WIDTH=10>";
150 echo "<FONT SIZE=1>";
151 if (isset($USER->topic)) {
2c0411e2 152 $strshowalltopics = get_string("showalltopics");
153 echo "<A HREF=\"view.php?id=$course->id&topic=all\" TITLE=\"$strshowalltopics\"><IMG SRC=../pix/i/all.gif BORDER=0></A><BR><BR>";
0b35af18 154 } else {
2c0411e2 155 $strshowonlytopic = get_string("showonlytopic", "", $section);
156 echo "<A HREF=\"view.php?id=$course->id&topic=$section\" TITLE=\"$strshowonlytopic\"><IMG SRC=../pix/i/one.gif BORDER=0></A><BR><BR>";
0b35af18 157 }
9dc79114 158 if (isediting($course->id) and $course->marker != $section) {
2c0411e2 159 $strmarkthistopic = get_string("markthistopic");
160 echo "<A HREF=\"view.php?id=$course->id&marker=$section\" TITLE=\"$strmarkthistopic\"><IMG SRC=../pix/i/marker.gif BORDER=0></A><BR><BR>";
0b35af18 161 }
162 echo "</TD>";
163 echo "</TR>";
164 echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
165
b5fe4c93 166 $section++;
0b35af18 167 }
168 echo "</TABLE>";
169
170
2c0411e2 171 echo "</TD><TD WIDTH=210>";
0b35af18 172
173 // Print all the news items.
174
db6395b2 175 if ($course->newsitems) {
176 if ($news = forum_get_course_forum($course->id, "news")) {
177 print_simple_box(get_string("latestnews"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
178 print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
179 echo "<FONT SIZE=1>";
180 forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
181 echo "</FONT>";
182 print_simple_box_end();
183 }
184 echo "<BR>";
0b35af18 185 }
0b35af18 186
187 // Print all the recent activity
4c654ee3 188 print_simple_box(get_string("recentactivity"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
0b35af18 189 print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
190 print_recent_activity($course);
191 print_simple_box_end();
192
193 echo "</TD></TR></TABLE>\n";
194
195?>