node_last_viewed

Versions
4.6 – 7
node_last_viewed($nid)

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

▾ 2 functions call node_last_viewed()

comment_num_new in modules/comment/comment.module
Get number of new comments for current user and specified node.
node_mark in modules/node/node.module
Decide on the type of marker to be displayed for a given node.

Code

modules/node/node.module, line 299

<?php
function node_last_viewed($nid) {
  global $user;
  static $history;

  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);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.