3 // Set tracking option for the forum.
5 require_once("../../config.php");
6 require_once("lib.php");
8 $id = required_param('id',PARAM_INT
); // The forum to subscribe or unsubscribe to
9 $returnpage = optional_param('returnpage', 'index.php', PARAM_FILE
); // Page to return to.
11 if (! $forum = get_record("forum", "id", $id)) {
12 error("Forum ID was incorrect");
15 if (! $course = get_record("course", "id", $forum->course
)) {
16 error("Forum doesn't belong to a course!");
19 if (!($cm = get_coursemodule_from_instance("forum", $forum->id
, $course->id
))) {
25 require_course_login($course, false, $cm);
27 if (isguest()) { // Guests can't change tracking
28 $wwwroot = $CFG->wwwroot
.'/login/index.php';
29 if (!empty($CFG->loginhttps
)) {
30 $wwwroot = str_replace('http','https', $wwwroot);
33 $strforums = get_string('modulenameplural', 'forum');
35 $navlinks[] = array('name' => $strforums, 'link' => "index.php?id=$course->id", 'type' => 'activity');
36 $navlinks[] = array('name' => format_string($forum->name
), 'link' => "view.php?f=$forum->id", 'type' => 'activityinstance');
38 $navigation = build_navigation($navlinks);
40 print_header($course->shortname
, $course->fullname
, $navigation, '', '', true, "", navmenu($course, $cm));
41 notice_yesno(get_string('noguesttracking', 'forum').'<br /><br />'.get_string('liketologin'),
42 $wwwroot, $_SERVER['HTTP_REFERER']);
43 print_footer($course);
47 $returnto = forum_go_back_to($returnpage.'?id='.$course->id
.'&f='.$forum->id
);
49 $info->name
= fullname($user);
50 $info->forum
= format_string($forum->name
);
52 if ( forum_tp_is_tracked($forum->id
, $user->id
) ) {
53 if (forum_tp_stop_tracking($forum->id
, $user->id
)) {
54 add_to_log($course->id
, "forum", "stop tracking", "view.php?f=$forum->id", $forum->id
, $cm->id
);
55 redirect($returnto, get_string("nownottracking", "forum", $info), 1);
57 error("Could not stop tracking that forum", $_SERVER["HTTP_REFERER"]);
61 if (forum_tp_start_tracking($forum->id
, $user->id
)) {
62 add_to_log($course->id
, "forum", "start tracking", "view.php?f=$forum->id", $forum->id
, $cm->id
);
63 redirect($returnto, get_string("nowtracking", "forum", $info), 1);
65 error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);