diff options
Diffstat (limited to 'modules/node.module')
-rw-r--r-- | modules/node.module | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/node.module b/modules/node.module index af41ab7a2..4044d64cd 100644 --- a/modules/node.module +++ b/modules/node.module @@ -104,8 +104,7 @@ function node_tag_new($nid) { global $user; if ($user->uid) { - $result = db_query('SELECT timestamp FROM {history} WHERE uid = %d AND nid = %d', $user->uid, $nid); - if (db_fetch_object($result)) { + if (node_last_viewed($nid)) { db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', time(), $user->uid, $nid); } else { @@ -120,9 +119,13 @@ function node_tag_new($nid) { */ function node_last_viewed($nid) { global $user; + static $history; - $history = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = '$user->uid' AND nid = %d", $nid)); - return ($history->timestamp ? $history->timestamp : NODE_NEW_LIMIT); + if (!isset($history[$nid])) { + $history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = '$user->uid' AND nid = %d", $nid)); + } + + return ($history[$nid]->timestamp ? $history[$nid]->timestamp : 0); } /** @@ -140,8 +143,7 @@ function node_is_new($nid, $timestamp) { if (!isset($cache[$nid])) { if ($user->uid) { - $history = db_fetch_object(db_query('SELECT timestamp FROM {history} WHERE uid = %d AND nid = %d', $user->uid, $nid)); - $cache[$nid] = $history->timestamp ? $history->timestamp : 0; + $cache[$nid] = node_last_viewed($nid); } else { $cache[$nid] = time(); |