Prevent caching of these forms
[moodle.git] / mod / forum / view.php
CommitLineData
f93f848a 1<?PHP // $Id$
2
3 require("../../config.php");
4 require("lib.php");
5
6 optional_variable($id); // Course Module ID
7 optional_variable($f); // Forum ID
8
9
10 if ($id) {
11 if (! $cm = get_record("course_modules", "id", $id)) {
12 error("Course Module ID was incorrect");
13 }
14 if (! $course = get_record("course", "id", $cm->course)) {
15 error("Course is misconfigured");
16 }
17 if (! $forum = get_record("forum", "id", $cm->instance)) {
18 error("Forum ID was incorrect");
19 }
da8b7aa7 20 $buttontext = update_module_icon($cm->id, $course->id);
f93f848a 21
22 } else if ($f) {
23 if (! $forum = get_record("forum", "id", $f)) {
24 error("Forum ID was incorrect");
25 }
26 if (! $course = get_record("course", "id", $forum->course)) {
27 error("Forum is misconfigured - don't know what course it's from");
28 }
29 $buttontext = "";
30
31 } else {
32 error("Must specify a course module or a forum ID");
33 }
34
35 if ($course->category) {
36 require_login($course->id);
37 $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
38 <A HREF=\"index.php?id=$course->id\">Forums</A> ->";
39 }
40
dd831125 41 add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id");
f93f848a 42
43 print_header("$course->shortname: $forum->name", "$course->fullname",
44 "$navigation $forum->name", "", "", true, $buttontext);
45
46 if ($USER) {
47 $SESSION->fromdiscuss = "$FULLME";
48 if (is_subscribed($USER->id, $forum->id)) {
49 $subtext = "Unsubscribe from this forum";
50 } else {
51 $subtext = "Subscribe to this forum";
52 }
e07635f4 53 echo "<DIV ALIGN=RIGHT><FONT SIZE=1><A HREF=\"subscribe.php?id=$forum->id\">$subtext</A></FONT></DIV>";
f93f848a 54 }
55
e07635f4 56 print_simple_box(text_to_html($forum->intro), "CENTER");
57
58 switch ($forum->type) {
59 case "eachuser":
60 echo "<P ALIGN=CENTER>";
61 if (user_can_post_discussion($forum)) {
62 echo "This forum allows one discussion topic to be posted per person. Click here to <A HREF=\"../discuss/post.php?forum=$forum->id\">post your topic</A>.";
63 } else {
64 echo "&nbsp";
65 }
66 echo "</P>";
67 break;
68
69 default:
70 echo "<P>&nbsp;</P>";
71 break;
72 }
73
74 print_forum_latest_topics($forum->id, 0);
f93f848a 75
76 print_footer($course);
77
78?>