2002-06-20 15:15:22 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2002-06-20 15:15:22 +00:00
|
|
|
|
2003-04-18 05:54:18 +00:00
|
|
|
optional_variable($id); // Course Module ID
|
|
|
|
optional_variable($f); // Forum ID
|
|
|
|
optional_variable($mode); // Display mode (for single forum)
|
2003-01-02 10:35:11 +00:00
|
|
|
optional_variable($search, ""); // search string
|
2003-04-18 05:54:18 +00:00
|
|
|
optional_variable($showall, ""); // show all discussions on one page
|
2004-02-19 17:57:22 +00:00
|
|
|
optional_variable($group, -1); // choose the current group
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
if ($id) {
|
|
|
|
if (! $cm = get_record("course_modules", "id", $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");
|
|
|
|
}
|
2004-02-20 02:29:30 +00:00
|
|
|
|
|
|
|
$strforums = get_string("modulenameplural", "forum");
|
|
|
|
$strforum = get_string("modulename", "forum");
|
|
|
|
|
2002-10-16 04:51:55 +00:00
|
|
|
$buttontext = update_module_button($cm->id, $course->id, $strforum);
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
} else if ($f) {
|
|
|
|
if (! $forum = get_record("forum", "id", $f)) {
|
2002-08-03 08:16:31 +00:00
|
|
|
error("Forum ID was incorrect or no longer exists");
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
|
|
|
if (! $course = get_record("course", "id", $forum->course)) {
|
|
|
|
error("Forum is misconfigured - don't know what course it's from");
|
|
|
|
}
|
2004-02-20 02:29:30 +00:00
|
|
|
|
|
|
|
$strforums = get_string("modulenameplural", "forum");
|
|
|
|
$strforum = get_string("modulename", "forum");
|
|
|
|
|
2002-07-29 08:11:12 +00:00
|
|
|
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
2002-10-16 04:51:55 +00:00
|
|
|
$buttontext = update_module_button($cm->id, $course->id, $strforum);
|
2002-07-29 08:11:12 +00:00
|
|
|
} else {
|
2004-01-31 14:47:57 +00:00
|
|
|
$cm->id = NULL;
|
2002-07-29 08:11:12 +00:00
|
|
|
$buttontext = "";
|
|
|
|
}
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
error("Must specify a course module or a forum ID");
|
|
|
|
}
|
|
|
|
|
2002-12-23 15:33:40 +00:00
|
|
|
if (!$buttontext) {
|
|
|
|
$buttontext = forum_print_search_form($course, $search, true, "plain");
|
|
|
|
}
|
2002-08-15 17:41:24 +00:00
|
|
|
|
2002-06-20 15:15:22 +00:00
|
|
|
if ($course->category) {
|
|
|
|
require_login($course->id);
|
2004-01-15 07:26:52 +00:00
|
|
|
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
|
|
<a href=\"index.php?id=$course->id\">$strforums</a> ->";
|
2002-07-14 13:32:51 +00:00
|
|
|
} else {
|
2004-01-15 07:26:52 +00:00
|
|
|
$navigation = "<a href=\"index.php?id=$course->id\">$strforums</a> ->";
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
|
|
|
|
2002-07-04 08:30:36 +00:00
|
|
|
if ($forum->type == "teacher") {
|
|
|
|
if (!isteacher($course->id)) {
|
|
|
|
error("You must be a $course->teacher to view this forum");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-15 07:26:52 +00:00
|
|
|
if ($cm) {
|
2004-01-31 14:47:57 +00:00
|
|
|
add_to_log($course->id, "forum", "view forum", "view.php?id=$cm->id", "$forum->id", $cm->id);
|
2004-01-15 07:26:52 +00:00
|
|
|
} else {
|
|
|
|
add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id");
|
|
|
|
}
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
print_header("$course->shortname: $forum->name", "$course->fullname",
|
2002-11-10 07:37:15 +00:00
|
|
|
"$navigation $forum->name", "", "", true, $buttontext, navmenu($course, $cm));
|
2002-06-20 15:15:22 +00:00
|
|
|
|
2003-05-15 18:03:22 +00:00
|
|
|
if (!$cm->visible and !isteacher($course->id)) {
|
|
|
|
notice(get_string("activityiscurrentlyhidden"));
|
|
|
|
}
|
|
|
|
|
2004-01-11 17:46:57 +00:00
|
|
|
|
|
|
|
/// Check to see if groups are being used in this forum
|
|
|
|
/// and if so, set $currentgroup to reflect the current group
|
|
|
|
|
2004-02-19 17:57:22 +00:00
|
|
|
$changegroup = isset($_GET['group']) ? $_GET['group'] : -1; // Group change requested?
|
2004-01-11 17:46:57 +00:00
|
|
|
$groupmode = groupmode($course, $cm); // Groups are being used
|
2004-02-19 17:57:22 +00:00
|
|
|
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
|
2004-01-11 17:46:57 +00:00
|
|
|
|
2004-02-19 17:57:22 +00:00
|
|
|
if ($groupmode and ($currentgroup === false) and !isteacheredit($course->id)) {
|
|
|
|
print_heading(get_string("notingroup", "forum"));
|
|
|
|
print_footer($course);
|
2004-01-11 17:46:57 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Print settings and things in a table across the top
|
|
|
|
|
|
|
|
echo '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr valign="top">';
|
|
|
|
|
|
|
|
if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
|
|
|
|
if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
|
|
|
|
echo '<td>';
|
2004-02-19 17:57:22 +00:00
|
|
|
print_group_menu($groups, $groupmode, $currentgroup, "view.php?id=$cm->id&group=");
|
2004-01-11 17:46:57 +00:00
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-20 15:15:22 +00:00
|
|
|
if ($USER) {
|
2004-01-11 17:46:57 +00:00
|
|
|
echo '<td align="right">';
|
2002-07-31 14:19:35 +00:00
|
|
|
$SESSION->fromdiscussion = "$FULLME";
|
|
|
|
if (forum_is_forcesubscribed($forum->id)) {
|
2002-08-15 17:41:24 +00:00
|
|
|
$streveryoneissubscribed = get_string("everyoneissubscribed", "forum");
|
|
|
|
$strallowchoice = get_string("allowchoice", "forum");
|
2003-04-23 15:19:01 +00:00
|
|
|
helpbutton("subscription", $streveryoneissubscribed, "forum");
|
|
|
|
echo "<font size=1>";
|
2002-07-31 14:19:35 +00:00
|
|
|
if (isteacher($course->id)) {
|
2003-04-23 15:19:01 +00:00
|
|
|
echo "<a title=\"$strallowchoice\" href=\"subscribe.php?id=$forum->id&force=no\">$streveryoneissubscribed</a>";
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2003-04-23 15:19:01 +00:00
|
|
|
echo $streveryoneissubscribed;
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2004-01-11 17:46:57 +00:00
|
|
|
echo "</font>";
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2002-06-20 15:15:22 +00:00
|
|
|
} else {
|
2002-08-15 17:41:24 +00:00
|
|
|
$streveryonecanchoose = get_string("everyonecanchoose", "forum");
|
|
|
|
$strforcesubscribe = get_string("forcesubscribe", "forum");
|
|
|
|
$strshowsubscribers = get_string("showsubscribers", "forum");
|
2003-04-23 15:19:01 +00:00
|
|
|
|
|
|
|
helpbutton("subscription", $streveryonecanchoose, "forum");
|
|
|
|
echo "<font size=1>";
|
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
if (isteacher($course->id)) {
|
2003-04-23 15:19:01 +00:00
|
|
|
echo "<a title=\"$strforcesubscribe\" href=\"subscribe.php?id=$forum->id&force=yes\">$streveryonecanchoose</a>";
|
2004-01-11 17:46:57 +00:00
|
|
|
echo "</font><br /><font size=1>";
|
2003-04-23 15:19:01 +00:00
|
|
|
echo "<a href=\"subscribers.php?id=$forum->id\">$strshowsubscribers</a>";
|
2002-07-31 15:09:39 +00:00
|
|
|
} else {
|
2003-04-23 15:19:01 +00:00
|
|
|
echo $streveryonecanchoose;
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2004-01-11 17:46:57 +00:00
|
|
|
echo "</font>";
|
2003-04-23 15:19:01 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
if (forum_is_subscribed($USER->id, $forum->id)) {
|
2003-05-23 05:00:58 +00:00
|
|
|
$subtexttitle = get_string("subscribestop", "forum");
|
2002-08-15 17:41:24 +00:00
|
|
|
$subtext = get_string("unsubscribe", "forum");
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2003-05-23 05:00:58 +00:00
|
|
|
$subtexttitle = get_string("subscribestart", "forum");
|
2002-08-15 17:41:24 +00:00
|
|
|
$subtext = get_string("subscribe", "forum");
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2004-01-11 17:46:57 +00:00
|
|
|
echo "<br />";
|
2003-05-23 05:00:58 +00:00
|
|
|
echo "<font size=1><a title=\"$subtexttitle\" href=\"subscribe.php?id=$forum->id\">$subtext</a></font>";
|
2002-07-14 13:32:51 +00:00
|
|
|
}
|
2004-01-11 17:46:57 +00:00
|
|
|
echo '</td>';
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
|
|
|
|
2004-01-11 17:46:57 +00:00
|
|
|
echo '</tr></table>';
|
|
|
|
|
2004-02-13 15:20:06 +00:00
|
|
|
$forum->intro = trim($forum->intro);
|
2002-06-25 06:47:34 +00:00
|
|
|
|
|
|
|
switch ($forum->type) {
|
2004-01-11 17:46:57 +00:00
|
|
|
case 'single':
|
2002-07-31 14:19:35 +00:00
|
|
|
if (! $discussion = get_record("forum_discussions", "forum", $forum->id)) {
|
|
|
|
if ($discussions = get_records("forum_discussions", "forum", $forum->id, "timemodified ASC")) {
|
|
|
|
notify("Warning! There is more than one discussion in this forum - using the most recent");
|
|
|
|
$discussion = array_pop($discussions);
|
|
|
|
} else {
|
|
|
|
error("Could not find the discussion in this forum");
|
|
|
|
}
|
|
|
|
}
|
2002-08-01 03:50:27 +00:00
|
|
|
if (! $post = forum_get_post_full($discussion->firstpost)) {
|
2002-07-31 14:19:35 +00:00
|
|
|
error("Could not find the first post in this forum");
|
|
|
|
}
|
2004-01-30 08:45:11 +00:00
|
|
|
if ($mode) {
|
|
|
|
set_user_preference("forum_displaymode", $mode);
|
|
|
|
}
|
|
|
|
$displaymode = get_user_preferences("forum_displaymode", $CFG->forum_displaymode);
|
|
|
|
forum_print_discussion($course, $forum, $discussion, $post, $displaymode);
|
2002-07-31 14:19:35 +00:00
|
|
|
break;
|
|
|
|
|
2004-01-11 17:46:57 +00:00
|
|
|
case 'eachuser':
|
2004-02-13 15:20:06 +00:00
|
|
|
if (!empty($forum->intro)) {
|
2004-02-13 03:39:58 +00:00
|
|
|
print_simple_box(format_text($forum->intro), 'center');
|
2003-08-12 16:37:52 +00:00
|
|
|
}
|
2004-01-11 17:46:57 +00:00
|
|
|
echo '<p align="center">';
|
2002-08-01 03:50:27 +00:00
|
|
|
if (forum_user_can_post_discussion($forum)) {
|
2002-08-15 17:41:24 +00:00
|
|
|
print_string("allowsdiscussions", "forum");
|
2002-06-25 06:47:34 +00:00
|
|
|
} else {
|
2004-01-11 17:46:57 +00:00
|
|
|
echo ' ';
|
2002-06-25 06:47:34 +00:00
|
|
|
}
|
2004-01-11 17:46:57 +00:00
|
|
|
echo '</p>';
|
2003-08-12 16:37:52 +00:00
|
|
|
if (!empty($showall)) {
|
2004-01-11 17:46:57 +00:00
|
|
|
forum_print_latest_discussions($forum->id, 0, 'header', '', $currentgroup);
|
2003-08-12 16:37:52 +00:00
|
|
|
} else {
|
2004-01-11 17:46:57 +00:00
|
|
|
forum_print_latest_discussions($forum->id, $CFG->forum_manydiscussions, 'header', '', $currentgroup);
|
2003-08-12 16:37:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-01-11 17:46:57 +00:00
|
|
|
case 'teacher':
|
2003-04-18 05:54:18 +00:00
|
|
|
if (!empty($showall)) {
|
2004-01-11 17:46:57 +00:00
|
|
|
forum_print_latest_discussions($forum->id, 0, 'header', '', $currentgroup);
|
2003-04-18 05:54:18 +00:00
|
|
|
} else {
|
2004-01-11 17:46:57 +00:00
|
|
|
forum_print_latest_discussions($forum->id, $CFG->forum_manydiscussions, 'header', '', $currentgroup);
|
2003-04-18 05:54:18 +00:00
|
|
|
}
|
2002-06-25 06:47:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-02-13 15:20:06 +00:00
|
|
|
if (!empty($forum->intro)) {
|
2004-02-13 03:39:58 +00:00
|
|
|
print_simple_box(format_text($forum->intro), 'center');
|
2003-08-12 16:37:52 +00:00
|
|
|
}
|
2004-01-11 17:46:57 +00:00
|
|
|
echo '<p> </p>';
|
2003-04-18 05:54:18 +00:00
|
|
|
if (!empty($showall)) {
|
2004-01-11 17:46:57 +00:00
|
|
|
forum_print_latest_discussions($forum->id, 0, 'header', '', $currentgroup);
|
2003-04-18 05:54:18 +00:00
|
|
|
} else {
|
2004-01-11 17:46:57 +00:00
|
|
|
forum_print_latest_discussions($forum->id, $CFG->forum_manydiscussions, 'header', '', $currentgroup);
|
2003-04-18 05:54:18 +00:00
|
|
|
}
|
2002-06-25 06:47:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|