You are here

function _xmlsitemap_gsitemap_replace in XML sitemap 5

Replace Google Sitemap if it is installed.

1 call to _xmlsitemap_gsitemap_replace()
xmlsitemap_enable in ./xmlsitemap.install
Implementation of hook_enable().

File

./xmlsitemap.install, line 57

Code

function _xmlsitemap_gsitemap_replace() {
  if (db_result(db_query("\n    SELECT 1 FROM {system}\n    WHERE type = 'module' AND name = 'gsitemap' AND (status = 1 OR schema_version >= 0)\n  "))) {
    db_query("\n      INSERT INTO {xmlsitemap_additional} (path, pid, last_changed, previously_changed, priority)\n      SELECT path, pid, last_changed, previously_changed, priority FROM {gsitemap_additional}\n    ");
    $modules = array(
      'xmlsitemap_node',
      'xmlsitemap_engines',
    );
    if (variable_get('gsitemap_showterms', FALSE)) {
      $modules[] = 'xmlsitemap_term';
      variable_del('gsitemap_showterms');
    }
    if (variable_get('gsitemap_showusers', FALSE)) {
      $modules[] = 'xmlsitemap_user';
      variable_del('gsitemap_showusers');
    }
    drupal_install_modules($modules);
    $settings = db_query("SELECT * FROM {variable} WHERE name LIKE 'gsitemap\\_%'");
    while ($variable = db_fetch_object($settings)) {
      switch ($variable->name) {
        case 'gsitemap_frontpage':
          $name = 'xmlsitemap_front_page_priority';
          break;
        case 'gsitemap_priority':
          $name = 'xmlsitemap_additional_links_priority';
          break;
        case 'gsitemap_logacc':
          $name = 'xmlsitemap_log_access';
          break;
        default:
          $name = 'xmlsitemap' . strstr($variable->name, '_');
          break;
      }
      variable_set($name, (double) unserialize($variable->value));
    }
    module_disable(array(
      'gsitemap',
    ));
    drupal_uninstall_module('gsitemap');
  }
}