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
|
|
|
|
|
|
|
optional_variable($id); // course
|
|
|
|
|
|
|
|
if ($id) {
|
|
|
|
if (! $course = get_record("course", "id", $id)) {
|
|
|
|
error("Course ID is incorrect");
|
|
|
|
}
|
|
|
|
} else {
|
2002-08-02 09:19:45 +00:00
|
|
|
if (! $course = get_site()) {
|
2002-06-20 15:15:22 +00:00
|
|
|
error("Could not find a top-level course!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($course->category) {
|
|
|
|
require_login($course->id);
|
|
|
|
}
|
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
unset($SESSION->fromdiscussion);
|
2002-06-20 15:15:22 +00:00
|
|
|
|
2002-08-02 09:19:45 +00:00
|
|
|
add_to_log($course->id, "forum", "view forums", "index.php?id=$course->id");
|
|
|
|
|
|
|
|
$strforums = get_string("forums", "forum");
|
2002-12-23 15:33:40 +00:00
|
|
|
$strforum = get_string("forum", "forum");
|
|
|
|
$strdescription = get_string("description");
|
|
|
|
$strdiscussions = get_string("discussions", "forum");
|
|
|
|
$strsubscribed = get_string("subscribed", "forum");
|
|
|
|
|
|
|
|
$searchform = forum_print_search_form($course, "", true, "plain");
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
if ($course->category) {
|
2002-08-02 09:19:45 +00:00
|
|
|
print_header("$course->shortname: $strforums", "$course->fullname",
|
2002-11-10 08:43:44 +00:00
|
|
|
"<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> $strforums",
|
2002-12-23 15:33:40 +00:00
|
|
|
"", "", true, $searchform, navmenu($course));
|
2002-06-20 15:15:22 +00:00
|
|
|
} else {
|
2002-12-23 15:33:40 +00:00
|
|
|
print_header("$course->shortname: $strforums", "$course->fullname", "$strforums",
|
|
|
|
"", "", true, $searchform, navmenu($course));
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
2002-12-23 15:33:40 +00:00
|
|
|
|
2002-08-02 09:19:45 +00:00
|
|
|
|
|
|
|
$table->head = array ($strforum, $strdescription, $strdiscussions);
|
|
|
|
$table->align = array ("LEFT", "LEFT", "CENTER");
|
|
|
|
|
|
|
|
$can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin());
|
2002-06-20 15:15:22 +00:00
|
|
|
|
|
|
|
if ($can_subscribe) {
|
2002-08-02 09:19:45 +00:00
|
|
|
$table->head[] = $strsubscribed;
|
|
|
|
$table->align[] = "CENTER";
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
|
|
|
|
2003-04-25 05:24:29 +00:00
|
|
|
if ($forums = get_records("forum", "course", $id, "name ASC")) {
|
2002-07-20 17:56:21 +00:00
|
|
|
foreach ($forums as $forum) {
|
2003-04-25 05:24:29 +00:00
|
|
|
$forum->visible = true;
|
2002-07-20 18:20:19 +00:00
|
|
|
switch ($forum->type) {
|
2002-07-31 16:13:55 +00:00
|
|
|
case "news":
|
|
|
|
case "social":
|
2003-04-25 05:24:29 +00:00
|
|
|
$forum->visible = instance_is_visible("forum", $forum);
|
2002-07-31 16:13:55 +00:00
|
|
|
$generalforums[] = $forum;
|
2002-07-20 18:20:19 +00:00
|
|
|
break;
|
|
|
|
case "teacher":
|
|
|
|
if (isteacher($course->id)) {
|
|
|
|
$generalforums[] = $forum;
|
|
|
|
}
|
|
|
|
break;
|
2002-08-03 08:16:31 +00:00
|
|
|
default:
|
|
|
|
if (!$course->category) {
|
|
|
|
$generalforums[] = $forum;
|
|
|
|
}
|
|
|
|
break;
|
2002-07-20 17:56:21 +00:00
|
|
|
}
|
2002-07-20 18:20:19 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-20 17:56:21 +00:00
|
|
|
|
2002-07-20 18:20:19 +00:00
|
|
|
if ($generalforums) {
|
|
|
|
foreach ($generalforums as $forum) {
|
2002-07-31 14:19:35 +00:00
|
|
|
$count = count_records("forum_discussions", "forum", "$forum->id");
|
2002-07-20 17:56:21 +00:00
|
|
|
|
2003-05-23 05:05:49 +00:00
|
|
|
$forum->intro = forum_shorten_post($forum->intro);
|
|
|
|
replace_smilies($forum->intro);
|
|
|
|
|
2003-04-25 05:24:29 +00:00
|
|
|
if ($forum->visible) {
|
|
|
|
$forumlink = "<a href=\"view.php?f=$forum->id\">$forum->name</a>";
|
2003-04-24 17:15:59 +00:00
|
|
|
} else {
|
2003-04-25 05:24:29 +00:00
|
|
|
$forumlink = "<a class=\"dimmed\" href=\"view.php?f=$forum->id\">$forum->name</a>";
|
2003-04-24 17:15:59 +00:00
|
|
|
}
|
|
|
|
|
2002-07-20 17:56:21 +00:00
|
|
|
if ($can_subscribe) {
|
2002-07-31 14:19:35 +00:00
|
|
|
if (forum_is_forcesubscribed($forum->id)) {
|
2002-08-02 09:19:45 +00:00
|
|
|
$sublink = get_string("yes");
|
2002-07-20 17:56:21 +00:00
|
|
|
} else {
|
2002-07-31 14:19:35 +00:00
|
|
|
if (forum_is_subscribed($USER->id, $forum->id)) {
|
2002-08-02 09:19:45 +00:00
|
|
|
$subscribed = get_string("yes");
|
|
|
|
$subtitle = get_string("unsubscribe", "forum");
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2002-08-02 09:19:45 +00:00
|
|
|
$subscribed = get_string("no");
|
|
|
|
$subtitle = get_string("subscribe", "forum");
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2003-04-25 05:24:29 +00:00
|
|
|
$sublink = "<a title=\"$subtitle\" href=\"subscribe.php?id=$forum->id\">$subscribed</a>";
|
2002-07-20 17:56:21 +00:00
|
|
|
}
|
2003-04-25 05:24:29 +00:00
|
|
|
$table->data[] = array ($forumlink, "$forum->intro", "$count", $sublink);
|
2002-07-20 17:56:21 +00:00
|
|
|
} else {
|
2003-04-25 05:24:29 +00:00
|
|
|
$table->data[] = array ($forumlink, "$forum->intro", "$count");
|
2002-07-20 17:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-02 09:19:45 +00:00
|
|
|
print_heading(get_string("generalforums", "forum"));
|
2002-07-20 18:20:19 +00:00
|
|
|
print_table($table);
|
|
|
|
unset($table->data);
|
|
|
|
}
|
2002-07-20 17:56:21 +00:00
|
|
|
|
2002-08-03 08:16:31 +00:00
|
|
|
if ($course->category) { // Only real courses have learning forums
|
|
|
|
// Add extra field for section number, at the front
|
|
|
|
array_unshift($table->head, "");
|
2003-05-23 04:51:28 +00:00
|
|
|
array_unshift($table->align, "center");
|
2002-08-03 08:16:31 +00:00
|
|
|
|
2003-07-12 05:19:18 +00:00
|
|
|
if ($learningforums = get_all_instances_in_course("forum", $course)) {
|
2002-10-25 14:46:42 +00:00
|
|
|
foreach ($learningforums as $key => $forum) {
|
|
|
|
if ($forum->type == "news" or $forum->type == "social") {
|
|
|
|
unset($learningforums[$key]); // Remove these
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($learningforums) {
|
2002-08-03 08:16:31 +00:00
|
|
|
foreach ($learningforums as $forum) {
|
|
|
|
$count = count_records("forum_discussions", "forum", "$forum->id");
|
|
|
|
|
2003-05-23 05:05:49 +00:00
|
|
|
$forum->intro = forum_shorten_post($forum->intro);
|
|
|
|
replace_smilies($forum->intro);
|
2002-08-03 08:16:31 +00:00
|
|
|
|
|
|
|
if (!$forum->section) { // some forums are in the "0" section
|
|
|
|
$forum->section = "";
|
|
|
|
}
|
2003-04-24 17:15:59 +00:00
|
|
|
|
2003-04-25 05:24:29 +00:00
|
|
|
if ($forum->visible) {
|
|
|
|
$forumlink = "<a href=\"view.php?f=$forum->id\">$forum->name</a>";
|
2003-04-24 17:15:59 +00:00
|
|
|
} else {
|
2003-04-25 05:24:29 +00:00
|
|
|
$forumlink = "<a class=\"dimmed\" href=\"view.php?f=$forum->id\">$forum->name</a>";
|
2003-04-24 17:15:59 +00:00
|
|
|
}
|
2003-04-25 05:24:29 +00:00
|
|
|
|
2002-08-03 08:16:31 +00:00
|
|
|
if ($can_subscribe) {
|
|
|
|
if (forum_is_forcesubscribed($forum->id)) {
|
|
|
|
$sublink = get_string("yes");
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2002-08-03 08:16:31 +00:00
|
|
|
if (forum_is_subscribed($USER->id, $forum->id)) {
|
|
|
|
$subscribed = get_string("yes");
|
|
|
|
$subtitle = get_string("unsubscribe", "forum");
|
|
|
|
} else {
|
|
|
|
$subscribed = get_string("no");
|
|
|
|
$subtitle = get_string("subscribe", "forum");
|
|
|
|
}
|
2003-04-25 05:24:29 +00:00
|
|
|
$sublink = "<a title=\"$subtitle\" href=\"subscribe.php?id=$forum->id\">$subscribed</a>";
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2003-04-25 05:24:29 +00:00
|
|
|
$table->data[] = array ("$forum->section", $forumlink, "$forum->intro", "$count", "$sublink");
|
2002-08-03 08:16:31 +00:00
|
|
|
} else {
|
2003-04-25 05:24:29 +00:00
|
|
|
$table->data[] = array ("$forum->section", $forumlink, "$forum->intro", "$count");
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-03 08:16:31 +00:00
|
|
|
print_heading(get_string("learningforums", "forum"));
|
|
|
|
print_table($table);
|
2002-06-20 15:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|