Skip to content
Browse files

forums/trackreads: Small optimizations to forum_tp_can_track_forums()

  • Loading branch information...
1 parent 63b8c59 commit e1a3a68059737b19552af9ba04768a362e27ff0d martinlanghoff committed Sep 2, 2005
Showing with 8 additions and 3 deletions.
  1. +8 −3 mod/forum/lib.php
View
11 mod/forum/lib.php
@@ -3459,6 +3459,12 @@ function forum_tp_get_untracked_forums($userid, $courseid=false) {
function forum_tp_can_track_forums($forum=false, $user=false) {
global $USER, $CFG;
+ // if possible, avoid expensive
+ // queries
+ if (empty($CFG->forum_trackreadposts)) {
+ return false;
+ }
+
if ($user === false) {
/// Must be logged in and not a guest.
$isauser = isloggedin() && !isguest();
@@ -3473,15 +3479,14 @@ function forum_tp_can_track_forums($forum=false, $user=false) {
} else {
/// Work toward always passing an object...
if (is_numeric($forum)) {
- $forum = get_record('forum', 'id', $forum);
+ $forum = get_record('forum', 'id', $forum, '','','','', 'id,trackingtype');
}
$forumallows = ($forum->trackingtype == FORUM_TRACKING_OPTIONAL);
$forumforced = ($forum->trackingtype == FORUM_TRACKING_ON);
}
- return ($isauser && $CFG->forum_trackreadposts &&
- ($forumforced || ($forumallows && !empty($user->trackforums))));
+ return ($isauser && ($forumforced || ($forumallows && !empty($user->trackforums))));
}
/**

0 comments on commit e1a3a68

Please sign in to comment.
Something went wrong with that request. Please try again.