| 1 |
<?php
|
| 2 |
// $Id: taxonomy_filter.install,v 1.3 2009/05/17 04:22:46 solotandem Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* The installation file for the Taxonomy Filter module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*/
|
| 12 |
function taxonomy_filter_install() {
|
| 13 |
// unnecessary - hook_enable is run by module installs
|
| 14 |
//taxonomy_filter_update_mappings();
|
| 15 |
}
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Implementation of hook_uninstall().
|
| 19 |
*/
|
| 20 |
function taxonomy_filter_uninstall() {
|
| 21 |
variable_del('taxonomy_filter_general');
|
| 22 |
variable_del('taxonomy_filter_input');
|
| 23 |
variable_del('taxonomy_filter_input_parsed');
|
| 24 |
variable_del('taxonomy_filter_output');
|
| 25 |
//variable_del('taxonomy_filter_cache');
|
| 26 |
variable_del('taxonomy_filter_mappings');
|
| 27 |
variable_del('taxonomy_filter_menus');
|
| 28 |
// Leave in case module is uninstalled without running update_6003.
|
| 29 |
variable_del('taxonomy_filter_next_id');
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Convert settings from Drupal 5 to Drupal 6.
|
| 34 |
*
|
| 35 |
* TODO What are the changes?
|
| 36 |
*/
|
| 37 |
/*
|
| 38 |
function taxonomy_filter_update_6000() {
|
| 39 |
// convert variables to new format
|
| 40 |
|
| 41 |
return array();
|
| 42 |
}
|
| 43 |
*/
|
| 44 |
|
| 45 |
/**
|
| 46 |
* Add default settings.
|
| 47 |
*/
|
| 48 |
function taxonomy_filter_update_6001() {
|
| 49 |
// Collect default settings.
|
| 50 |
$settings = array();
|
| 51 |
$modules = module_implements('tf_default_settings');
|
| 52 |
foreach ($modules as $module) {
|
| 53 |
$settings[$module] = module_invoke($module, 'tf_default_settings');
|
| 54 |
}
|
| 55 |
|
| 56 |
// Update settings for each menu.
|
| 57 |
$menus = variable_get('taxonomy_filter_menus', array());
|
| 58 |
foreach ($menus as $id => $menu) {
|
| 59 |
$menus[$id] += array(
|
| 60 |
'depth' => '0',
|
| 61 |
);
|
| 62 |
foreach ($modules as $module) {
|
| 63 |
$menus[$id][$module] = $settings[$module];
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
| 67 |
// Save settings.
|
| 68 |
variable_set('taxonomy_filter_menus', $menus);
|
| 69 |
|
| 70 |
return array();
|
| 71 |
}
|
| 72 |
|
| 73 |
/**
|
| 74 |
* Update vocabulary mappings.
|
| 75 |
*/
|
| 76 |
function taxonomy_filter_update_6002() {
|
| 77 |
// Retrieve current mappings.
|
| 78 |
$old_mappings = variable_get('taxonomy_filter_mappings', array());
|
| 79 |
$new_mappings = array();
|
| 80 |
|
| 81 |
// Update mappings for each vocabulary.
|
| 82 |
$vocabs = _taxonomy_filter_get_vocabs();
|
| 83 |
foreach ($vocabs as $vid => $name) {
|
| 84 |
// Recreate array in case vocab weights have changed.
|
| 85 |
if (array_key_exists($vid, $old_mappings)) {
|
| 86 |
$new_mappings[$vid] = array(
|
| 87 |
'vocab' => $name, // In case the vocab name has changed. TODO This probably could be omitted.
|
| 88 |
'refine_menu' => $old_mappings[$vid]['menu'],
|
| 89 |
'current_menu' => 0,
|
| 90 |
'mappings' => $old_mappings[$vid]['mappings'],
|
| 91 |
);
|
| 92 |
}
|
| 93 |
else {
|
| 94 |
$new_mappings[$vid] = array(
|
| 95 |
'vocab' => $name,
|
| 96 |
'refine_menu' => 0,
|
| 97 |
'current_menu' => 0,
|
| 98 |
'mappings' => array(),
|
| 99 |
);
|
| 100 |
}
|
| 101 |
}
|
| 102 |
|
| 103 |
// Save updated mappings.
|
| 104 |
variable_set('taxonomy_filter_mappings', $new_mappings);
|
| 105 |
|
| 106 |
return array();
|
| 107 |
}
|
| 108 |
|
| 109 |
/**
|
| 110 |
* Eliminate the next_id variable.
|
| 111 |
*/
|
| 112 |
function taxonomy_filter_update_6003() {
|
| 113 |
// Delete the variable.
|
| 114 |
variable_del('taxonomy_filter_next_id');
|
| 115 |
|
| 116 |
return array();
|
| 117 |
}
|