You are here

taxonomy_menu.install in Taxonomy menu 6.2

Install and uninstall all required databases. Incremental database updates.

File

taxonomy_menu.install
View source
<?php

/**
 * @file
 * Install and uninstall all required databases. Incremental database updates.
 */

/**
 * Implementation of hook_uninstall().
 */
function taxonomy_menu_uninstall() {

  // remove menu items
  db_query("DELETE FROM {menu_links} WHERE module = '%s'", 'taxonomy_menu');

  // rebuild the menus
  variable_set('menu_rebuild_needed', TRUE);

  // Delete variables
  $variables = db_query('SELECT * from {variable}');
  while ($variable = db_fetch_object($variables)) {
    if (strpos($variable->name, 'taxonomy_menu') !== FALSE) {
      variable_del($variable->name);
    }
  }

  // remove table
  drupal_uninstall_schema('taxonomy_menu');
}

/**
 * Implementation of hook_install().
 */
function taxonomy_menu_install() {
  drupal_install_schema('taxonomy_menu');
}

/**
 * Implementation of hook_schema().
 */
function taxonomy_menu_schema() {
  $schema['taxonomy_menu'] = array(
    'description' => 'Links a taxonomy term to a menu item.',
    'fields' => array(
      'mlid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The taxonomy terms {menu_link}.mlid.',
      ),
      'tid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Tid that is linked to the mlid.',
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Vid for the tid.',
      ),
    ),
    'primary key' => array(
      'mlid',
      'tid',
    ),
    'indexes' => array(
      'vid' => array(
        'vid',
      ),
    ),
  );
  return $schema;
}
function taxonomy_menu_update_6200() {
  $schema['taxonomy_menu'] = array(
    'description' => 'Links a taxonomy term to a menu item.',
    'fields' => array(
      'mlid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The taxonomy terms {menu_link}.mlid.',
      ),
      'tid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Tid that is linked to the mlid.',
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Vid for the tid.',
      ),
    ),
    'primary key' => array(
      'mlid',
      'tid',
    ),
    'indexes' => array(
      'vid' => array(
        'vid',
      ),
    ),
  );
  $ret = array();
  db_create_table($ret, 'taxonomy_menu', $schema['taxonomy_menu']);
  return $ret;
}

Functions