3 // Set tracking option for the forum.
5 require_once("../../config.php");
6 require_once("lib.php");
8 $f = required_param('f',PARAM_INT
); // The forum to mark
9 $mark = required_param('mark',PARAM_ALPHA
); // Read or unread?
10 $d = optional_param('d',0,PARAM_INT
); // Discussion to mark.
11 $returnpage = optional_param('returnpage', 'index.php', PARAM_FILE
); // Page to return to.
13 if (! $forum = get_record("forum", "id", $f)) {
14 error("Forum ID was incorrect");
17 if (! $course = get_record("course", "id", $forum->course
)) {
18 error("Forum doesn't belong to a course!");
21 if (!$cm = get_coursemodule_from_instance("forum", $forum->id
, $course->id
)) {
22 error("Incorrect cm!");
27 require_course_login($course, false, $cm);
29 if ($returnpage == 'index.php') {
30 $returnto = forum_go_back_to($returnpage.'?id='.$course->id
);
32 $returnto = forum_go_back_to($returnpage.'?f='.$forum->id
);
35 if (isguest()) { // Guests can't change forum
36 $wwwroot = $CFG->wwwroot
.'/login/index.php';
37 if (!empty($CFG->loginhttps
)) {
38 $wwwroot = str_replace('http:','https:', $wwwroot);
41 $navigation = build_navigation('', $cm);
42 print_header($course->shortname
, $course->fullname
, $navigation, '', '', true, "", navmenu($course, $cm));
43 notice_yesno(get_string('noguesttracking', 'forum').'<br /><br />'.get_string('liketologin'),
45 print_footer($course);
50 $info->name
= fullname($user);
51 $info->forum
= format_string($forum->name
);
53 if ($mark == 'read') {
55 if (! $discussion = get_record('forum_discussions', 'id', $d, 'forum', $forum->id
)) {
56 error("Discussion ID was incorrect");
59 if (forum_tp_mark_discussion_read($user, $d)) {
60 add_to_log($course->id
, "discussion", "mark read", "view.php?f=$forum->id", $d, $cm->id
);
63 if (forum_tp_mark_forum_read($user, $forum->id
)) {
64 add_to_log($course->id
, "forum", "mark read", "view.php?f=$forum->id", $forum->id
, $cm->id
);
68 /// FUTURE - Add ability to mark them as unread.
69 // } else { // subscribe
70 // if (forum_tp_start_tracking($forum->id, $user->id)) {
71 // add_to_log($course->id, "forum", "mark unread", "view.php?f=$forum->id", $forum->id, $cm->id);
72 // redirect($returnto, get_string("nowtracking", "forum", $info), 1);
74 // error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);