W3cubDocs

/Drupal 8

function node_mark

node_mark($nid, $timestamp)

Determines the type of marker to be displayed for a given node.

Parameters

int $nid: Node ID whose history supplies the "last viewed" timestamp.

int $timestamp: Time which is compared against node's "last viewed" timestamp.

Return value

int One of the MARK constants.

File

core/modules/node/node.module, line 215
The core module that allows content to be submitted to the site.

Code

function node_mark($nid, $timestamp) {

  $cache = &drupal_static(__FUNCTION__, array());

  if (\Drupal::currentUser()->isAnonymous() || !\Drupal::moduleHandler()->moduleExists('history')) {
    return MARK_READ;
  }
  if (!isset($cache[$nid])) {
    $cache[$nid] = history_read($nid);
  }
  if ($cache[$nid] == 0 && $timestamp > HISTORY_READ_LIMIT) {
    return MARK_NEW;
  }
  elseif ($timestamp > $cache[$nid] && $timestamp > HISTORY_READ_LIMIT) {
    return MARK_UPDATED;
  }
  return MARK_READ;
}

© 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/core!modules!node!node.module/function/node_mark/8.1.x