function history_write

Updates 'last viewed' timestamp of the specified entity for the current user.

Parameters

$nid: The node ID that has been read.

$account: (optional) The user account to update the history for. Defaults to the current user.

1 call to history_write()
node_show in drupal/core/modules/node/node.module
Page callback: Generates an array which displays a node detail page.

File

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

Code

function history_write($nid, $account = NULL) {
  global $user;
  if (!isset($account)) {
    $account = $user;
  }
  if ($account->uid) {
    db_merge('history')
      ->key(array(
      'uid' => $account->uid,
      'nid' => $nid,
    ))
      ->fields(array(
      'timestamp' => REQUEST_TIME,
    ))
      ->execute();
  }
}