<?php
// $Id: xmlsitemap_taxonomy.install,v 1.4 2010/01/18 06:30:31 davereid Exp $

/**
 * @file
 * Install and uninstall schema and functions for the xmlsitemap_taxonomy module.
 */

/**
 * Implements hook_uninstall().
 */
function xmlsitemap_taxonomy_uninstall() {
  // Remove variables.
  drupal_load('module', 'xmlsitemap_taxonomy');
  $variables = array_keys(xmlsitemap_taxonomy_variables());
  foreach ($variables as $variable) {
    variable_del($variable);
  }
}

// @todo Remove these update functions before alpha.
function xmlsitemap_taxonomy_update_1() {
  $vids = array_keys(taxonomy_get_vocabularies());
  foreach ($vids as $vid) {
    if (variable_get('xmlsitemap_taxonomy_priority_' . $vid, 'default') === 'default') {
      variable_set('xmlsitemap_taxonomy_priority_' . $vid, 0.5);
    }
  }
}

/**
 * Change 'taxonomy' type to 'taxonomy_term'.
 */
function xmlsitemap_taxonomy_update_2() {
  $field = array(
    'type' => 'varchar',
    'length' => 32,
    'not null' => TRUE,
    'default' => '',
  );
  db_change_field('xmlsitemap', 'type', 'type', $field);
  db_update('xmlsitemap')
    ->fields(array('type' => 'taxonomy_term'))
    ->condition('type', 'taxonomy')
    ->execute();
}

// @todo Convert {xmlsitemap}.subtype from vid to vocabulary_machine_name.
