libdir/rsslib.php"); $id = optional_param('id', 0, PARAM_INT); // Course Module ID $f = optional_param('f', 0, PARAM_INT); // Forum ID $mode = optional_param('mode', 0, PARAM_INT); // Display mode (for single forum) $showall = optional_param('showall', '', PARAM_INT); // show all discussions on one page $changegroup = optional_param('group', -1, PARAM_INT); // choose the current group $page = optional_param('page', 0, PARAM_INT); // which page to show $search = optional_param('search', ''); // search string $buttontext = ''; if ($id) { if (! $cm = get_coursemodule_from_id('forum', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { error("Course is misconfigured"); } if (! $forum = get_record("forum", "id", $cm->instance)) { error("Forum ID was incorrect"); } // move require_course_login here to use forced language for course // fix for MDL-6926 require_course_login($course, true, $cm); $strforums = get_string("modulenameplural", "forum"); $strforum = get_string("modulename", "forum"); $buttontext = update_module_button($cm->id, $course->id, $strforum); } else if ($f) { if (! $forum = get_record("forum", "id", $f)) { error("Forum ID was incorrect or no longer exists"); } if (! $course = get_record("course", "id", $forum->course)) { error("Forum is misconfigured - don't know what course it's from"); } if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { error("Course Module missing"); } // move require_course_login here to use forced language for course // fix for MDL-6926 require_course_login($course, true, $cm); $strforums = get_string("modulenameplural", "forum"); $strforum = get_string("modulename", "forum"); $buttontext = update_module_button($cm->id, $course->id, $strforum); } else { error('Must specify a course module or a forum ID'); } if (!$buttontext) { $buttontext = forum_search_form($course, $search); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); /// Print header. /// Add ajax-related libs require_js(array('yui_yahoo', 'yui_event', 'yui_dom', 'yui_connection', 'yui_json')); require_js($CFG->wwwroot . '/mod/forum/rate_ajax.js'); $navigation = build_navigation('', $cm); print_header_simple(format_string($forum->name), "", $navigation, "", "", true, $buttontext, navmenu($course, $cm)); /// Some capability checks. if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) { notice(get_string("activityiscurrentlyhidden")); } if (!has_capability('mod/forum:viewdiscussion', $context)) { notice(get_string('noviewdiscussionspermission', 'forum')); } /// find out current groups mode groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/forum/view.php?id=' . $cm->id); $currentgroup = groups_get_activity_group($cm); $groupmode = groups_get_activity_groupmode($cm); /// Okay, we can show the discussions. Log the forum view. if ($cm->id) { add_to_log($course->id, "forum", "view forum", "view.php?id=$cm->id", "$forum->id", $cm->id); } else { add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id"); } /// Print settings and things across the top // If it's a simple single discussion forum, we need to print the display // mode control. if ($forum->type == 'single') { if (! $discussion = get_record("forum_discussions", "forum", $forum->id)) { if ($discussions = get_records("forum_discussions", "forum", $forum->id, "timemodified ASC")) { $discussion = array_pop($discussions); } } if ($discussion) { if ($mode) { set_user_preference("forum_displaymode", $mode); } $displaymode = get_user_preferences("forum_displaymode", $CFG->forum_displaymode); forum_print_mode_form($forum->id, $displaymode, $forum->type); } } // print_box_start('forumcontrol clearfix'); // print_box_start('subscription clearfix'); echo '
'; if (forum_user_can_post_discussion($forum, null, -1, $cm)) { print_string("allowsdiscussions", "forum"); } else { echo ' '; } echo '
'; if (!empty($showall)) { forum_print_latest_discussions($course, $forum, 0, 'header', '', -1, -1, -1, 0, $cm); } else { forum_print_latest_discussions($course, $forum, -1, 'header', '', -1, -1, $page, $CFG->forum_manydiscussions, $cm); } break; case 'teacher': if (!empty($showall)) { forum_print_latest_discussions($course, $forum, 0, 'header', '', -1, -1, -1, 0, $cm); } else { forum_print_latest_discussions($course, $forum, -1, 'header', '', -1, -1, $page, $CFG->forum_manydiscussions, $cm); } break; default: if (!empty($forum->intro)) { $options = new stdclass; $options->para = false; print_box(format_text($forum->intro, FORMAT_MOODLE, $options), 'generalbox', 'intro'); } echo '