Retrieves the timestamp for the current user's last view of a specified node.
int $nid: A node ID.
int If a node has been previously viewed by the user, the timestamp in seconds of when the last view occurred; otherwise, zero.
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;
}