course)) { error("Course ID is incorrect - discussion is faulty"); } if ($course->category) { require_login($course->id); } if (!empty($move)) { if (!isteacher($course->id)) { error("Only teachers can do that!"); } if ($forum = get_record("forum", "id", $move)) { if (!forum_move_attachments($discussion, $move)) { notify("Errors occurred while moving attachment directories - check your file permissions"); } set_field("forum_discussions", "forum", $forum->id, "id", $discussion->id); $discussion->forum = $forum->id; if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { add_to_log($course->id, "forum", "move discussion", "discuss.php?d=$discussion->id", "$discussion->id", $cm->id); } else { add_to_log($course->id, "forum", "move discussion", "discuss.php?d=$discussion->id", "$discussion->id"); } $discussionmoved = true; } else { error("You can't move to that forum - it doesn't exist!"); } } if (empty($forum)) { if (! $forum = get_record("forum", "id", $discussion->forum)) { notify("Bad forum ID stored in this discussion"); } } $logparameters = "d=$discussion->id"; if ($parent) { $logparameters .= "&parent=$parent"; } if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { add_to_log($course->id, "forum", "view discussion", "discuss.php?$logparameters", "$discussion->id", $cm->id); } else { add_to_log($course->id, "forum", "view discussion", "discuss.php?$logparameters", "$discussion->id"); } unset($SESSION->fromdiscussion); if ($mode) { set_user_preference("forum_displaymode", $mode); } $displaymode = get_user_preferences("forum_displaymode", $CFG->forum_displaymode); if ($parent) { if (abs($displaymode) == 1) { // If flat AND parent, then force nested display this time $displaymode = 3; } } else { $parent = $discussion->firstpost; $navtail = "$discussion->name"; } if (! $post = forum_get_post_full($parent)) { error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id"); } if (empty($navtail)) { $navtail = "id\">$discussion->name -> $post->subject"; } $navmiddle = "id\">".get_string("forums", "forum")." -> id\">$forum->name"; $searchform = forum_print_search_form($course, "", true, "plain"); if ($course->category) { print_header("$course->shortname: $discussion->name", "$course->fullname", "id>$course->shortname -> $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm)); } else { print_header("$course->shortname: $discussion->name", "$course->fullname", "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm)); } /// Check to see if groups are being used in this forum /// If so, make sure the current person is allowed to see this discussion /// Also, if we know they should be able to reply, then explicitly set $canreply $canreply = NULL; /// No override one way or the other $groupmode = groupmode($course, $cm); if ($groupmode and !isteacheredit($course->id)) { // Groups must be kept separate if ($groupmode == SEPARATEGROUPS) { require_login(); if (mygroupid($course->id) == $discussion->groupid) { $canreply = true; } else { print_heading("Sorry, you can't see this discussion because you are not in this group"); print_footer(); die; } } else if ($groupmode == VISIBLEGROUPS) { $canreply = (mygroupid($course->id) == $discussion->groupid); } } /// Print the controls across the top echo "
"; if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) { if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) { print_group_menu($groups, $groupmode, $discussion->groupid, "view.php?id=$cm->id&group="); } } echo " | "; forum_print_mode_form($discussion->id, $displaymode); echo " | ";
if (isteacher($course->id)) { // Popup menu to allow discussions to be moved to other forums
if ($forums = get_all_instances_in_course("forum", $course)) {
foreach ($forums as $courseforum) {
if ($courseforum->id != $forum->id) {
$url = "discuss.php?d=$discussion->id&move=$courseforum->id";
$forummenu[$url] = $courseforum->name;
}
}
if (!empty($forummenu)) {
echo " ";
echo popup_form("$CFG->wwwroot/mod/forum/", $forummenu, "forummenu", "",
get_string("movethisdiscussionto", "forum"), "", "", true);
echo " ";
}
}
}
echo " |