You are here

submenutree.install in Submenu Tree 6

Same filename and directory in other branches
  1. 5 submenutree.install
  2. 7.2 submenutree.install
  3. 7 submenutree.install

File

submenutree.install
View source
<?php

// Modeline for drupal
// vim: set expandtab tabstop=2 shiftwidth=2 autoindent smartindent filetype=php:

/**
 * Implementation of hook_schema().
 */
function submenutree_schema() {
  $schema['node_submenutree'] = array(
    'description' => t('The base table for submenutree'),
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'submenutree_enable' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'submenutree_title' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'submenutree_display' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'submenutree_weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'siblingmenutree_enable' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'siblingmenutree_title' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'siblingmenutree_display' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'siblingmenutree_weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function submenutree_install() {
  drupal_install_schema('submenutree');
}

/**
 * Implementation of hook_uninstall().
 */
function submenutree_uninstall() {
  drupal_uninstall_schema('submenutree');
}

/* This is an update from submenutree 5.x-0.x. Leave it here for now  */
function submenutree_update_5001() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {node_submenutree} ADD submenutree_enable int(10) unsigned NOT NULL default '0' AFTER nid");
      $ret[] = update_sql("ALTER TABLE {node_submenutree} ADD submenutree_title varchar(255) NOT NULL default '' AFTER submenutree_enable");
      $ret[] = update_sql("ALTER TABLE {node_submenutree} CHANGE display submenutree_display int(10) unsigned NOT NULL default '0'");
      $ret[] = update_sql("ALTER TABLE {node_submenutree} CHANGE weight submenutree_weight int(10) unsigned NOT NULL default '0'");
      $ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_enable int(10) unsigned NOT NULL default '0'");
      $ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_title varchar(255) NOT NULL default ''");
      $ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_display int(10) unsigned NOT NULL default '0'");
      $ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_weight int(10) unsigned NOT NULL default '0'");
      $ret[] = update_sql("UPDATE {node_submenutree} SET submenutree_enable = 1");
      break;
  }
  return $ret;
}

/**
 * Make columns submenutree_weight and siblingmenutree_weight signed integers.
 * See http://drupal.org/node/455690
 */
function submenutree_update_6001() {
  $fields = array(
    'submenutree_weight' => array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'disp-width' => '10',
    ),
    'siblingmenutree_weight' => array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'disp-width' => '10',
    ),
  );
  $ret = array();
  foreach ($fields as $field => $spec) {
    db_change_field($ret, 'node_submenutree', $field, $field, $spec);
  }
  return $ret;
}

Functions

Namesort descending Description
submenutree_install Implementation of hook_install().
submenutree_schema Implementation of hook_schema().
submenutree_uninstall Implementation of hook_uninstall().
submenutree_update_5001
submenutree_update_6001 Make columns submenutree_weight and siblingmenutree_weight signed integers. See http://drupal.org/node/455690