node_last_viewed

5 node.module node_last_viewed($nid)
6 node.module node_last_viewed($nid)
7 node.module node_last_viewed($nid)
8 node.module node_last_viewed($nid)

Retrieves the timestamp at which the current user last viewed the specified node.

2 calls to node_last_viewed()

File

modules/node/node.module, line 320
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function node_last_viewed($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);
}

Comments

a pair

this function can be used as test pair with:
node_tag_new($nid);

Login or register to post comments