<?php

/*
 * @file
 * Installer
 */

require_once('location_taxonomize.inc');

/**
 * Implements hook_install().
 */
function location_taxonomize_install() {
  // set all variables to their default values
  _location_taxonomize_set_defaults();
  drupal_set_message(st("Location taxonomize has been installed, but it doesn't do anything right away. To start using it, you have to go to the configuration page and initialize your Location Vocabulary. You also have to install one of the available source modules."));
}

/**
 * Implements hook_enable().
 */
function location_taxonomize_enable() {
  // nothing to do here for now, everything is done during initialization
}

/**
 * Implements hook_requirements().
 */
function location_taxonomize_requirements($phase) {
  $requirements = array();
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function location_taxonomize_uninstall() {
  // delete all variables set by this module
  _location_taxonomize_del_variables();
}

/**
 * Reinitialize variables for the 2.x branch
 */
function location_taxonomize_update_7200() {
  $settings = variable_get('location_taxonomize_vocab');
  if (!isset($settings['hierarchy'])) {
    // remove all previously set variables
    variable_del('location_taxonomize_vid');
    variable_del('location_taxonomize_vocab');
    variable_del('location_taxonomize_settings');
    // reinitialize variables
    _location_taxonomize_set_defaults();
  }
}

/**
 * Implements hook_update_n().
 */
function location_taxonomize_update_7201() {
  // add the 'longname main' settings variable
  $settings = variable_get('location_taxonomize_settings');
  if (!isset($settings['longname']['main'])) {
    // remove all previously set variables
    $settings['longname']['main'] = 0;
    variable_set('location_taxonomize_settings', $settings);
  }
}

