function history_read

Retrieves the timestamp for the current user's last view of a specified node.

Parameters

int $nid: A node ID.

Return value

int If a node has been previously viewed by the user, the timestamp in seconds of when the last view occurred; otherwise, zero.

2 calls to history_read()
comment_num_new in drupal/core/modules/comment/comment.module
Gets the number of new comments for the current user and the specified node.
node_mark in drupal/core/modules/node/node.module
Decides on the type of marker to be displayed for a given node.

File

drupal/core/modules/history/history.module, line 32
Records which users have read which content.

Code

function history_read($nid) {
  global $user;
  $history =& drupal_static(__FUNCTION__, array());
  if (!isset($history[$nid])) {
    $history[$nid] = db_query("SELECT timestamp FROM {history} WHERE uid = :uid AND nid = :nid", array(
      ':uid' => $user->uid,
      ':nid' => $nid,
    ))
      ->fetchObject();
  }
  return isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0;
}