You are here

function node_mark in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_mark()
  2. 4 modules/node.module \node_mark()
  3. 5 modules/node/node.module \node_mark()
  4. 6 modules/node/node.module \node_mark()
  5. 7 modules/node/node.module \node_mark()

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.

1 call to node_mark()
NodeListBuilder::buildRow in core/modules/node/src/NodeListBuilder.php
Builds a row for an entity in the entity listing.
2 string references to 'node_mark'
drupal_static_reset in core/includes/bootstrap.inc
Resets one or all centrally stored static variable(s).
NodeDeprecationTest::testNodeMarkDeprecation in core/modules/node/tests/src/Kernel/NodeDeprecationTest.php

File

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

Code

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