You are here

function _node_revision_delete_determine_time in Node Revision Delete 7.3

Determine the time value for the node type or nid and variable type.

Parameters

string $variable_type: The variable type.

string $node_type: The node type, can be null.

int $nid: The nid, can be null.

Return value

int The timestamp representing the when delete for the node type or nid.

2 calls to _node_revision_delete_determine_time()
_node_revision_delete_candidates in ./node_revision_delete.helpers.inc
Return the list of candidate nodes for node revision delete.
_node_revision_delete_do_delete in ./node_revision_delete.helpers.inc
Private function to perform revision deletion.

File

./node_revision_delete.helpers.inc, line 399
Helper functions.

Code

function _node_revision_delete_determine_time($variable_type, $node_type = NULL, $nid = NULL) {

  // Get the node type for the nid.
  if (empty($node_type) && !empty($nid)) {
    $node_type = db_select('node', 'n')
      ->fields('n', array(
      'type',
    ))
      ->condition('n.nid', $nid)
      ->execute()
      ->fetchField();
  }

  // Get the variable value for the node type (or default).
  $track = variable_get('node_revision_delete_track', array());
  $time = REQUEST_TIME;
  $time_interval = variable_get('node_revision_delete_' . $variable_type . '_time')['time'];
  if (count($track) && !empty($node_type) && isset($track[$node_type])) {
    $time = $track[$node_type][$variable_type];
  }
  $time = strtotime('-' . $time . ' ' . $time_interval);
  return $time;
}