You are here

function _forum_user_last_visit in Drupal 7

Same name and namespace in other branches
  1. 4 modules/forum.module \_forum_user_last_visit()
  2. 5 modules/forum/forum.module \_forum_user_last_visit()
  3. 6 modules/forum/forum.module \_forum_user_last_visit()

Gets the last time the user viewed a node.

Parameters

$nid: The node ID.

Return value

The timestamp when the user last viewed this node, if the user has previously viewed the node; otherwise NODE_NEW_LIMIT.

1 call to _forum_user_last_visit()
forum_get_topics in modules/forum/forum.module
Gets all the topics in a forum.

File

modules/forum/forum.module, line 1289
Provides discussion forums.

Code

function _forum_user_last_visit($nid) {
  global $user;
  $history =& drupal_static(__FUNCTION__, array());
  if (empty($history)) {
    $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = :uid', array(
      ':uid' => $user->uid,
    ));
    foreach ($result as $t) {
      $history[$t->nid] = $t->timestamp > NODE_NEW_LIMIT ? $t->timestamp : NODE_NEW_LIMIT;
    }
  }
  return isset($history[$nid]) ? $history[$nid] : NODE_NEW_LIMIT;
}