2002-06-20 15:15:22 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
require("../../config.php");
|
|
|
|
require("lib.php");
|
|
|
|
|
|
|
|
optional_variable($id); // Course Module ID
|
|
|
|
optional_variable($f); // Forum ID
|
2002-07-31 14:19:35 +00:00
|
|
|
optional_variable($mode); // Display mode (for single forum)
|
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");
|
|
|
|
}
|
2002-07-04 07:48:44 +00:00
|
|
|
$buttontext = update_module_icon($cm->id, $course->id);
|
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");
|
|
|
|
}
|
2002-07-29 08:11:12 +00:00
|
|
|
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
|
|
|
$buttontext = update_module_icon($cm->id, $course->id);
|
|
|
|
} else {
|
|
|
|
$buttontext = "";
|
|
|
|
}
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
error("Must specify a course module or a forum ID");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($course->category) {
|
|
|
|
require_login($course->id);
|
|
|
|
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
|
|
|
|
<A HREF=\"index.php?id=$course->id\">Forums</A> ->";
|
2002-07-14 13:32:51 +00:00
|
|
|
} else {
|
|
|
|
$navigation = "<A HREF=\"index.php?id=$course->id\">Forums</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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-24 15:27:12 +00:00
|
|
|
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",
|
|
|
|
"$navigation $forum->name", "", "", true, $buttontext);
|
|
|
|
|
|
|
|
if ($USER) {
|
2002-07-31 14:19:35 +00:00
|
|
|
$SESSION->fromdiscussion = "$FULLME";
|
|
|
|
if (forum_is_forcesubscribed($forum->id)) {
|
|
|
|
$subtext = "Everyone is subscribed to this forum";
|
|
|
|
if (isteacher($course->id)) {
|
|
|
|
echo "<DIV ALIGN=RIGHT><FONT SIZE=1>";
|
|
|
|
echo "<A TITLE=\"Allow people to choose\" HREF=\"subscribe.php?id=$forum->id&force=no\">$subtext</A>";
|
|
|
|
echo "</FONT></DIV>";
|
|
|
|
} else {
|
|
|
|
echo "<DIV ALIGN=RIGHT><FONT SIZE=1>$subtext</FONT></DIV>";
|
|
|
|
}
|
|
|
|
|
2002-06-20 15:15:22 +00:00
|
|
|
} else {
|
2002-07-31 14:19:35 +00:00
|
|
|
$subtext = "Everyone can choose to be subscribed";
|
|
|
|
if (isteacher($course->id)) {
|
|
|
|
echo "<DIV ALIGN=RIGHT><FONT SIZE=1>";
|
|
|
|
echo "<A TITLE=\"Force everyone to subscribe\" HREF=\"subscribe.php?id=$forum->id&force=yes\">$subtext</A>";
|
|
|
|
echo "</FONT></DIV>";
|
|
|
|
$subtext = "<A HREF=\"subscribers.php?id=$forum->id\">Show subscribers</A>";
|
|
|
|
echo "<DIV ALIGN=RIGHT><FONT SIZE=1>$subtext</FONT></DIV>";
|
2002-07-31 15:09:39 +00:00
|
|
|
} else {
|
|
|
|
echo "<DIV ALIGN=RIGHT><FONT SIZE=1>$subtext</FONT></DIV>";
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
if (forum_is_subscribed($USER->id, $forum->id)) {
|
|
|
|
$subtext = "Unsubscribe me";
|
|
|
|
} else {
|
|
|
|
$subtext = "Subscribe me";
|
|
|
|
}
|
2002-07-31 15:09:39 +00:00
|
|
|
$subtext = "<A TITLE=\"...this forum only\" HREF=\"subscribe.php?id=$forum->id\">$subtext</A>";
|
2002-07-31 14:19:35 +00:00
|
|
|
echo "<DIV ALIGN=RIGHT><FONT SIZE=1>$subtext</FONT></DIV>";
|
2002-07-14 13:32:51 +00:00
|
|
|
}
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
|
|
|
|
2002-06-25 06:47:34 +00:00
|
|
|
|
|
|
|
switch ($forum->type) {
|
2002-07-31 14:19:35 +00:00
|
|
|
case "single":
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
forum_set_display_mode($mode);
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_print_discussion($course, $discussion, $post, $USER->mode);
|
2002-07-31 14:19:35 +00:00
|
|
|
break;
|
|
|
|
|
2002-06-25 06:47:34 +00:00
|
|
|
case "eachuser":
|
2002-07-31 14:19:35 +00:00
|
|
|
print_simple_box(text_to_html($forum->intro), "CENTER");
|
2002-06-25 06:47:34 +00:00
|
|
|
echo "<P ALIGN=CENTER>";
|
2002-08-01 03:50:27 +00:00
|
|
|
if (forum_user_can_post_discussion($forum)) {
|
2002-07-29 09:17:14 +00:00
|
|
|
echo "This forum allows one discussion topic to be posted per person.";
|
2002-06-25 06:47:34 +00:00
|
|
|
} else {
|
|
|
|
echo " ";
|
|
|
|
}
|
|
|
|
echo "</P>";
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_print_latest_discussions($forum->id, 0);
|
2002-06-25 06:47:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-07-31 14:19:35 +00:00
|
|
|
print_simple_box(text_to_html($forum->intro), "CENTER");
|
2002-06-25 06:47:34 +00:00
|
|
|
echo "<P> </P>";
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_print_latest_discussions($forum->id, 0);
|
2002-06-25 06:47:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|