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 | |
b0e3a925 |
6 | require_once("../../config.php"); |
7 | require_once("lib.php"); |
501cdbd8 |
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 | |
dfc9ba9b |
25 | if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { |
b20f74c9 |
26 | //notify("Bad coursemodule for this discussion"); // Only affects navmenu |
dfc9ba9b |
27 | } |
28 | |
501cdbd8 |
29 | if ($course->category) { |
30 | require_login($course->id); |
31 | } |
32 | |
02300104 |
33 | add_to_log($course->id, "forum", "view discussion", "discuss.php?".$_SERVER["QUERY_STRING"], "$discussion->id"); |
501cdbd8 |
34 | |
35 | unset($SESSION->fromdiscussion); |
36 | |
37 | forum_set_display_mode($mode); |
38 | |
e92ea3d8 |
39 | $displaymode = $USER->mode; |
501cdbd8 |
40 | |
e92ea3d8 |
41 | if ($parent) { |
42 | if (abs($USER->mode) == 1) { // If flat AND parent, then force nested display this time |
43 | $displaymode = 3; |
44 | } |
45 | } else { |
501cdbd8 |
46 | $parent = $discussion->firstpost; |
47 | $navtail = "$discussion->name"; |
48 | } |
49 | |
11b0c469 |
50 | if (! $post = forum_get_post_full($parent)) { |
501cdbd8 |
51 | error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); |
52 | } |
53 | |
61e96406 |
54 | if (empty($navtail)) { |
501cdbd8 |
55 | $navtail = "<A HREF=\"discuss.php?d=$discussion->id\">$discussion->name</A> -> $post->subject"; |
56 | } |
57 | |
f781b794 |
58 | $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 |
59 | |
9c9f7d77 |
60 | $searchform = forum_print_search_form($course, "", true, "plain"); |
97485d07 |
61 | |
501cdbd8 |
62 | if ($course->category) { |
63 | print_header("$course->shortname: $discussion->name", "$course->fullname", |
64 | "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> |
97485d07 |
65 | $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm)); |
501cdbd8 |
66 | } else { |
67 | print_header("$course->shortname: $discussion->name", "$course->fullname", |
97485d07 |
68 | "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm)); |
501cdbd8 |
69 | } |
70 | |
e92ea3d8 |
71 | forum_print_discussion($course, $forum, $discussion, $post, $displaymode); |
501cdbd8 |
72 | |
73 | print_footer($course); |
74 | |
75 | ?> |