2005-04-25 10:56:11 +00:00
|
|
|
<?php // $Id$
|
2005-04-25 03:56:02 +00:00
|
|
|
|
2005-04-25 10:56:11 +00:00
|
|
|
// Set tracking option for the forum.
|
2005-04-25 03:56:02 +00:00
|
|
|
|
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
|
|
|
|
2005-04-28 19:49:01 +00:00
|
|
|
require_variable($f); // The forum to mark
|
2005-04-25 15:00:27 +00:00
|
|
|
require_variable($mark); // Read or unread?
|
|
|
|
optional_variable($d); // Discussion to mark.
|
|
|
|
optional_variable($returnpage, 'index.php'); // Page to return to.
|
2005-04-25 03:56:02 +00:00
|
|
|
|
2005-04-28 19:49:01 +00:00
|
|
|
if (! $forum = get_record("forum", "id", $f)) {
|
2005-04-25 03:56:02 +00:00
|
|
|
error("Forum ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $forum->course)) {
|
|
|
|
error("Forum doesn't belong to a course!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) {
|
|
|
|
$cm->id = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = $USER;
|
|
|
|
|
|
|
|
require_course_login($course, false, $cm);
|
|
|
|
|
|
|
|
if (isguest()) { // Guests can't change forum
|
|
|
|
$wwwroot = $CFG->wwwroot.'/login/index.php';
|
|
|
|
if (!empty($CFG->loginhttps)) {
|
|
|
|
$wwwroot = str_replace('http','https', $wwwroot);
|
|
|
|
}
|
|
|
|
|
|
|
|
$strforums = get_string('modulenameplural', 'forum');
|
|
|
|
if ($course->category) {
|
|
|
|
print_header($course->shortname, $course->fullname,
|
|
|
|
"<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
|
|
<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
|
|
|
|
<a href=\"view.php?f=$forum->id\">".format_string($forum->name,true)."</a>", '', '', true, "", navmenu($course, $cm));
|
|
|
|
} else {
|
|
|
|
print_header($course->shortname, $course->fullname,
|
|
|
|
"<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
|
|
|
|
<a href=\"view.php?f=$forum->id\">".format_string($forum->name,true)."</a>", '', '', true, "", navmenu($course, $cm));
|
|
|
|
}
|
|
|
|
notice_yesno(get_string('noguesttracking', 'forum').'<br /><br />'.get_string('liketologin'),
|
|
|
|
$wwwroot, $_SERVER['HTTP_REFERER']);
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-04-28 19:49:01 +00:00
|
|
|
if ($returnpage == 'index.php') {
|
|
|
|
$returnto = forum_go_back_to($returnpage.'?id='.$course->id);
|
|
|
|
} else {
|
|
|
|
$returnto = forum_go_back_to($returnpage.'?f='.$forum->id);
|
|
|
|
}
|
2005-04-25 03:56:02 +00:00
|
|
|
|
|
|
|
$info->name = fullname($user);
|
|
|
|
$info->forum = format_string($forum->name);
|
|
|
|
|
|
|
|
if ($mark == 'read') {
|
2005-04-25 15:00:27 +00:00
|
|
|
if (!empty($d)) {
|
|
|
|
if (forum_tp_mark_discussion_read($user->id, $d, $forum->id)) {
|
|
|
|
add_to_log($course->id, "discussion", "mark read", "view.php?f=$forum->id", $d, $cm->id);
|
|
|
|
redirect($returnto);
|
|
|
|
} else {
|
|
|
|
error("Could not mark that forum read.", $_SERVER["HTTP_REFERER"]);
|
|
|
|
}
|
2005-04-25 03:56:02 +00:00
|
|
|
} else {
|
2005-04-25 15:00:27 +00:00
|
|
|
if (forum_tp_mark_forum_read($user->id, $forum->id)) {
|
|
|
|
add_to_log($course->id, "forum", "mark read", "view.php?f=$forum->id", $forum->id, $cm->id);
|
|
|
|
redirect($returnto);
|
|
|
|
} else {
|
|
|
|
error("Could not mark that forum read.", $_SERVER["HTTP_REFERER"]);
|
|
|
|
}
|
2005-04-25 03:56:02 +00:00
|
|
|
}
|
|
|
|
|
2005-04-25 14:02:00 +00:00
|
|
|
/// FUTURE - Add ability to mark them as unread.
|
2005-04-25 03:56:02 +00:00
|
|
|
// } else { // subscribe
|
|
|
|
// if (forum_tp_start_tracking($forum->id, $user->id)) {
|
|
|
|
// add_to_log($course->id, "forum", "mark unread", "view.php?f=$forum->id", $forum->id, $cm->id);
|
|
|
|
// redirect($returnto, get_string("nowtracking", "forum", $info), 1);
|
|
|
|
// } else {
|
|
|
|
// error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|