You are here

function xmlsitemap_node_get_timestamps in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_get_timestamps()

Fetch all the timestamps for when a node was changed.

Parameters

object $node: A node object.

Return value

array An array of UNIX timestamp integers.

1 call to xmlsitemap_node_get_timestamps()
xmlsitemap_node_create_link in xmlsitemap_node/xmlsitemap_node.module
Create a sitemap link from a node.

File

xmlsitemap_node/xmlsitemap_node.module, line 197
Default file for XML sitemap node.

Code

function xmlsitemap_node_get_timestamps(stdClass $node) {
  $timestamps =& drupal_static(__FUNCTION__, array());
  if (!isset($timestamps[$node->nid])) {
    $timestamps[$node->nid] = db_query("SELECT nr.timestamp FROM {node_revision} nr WHERE nr.nid = :nid", array(
      ':nid' => $node->nid,
    ))
      ->fetchCol();
    if (module_exists('comment')) {
      $comment_timestamps = db_query("SELECT c.created FROM {comment} c WHERE c.nid = :nid AND c.status = :status", array(
        ':nid' => $node->nid,
        ':status' => COMMENT_PUBLISHED,
      ))
        ->fetchCol();
      $timestamps[$node->nid] = array_merge($timestamps[$node->nid], $comment_timestamps);
    }
  }
  return $timestamps[$node->nid];
}