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
))) {
27 require_course_login($course, false, $cm);
29 if (isguest()) { // Guests can't change forum
30 $wwwroot = $CFG->wwwroot
.'/login/index.php';
31 if (!empty($CFG->loginhttps
)) {
32 $wwwroot = str_replace('http','https', $wwwroot);
35 $strforums = get_string('modulenameplural', 'forum');
37 $navlinks[] = array('name' => $strforums, 'link' => "index.php?id=$course->id", 'type' => 'activity');
38 $navlinks[] = array('name' => format_string($forum->name
), 'link' => "view.php?f=$forum->id", 'type' => 'activityinstance');
40 $navigation = build_navigation($navlinks);
42 print_header($course->shortname
, $course->fullname
, $navigation, '', '', true, "", navmenu($course, $cm));
43 notice_yesno(get_string('noguesttracking', 'forum').'<br /><br />'.get_string('liketologin'),
44 $wwwroot, $_SERVER['HTTP_REFERER']);
45 print_footer($course);
49 if ($returnpage == 'index.php') {
50 $returnto = forum_go_back_to($returnpage.'?id='.$course->id
);
52 $returnto = forum_go_back_to($returnpage.'?f='.$forum->id
);
55 $info->name
= fullname($user);
56 $info->forum
= format_string($forum->name
);
58 if ($mark == 'read') {
60 if (forum_tp_mark_discussion_read($user->id
, $d, $forum->id
)) {
61 add_to_log($course->id
, "discussion", "mark read", "view.php?f=$forum->id", $d, $cm->id
);
64 if (forum_tp_mark_forum_read($user->id
, $forum->id
)) {
65 add_to_log($course->id
, "forum", "mark read", "view.php?f=$forum->id", $forum->id
, $cm->id
);
69 /// FUTURE - Add ability to mark them as unread.
70 // } else { // subscribe
71 // if (forum_tp_start_tracking($forum->id, $user->id)) {
72 // add_to_log($course->id, "forum", "mark unread", "view.php?f=$forum->id", $forum->id, $cm->id);
73 // redirect($returnto, get_string("nowtracking", "forum", $info), 1);
75 // error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);