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)) { |
94361e02 |
14 | error("Discussion ID was incorrect or no longer exists"); |
501cdbd8 |
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 | |
02300104 |
29 | add_to_log($course->id, "forum", "view discussion", "discuss.php?".$_SERVER["QUERY_STRING"], "$discussion->id"); |
501cdbd8 |
30 | |
31 | unset($SESSION->fromdiscussion); |
8223d271 |
32 | save_session("SESSION"); |
501cdbd8 |
33 | |
34 | forum_set_display_mode($mode); |
35 | |
36 | if (abs($USER->mode) == 1) { // If flat display then display the lot. |
37 | $parent = 0; |
38 | } |
39 | |
40 | if (!$parent) { |
41 | $parent = $discussion->firstpost; |
42 | $navtail = "$discussion->name"; |
43 | } |
44 | |
11b0c469 |
45 | if (! $post = forum_get_post_full($parent)) { |
501cdbd8 |
46 | error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); |
47 | } |
48 | |
49 | if (!$navtail) { |
50 | $navtail = "<A HREF=\"discuss.php?d=$discussion->id\">$discussion->name</A> -> $post->subject"; |
51 | } |
52 | |
f781b794 |
53 | $navmiddle = "<A HREF=\"../forum/index.php?id=$course->id\">".get_string("forums", "forum")."</A> -> <A HREF=\"../forum/view.php?f=$forum->id\">$forum->name</A>"; |
501cdbd8 |
54 | |
55 | if ($cm->id) { |
56 | $updatebutton = update_module_icon($cm->id, $course->id); |
57 | } else { |
58 | $updatebutton = ""; |
59 | } |
60 | |
61 | if ($course->category) { |
62 | print_header("$course->shortname: $discussion->name", "$course->fullname", |
63 | "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> |
64 | $navmiddle -> $navtail", "", "", true, $updatebutton); |
65 | } else { |
66 | print_header("$course->shortname: $discussion->name", "$course->fullname", |
67 | "$navmiddle -> $navtail", "", "", true, $updatebutton); |
68 | } |
69 | |
fe25fc9b |
70 | forum_print_discussion($course, $forum, $discussion, $post, $USER->mode); |
501cdbd8 |
71 | |
72 | print_footer($course); |
73 | |
74 | ?> |