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 | } |
20 | $buttontext = update_module_icon($cm->id); |
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 | |
41 | add_to_log($course->id, "forum", "view forum", "index.php?f=$forum->id", "$forum->id"); |
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 | } |
53 | echo "<DIV ALIGN=RIGHT><FONT SIZE=1><A HREF=\"subscribe.php?id=$forum->id\">$subtext</A></FONT></P>"; |
54 | } |
55 | |
56 | forum_latest_topics($forum->id, 0); |
57 | |
58 | print_footer($course); |
59 | |
60 | ?> |