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