diff --git a/mod/forum/index.php b/mod/forum/index.php
index 58de2b4a12c..4533aa0f116 100644
--- a/mod/forum/index.php
+++ b/mod/forum/index.php
@@ -45,7 +45,7 @@
$generaltable->head[] = $strunreadposts;
$generaltable->align[] = 'center';
- if (forum_tp_is_tracked()) {
+ if (forum_tp_can_track_forums($USER->id)) {
$untracked = forum_tp_get_untracked_forums($USER->id);
}
$generaltable->head[] = $strtracking;
@@ -140,8 +140,8 @@
if ($unread > 0) {
$unreadlink = ''.$unread.'';
$unreadlink .= ' ' .
- 'mark read';
+ ''.get_string('markread', 'forum').'';
} else {
$unreadlink = ''.$unread.'';
}
@@ -273,14 +273,14 @@
}
if ($CFG->forum_trackreadposts) {
- if (forum_tp_is_tracked() && !isset($untracked[$forum->id])) {
+ if (forum_tp_can_track_forums($USER->id) && !isset($untracked[$forum->id])) {
$groupid = ($groupmode==SEPARATEGROUPS && !isteacheredit($course->id)) ? $currentgroup : false;
$unread = forum_tp_count_forum_unread_posts($USER->id, $forum->id, $groupid);
if ($unread > 0) {
$unreadlink = ''.$unread.'';
$unreadlink .= ' ' .
- 'mark read';
+ ''.get_string('markread', 'forum').'';
} else {
$unreadlink = ''.$unread.'';
}
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 7887c9c5eb3..9151750f84a 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -1535,7 +1535,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
$strmarkunread = get_string('markunread', 'forum');
}
- if ($CFG->forum_trackreadposts && forum_tp_is_tracked($post->forum, $USER->id)) {
+ if (forum_tp_can_track_forums($USER->id) && forum_tp_is_tracked($post->forum, $USER->id)) {
if ($post_read == -99) { // If we don't know yet...
/// The front page can display a news item post to non-logged in users. This should
/// always appear as 'read'.
@@ -2588,7 +2588,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis
$strdatestring = get_string('strftimerecentfull');
/// Check if the forum is tracked.
- if ($CFG->forum_trackreadposts) {
+ if (forum_tp_can_track_forums($USER->id)) {
$forumtracked = forum_tp_is_tracked($forum->id, $USER->id);
} else {
$forumtracked = false;
@@ -2740,7 +2740,7 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode, $can
$post->subject = format_string($post->subject);
$forumtracked = forum_tp_is_tracked($forum->id, $USER->id);
- if ($CFG->forum_trackreadposts && $forumtracked) {
+ if (forum_tp_can_track_forums($USER->id) && $forumtracked) {
$user_read_array = forum_tp_get_discussion_read_records($USER->id, $post->discussion);
} else {
$user_read_array = array();
@@ -3314,8 +3314,14 @@ function forum_tp_get_untracked_forums($userid) {
return get_records('forum_track_prefs', 'userid', $userid, '', 'forumid,userid');
}
-/// Tells whether a specific forum is tracked, or if no forum specified, whether
-/// it is configured to allow tracking.
+/// Tells whether a user can track forums based on config variables.
+function forum_tp_can_track_forums($courseid=false, $forumid=false) {
+ global $USER, $CFG;
+
+ return ($CFG->forum_trackreadposts && $USER->trackforums);
+}
+
+/// Tells whether a specific forum is tracked.
function forum_tp_is_tracked($forumid=0, $userid=false) {
global $USER, $CFG;
@@ -3323,13 +3329,7 @@ function forum_tp_is_tracked($forumid=0, $userid=false) {
$userid = $USER->id;
}
- if (!$CFG->forum_trackreadposts || !$USER->trackforums) {
- return false;
- } else if (empty($forumid)) {
- return true;
- } else {
- return (get_record('forum_track_prefs', 'userid', $userid, 'forumid', $forumid) === false);
- }
+ return (get_record('forum_track_prefs', 'userid', $userid, 'forumid', $forumid) === false);
}
function forum_tp_start_tracking($forumid, $userid=false) {
diff --git a/mod/forum/markposts.php b/mod/forum/markposts.php
index ceab792925e..11a71be0e03 100644
--- a/mod/forum/markposts.php
+++ b/mod/forum/markposts.php
@@ -60,6 +60,7 @@
error("Could not mark that forum read.", $_SERVER["HTTP_REFERER"]);
}
+/// FUTURE - Add ability to mark them as unread.
// } 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);
diff --git a/mod/forum/settracking.php b/mod/forum/settracking.php
index b3acce28a57..1f774e08b08 100644
--- a/mod/forum/settracking.php
+++ b/mod/forum/settracking.php
@@ -5,7 +5,8 @@
require_once("../../config.php");
require_once("lib.php");
- require_variable($id); // The forum to subscribe or unsubscribe to
+ require_variable($id); // The forum to subscribe or unsubscribe to
+ optional_variable($returnpage, 'index.php'); // Page to return to.
if (! $forum = get_record("forum", "id", $id)) {
error("Forum ID was incorrect");
@@ -46,7 +47,7 @@
exit;
}
- $returnto = forum_go_back_to("index.php?id=$course->id");
+ $returnto = forum_go_back_to($returnpage.'?id='.$course->id.'&f='.$forum->id);
$info->name = fullname($user);
$info->forum = format_string($forum->name);
diff --git a/mod/forum/view.php b/mod/forum/view.php
index 088ce800682..b2b861ff7df 100644
--- a/mod/forum/view.php
+++ b/mod/forum/view.php
@@ -153,6 +153,20 @@
echo "id\">$subtext";
}
+ if (forum_tp_can_track_forums($USER->id)) {
+ if (forum_tp_is_tracked($forum->id, $USER->id)) {
+ $trtitle = get_string('notrackforum', 'forum');
+ $trackedlink = ''.get_string('notrackforum', 'forum').'';
+ } else {
+ $trtitle = get_string('trackforum', 'forum');
+ $trackedlink = ''.get_string('trackforum', 'forum').'';
+ }
+ echo "
";
+ echo "$trackedlink";
+ }
+
echo '';
}