You are here

function _xmlsitemap_check_changed_link in XML sitemap 6.2

Same name and namespace in other branches
  1. 7.2 xmlsitemap.module \_xmlsitemap_check_changed_link()

Check if there is sitemap link is changed from the existing data.

Parameters

$link: An array of the sitemap link.

$original_link: An optional array of the existing data. This should only contain the fields necessary for comparison. If not provided the existing data will be loaded from the database.

$flag: An optional boolean that if TRUE, will set the regenerate needed flag if there is a match. Defaults to FALSE.

Return value

TRUE if the link is changed, or FALSE otherwise.

Related topics

1 call to _xmlsitemap_check_changed_link()
xmlsitemap_link_save in ./xmlsitemap.module
Saves or updates a sitemap link.

File

./xmlsitemap.module, line 738
Main file for the xmlsitemap module.

Code

function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $flag = FALSE) {
  $changed = FALSE;
  if ($original_link === NULL) {

    // Load only the fields necessary for data to be changed in the sitemap.
    $original_link = db_fetch_array(db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount, language FROM {xmlsitemap} WHERE type = '%s' AND id = %d", $link['type'], $link['id'], 0, 1));
  }
  if (!$original_link) {
    if ($link['access'] && $link['status']) {

      // Adding a new visible link.
      $changed = TRUE;
    }
  }
  else {
    if (!($original_link['access'] && $original_link['status']) && $link['access'] && $link['status']) {

      // Changing a non-visible link to a visible link.
      $changed = TRUE;
    }
    elseif ($original_link['access'] && $original_link['status'] && array_diff_assoc($original_link, $link)) {

      // Changing a visible link
      $changed = TRUE;
    }
  }
  if ($changed && $flag) {
    variable_set('xmlsitemap_regenerate_needed', TRUE);
  }
  return $changed;
}