Fix to break out of frames
[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
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
e92ea3d8 36 $displaymode = $USER->mode;
501cdbd8 37
e92ea3d8 38 if ($parent) {
39 if (abs($USER->mode) == 1) { // If flat AND parent, then force nested display this time
40 $displaymode = 3;
41 }
42 } else {
501cdbd8 43 $parent = $discussion->firstpost;
44 $navtail = "$discussion->name";
45 }
46
11b0c469 47 if (! $post = forum_get_post_full($parent)) {
501cdbd8 48 error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
49 }
50
51 if (!$navtail) {
52 $navtail = "<A HREF=\"discuss.php?d=$discussion->id\">$discussion->name</A> -> $post->subject";
53 }
54
f781b794 55 $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 56
501cdbd8 57 if ($course->category) {
58 print_header("$course->shortname: $discussion->name", "$course->fullname",
59 "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> ->
09aebc94 60 $navmiddle -> $navtail", "", "", true);
501cdbd8 61 } else {
62 print_header("$course->shortname: $discussion->name", "$course->fullname",
09aebc94 63 "$navmiddle -> $navtail", "", "", true);
501cdbd8 64 }
65
e92ea3d8 66 forum_print_discussion($course, $forum, $discussion, $post, $displaymode);
501cdbd8 67
68 print_footer($course);
69
70?>