function _forum_user_last_visit

_forum_user_last_visit($nid)

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.

File

modules/forum/forum.module, line 1288
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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!forum!forum.module/function/_forum_user_last_visit/7.x