501cdbd8 |
1 | <?PHP // $Id$ |
2 | |
3 | // Displays a post, and all the posts below it. |
4 | // If no post is given, displays all posts in a discussion |
5 | |
6 | require("../../config.php"); |
7 | require("lib.php"); |
8 | |
9 | require_variable($d); // Discussion ID |
10 | optional_variable($parent); // If set, then display this post and all children. |
11 | optional_variable($mode); // If set, changes the layout of the thread |
12 | |
13 | if (! $discussion = get_record("forum_discussions", "id", $d)) { |
14 | error("Discussion ID was incorrect"); |
15 | } |
16 | |
17 | if (! $course = get_record("course", "id", $discussion->course)) { |
18 | error("Course ID is incorrect - discussion is faulty"); |
19 | } |
20 | |
21 | if (! $forum = get_record("forum", "id", $discussion->forum)) { |
22 | notify("Bad forum ID stored in this discussion"); |
23 | } |
24 | |
25 | if ($course->category) { |
26 | require_login($course->id); |
27 | } |
28 | |
29 | add_to_log($course->id, "forum", "view discussion", "view.php?".$_SERVER["QUERY_STRING"], "$discussion->id"); |
30 | |
31 | unset($SESSION->fromdiscussion); |
32 | |
33 | forum_set_display_mode($mode); |
34 | |
35 | if (abs($USER->mode) == 1) { // If flat display then display the lot. |
36 | $parent = 0; |
37 | } |
38 | |
39 | if (!$parent) { |
40 | $parent = $discussion->firstpost; |
41 | $navtail = "$discussion->name"; |
42 | } |
43 | |
44 | if (! $post = get_forum_post_full($parent)) { |
45 | error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); |
46 | } |
47 | |
48 | if (!$navtail) { |
49 | $navtail = "<A HREF=\"discuss.php?d=$discussion->id\">$discussion->name</A> -> $post->subject"; |
50 | } |
51 | |
52 | $navmiddle = "<A HREF=\"../forum/index.php?id=$course->id\">Forums</A> -> <A HREF=\"../forum/view.php?f=$forum->id\">$forum->name</A>"; |
53 | |
54 | if ($cm->id) { |
55 | $updatebutton = update_module_icon($cm->id, $course->id); |
56 | } else { |
57 | $updatebutton = ""; |
58 | } |
59 | |
60 | if ($course->category) { |
61 | print_header("$course->shortname: $discussion->name", "$course->fullname", |
62 | "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> |
63 | $navmiddle -> $navtail", "", "", true, $updatebutton); |
64 | } else { |
65 | print_header("$course->shortname: $discussion->name", "$course->fullname", |
66 | "$navmiddle -> $navtail", "", "", true, $updatebutton); |
67 | } |
68 | |
69 | print_discussion($course, $discussion, $post, $USER->mode); |
70 | |
71 | print_footer($course); |
72 | |
73 | ?> |