[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/xmlsitemap/xmlsitemap_taxonomy/ -> xmlsitemap_taxonomy.install (source)

   1  <?php
   2  // $Id: xmlsitemap_taxonomy.install,v 1.1.4.16 2010/04/30 03:31:19 davereid Exp $
   3  
   4  /**
   5   * @file
   6   * Install and uninstall schema and functions for the xmlsitemap_taxonomy module.
   7   */
   8  
   9  /**
  10   * Implements hook_uninstall().
  11   */
  12  function xmlsitemap_taxonomy_uninstall() {
  13    drupal_load('module', 'taxonomy');
  14    drupal_load('module', 'xmlsitemap');
  15    $vids = array_keys(taxonomy_get_vocabularies());
  16    foreach ($vids as $vid) {
  17      xmlsitemap_link_bundle_delete('taxonomy_term', $vid);
  18    }
  19  }
  20  
  21  /**
  22   * Migrate 6.x-1.x taxonomy variables.
  23   */
  24  function xmlsitemap_taxonomy_update_6196() {
  25    drupal_load('module', 'taxonomy');
  26    $vids = array_keys(taxonomy_get_vocabularies());
  27    foreach ($vids as $vid) {
  28      $status = 0;
  29      $priority = variable_get('xmlsitemap_taxonomy_vocabulary_priority_' . $vid, 0.5);
  30      if ($priority == -1) {
  31        $priority = 0.5;
  32      }
  33      else {
  34        $status = 1;
  35      }
  36      variable_set('xmlsitemap_taxonomy_status_' . $vid, $status);
  37      variable_set('xmlsitemap_taxonomy_priority_' . $vid, $priority);
  38    }
  39    return array();
  40  }
  41  
  42  /**
  43   * Migrate 6.x-1.x taxonomy data.
  44   */
  45  function xmlsitemap_taxonomy_update_6198(&$context) {
  46    $ret = array();
  47  
  48    if (!db_table_exists('xmlsitemap_taxonomy')) {
  49      // Skip if the 6.x-1.x table doesn't exist.
  50      return $ret;
  51    }
  52    elseif (db_column_exists('xmlsitemap', 'sid')) {
  53      // Skip if the main {xmlsitemap} table hasn't been upgraded yet.
  54      $ret['#abort'] = array('success' => FALSE, 'query' => 'The primary xmlsitemap table upgrade has not yet been completed. Re-run the upgrade script.');
  55      return $ret;
  56    }
  57  
  58    if (!isset($context['progress'])) {
  59      $context['progress'] = $context['last'] = 0;
  60      $context['count'] = db_result(db_query("SELECT COUNT(tid) FROM {xmlsitemap_taxonomy} WHERE priority_override <> -2 AND tid > %d", $context['last']));
  61    }
  62  
  63    drupal_load('module', 'xmlsitemap_taxonomy');
  64    drupal_load('module', 'xmlsitemap');
  65  
  66    $query = db_query_range("SELECT tid, priority_override FROM {xmlsitemap_taxonomy} WHERE priority_override <> -2 AND tid > %d ORDER BY tid", $context['last'], 0, 10);
  67    while ($record = db_fetch_object($query)) {
  68      if ($term = taxonomy_get_term($record->tid)) {
  69        $link = xmlsitemap_taxonomy_create_link($term);
  70        $link['status'] = variable_get('xmlsitemap_taxonomy_status_' . $term->vid, 0);
  71        $link['priority'] = variable_get('xmlsitemap_taxonomy_priority_' . $term->vid, 0.5);
  72        if ($record->priority_override == -1) {
  73          $link['status'] = 0;
  74          $link['status_override'] = 1;
  75        }
  76        elseif ($record->priority_override != -2) {
  77          $link['priority'] = $record->priority_override;
  78          $link['priority_override'] = 1;
  79        }
  80        xmlsitemap_link_save($link);
  81      }
  82      $context['last'] = $record->tid;
  83      $context['progress']++;
  84    }
  85  
  86    $ret['#finished'] = empty($context['count']) ? 1 : ($context['progress'] / $context['count']);
  87    return $ret;
  88  }
  89  
  90  /**
  91   * Cleanup variables.
  92   */
  93  function xmlsitemap_taxonomy_update_6200() {
  94    drupal_load('module', 'taxonomy');
  95    drupal_load('module', 'xmlsitemap');
  96    $vids = array_keys(taxonomy_get_vocabularies());
  97    foreach ($vids as $vid) {
  98      $settings = array(
  99        'status' => variable_get('xmlsitemap_taxonomy_status_' . $vid, XMLSITEMAP_STATUS_DEFAULT),
 100        'priority' => variable_get('xmlsitemap_taxonomy_priority_' . $vid, XMLSITEMAP_PRIORITY_DEFAULT),
 101      );
 102      variable_set('xmlsitemap_settings_taxonomy_term_' . $vid, $settings);
 103      variable_del('xmlsitemap_taxonomy_status_' . $vid);
 104      variable_del('xmlsitemap_taxonomy_priority_' . $vid);
 105      variable_del('xmlsitemap_taxonomy_calculate_priority_' . $vid);
 106      variable_del('xmlsitemap_taxonomy_include_empty_terms_' . $vid);
 107    }
 108    variable_del('xmlsitemap_taxonomy_include_empty_terms');
 109    variable_del('xmlsitemap_taxonomy_calculate_priority');
 110    return array();
 111  }
 112  
 113  /**
 114   * Cleanup any remaining 6.x-1.x tables, variables or weights.
 115   */
 116  function xmlsitemap_taxonomy_update_6201() {
 117    $ret = array();
 118    if (db_table_exists('xmlsitemap_taxonomy')) {
 119      db_drop_table($ret, 'xmlsitemap_taxonomy');
 120    }
 121    if (db_table_exists('xmlsitemap_term')) {
 122      db_drop_table($ret, 'xmlsitemap_term');
 123    }
 124    db_query("DELETE FROM {variable} WHERE name LIKE 'xmlsitemap_taxonomy_vocabulary_priority_%%'");
 125    cache_clear_all('variables', 'cache');
 126    $ret[] = update_sql("UPDATE {system} SET weight = 0 WHERE type = 'module' AND name = 'xmlsitemap_taxonomy'");
 127    return $ret;
 128  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7