You are here

fieldset_helper.install in Fieldset helper 7.2

Same filename and directory in other branches
  1. 6.2 fieldset_helper.install
  2. 6 fieldset_helper.install

Installation information for the 'Fieldset helper' module.

File

fieldset_helper.install
View source
<?php

/**
 * @file
 * Installation information for the 'Fieldset helper' module.
 */

/**
 * Implements hook_install().
 */
function fieldset_helper_install() {

  // Define variables
  variable_set('fieldset_helper_node_form_state', 1);
  variable_set('fieldset_helper_default_collapsible_pages', '*');
  variable_set('fieldset_helper_default_collapsed_pages', 'admin/modules');
  variable_set('fieldset_helper_toggle_all_pages', 'admin/modules
admin/modules/list');
  variable_set('fieldset_helper_toggle_all_minimum', 2);
  variable_set('fieldset_helper_global_pages', '');
  variable_set('fieldset_helper_global_ids', '');
  variable_set('fieldset_helper_cookie_duration', 0);
  variable_set('fieldset_helper_disable_state_anonymous', 0);
}

/**
 * Implements hook_uninstall().
 */
function fieldset_helper_uninstall() {

  // Delete all the fieldset_helper variables and then clear the variable cache
  db_delete('variable')
    ->condition('name', 'fieldset_helper_%', 'LIKE')
    ->execute();
  cache_clear_all('variables', 'cache_bootstrap');
}

////////////////////////////////////////////////////////////////////////////////

// Updates

////////////////////////////////////////////////////////////////////////////////

/**
 * Remove 'fieldset_helper_auto_exclude' variable.
 */
function fieldset_helper_update_6200(&$sandbox) {

  // All fieldsets are now always assigned an ID,
  // so the auto exclude variable is no longer applicable.
  variable_del('fieldset_helper_auto_exclude');
  fieldset_helper_state_manager_clear_lookup_ids();
}

/**
 * Change fieldset helper path variables from 'admin/build/modules' to 'admin/modules'.
 */
function fieldset_helper_update_7200(&$sandbox) {
  $result = db_query("SELECT name, value FROM {variable} WHERE name LIKE 'fieldset_helper_%'");
  foreach ($result as $record) {
    if (strpos($record->value, 'admin/build/modules') !== FALSE) {
      variable_set($record->name, str_replace('admin/build/modules', 'admin/modules', $record->value));
    }
  }
}

////////////////////////////////////////////////////////////////////////////////

// Database schema

////////////////////////////////////////////////////////////////////////////////

/**
 * Implements hook_schema().
 */
function fieldset_helper_schema() {

  // Learn more at http://api.drupal.org/api/function/hook_schema
  return array(
    'fieldset_helper_state_manager' => array(
      'description' => 'Table to save a short numeric lookup id for a DOM element',
      'fields' => array(
        'id' => array(
          'description' => 'The unique id',
          'type' => 'serial',
          // auto increment
          'unsigned' => TRUE,
          'not null' => TRUE,
        ),
        'path' => array(
          'description' => "A drupal path",
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE,
        ),
        'element_id' => array(
          'description' => "The unique DOM element id.",
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE,
        ),
      ),
      'primary key' => array(
        'id',
      ),
      'indexes' => array(
        'path' => array(
          'path',
        ),
      ),
    ),
  );
}

Functions

Namesort descending Description
fieldset_helper_install Implements hook_install().
fieldset_helper_schema Implements hook_schema().
fieldset_helper_uninstall Implements hook_uninstall().
fieldset_helper_update_6200 Remove 'fieldset_helper_auto_exclude' variable.
fieldset_helper_update_7200 Change fieldset helper path variables from 'admin/build/modules' to 'admin/modules'.