<?php

/**
 * @file
 * Install, update and uninstall functions for the xmlsitemap_engines module.
 */

/**
 * Implements hook_install().
 */
function xmlsitemap_engines_install() {
  // Set this module's weight to 1 so xmlsitemap_engines_cron() runs after
  // the sitemap has been generated in xmlsitemap_cron().
  db_update('system')
    ->fields(array('weight' => 2))
    ->condition('type', 'module')
    ->condition('name', 'xmlsitemap_engines')
    ->execute();
}

/**
 * Implements hook_uninstall().
 */
function xmlsitemap_engines_uninstall() {
  variable_del('xmlsitemap_engines_engines');
  variable_del('xmlsitemap_engines_custom_urls');
  variable_del('xmlsitemap_engines_minimum_lifetime');
  variable_del('xmlsitemap_engines_submit_last');
  variable_del('xmlsitemap_engines_submit_updated');
}

/**
 * Deprecate support for Ask.com, Moreover, and Yahoo! search engines.
 */
function xmlsitemap_engines_update_6202() {
  $engines = variable_get('xmlsitemap_engines_engines', array());
  $removed = array(
    'ask' => 'Ask.com',
    'moreover' => 'Moreover',
    'yahoo' => 'Yahoo.com',
  );
  $engines = array_diff($engines, array_keys($removed));
  variable_set('xmlsitemap_engines_engines', $engines);
  return t('The following search engines have deprecated their XML sitemap ping services and have been disabled: !list.', array('!list' => implode(', ', $removed)));
}
