You are here

accordions.install in Accordions 7

File

accordions.install
View source
<?php

/**
 * Implements hook_schema().
 */
function accordions_schema() {
  $schema = array();
  $schema['accordions'] = array(
    'description' => 'Details of accordions',
    'fields' => array(
      'type' => array(
        // e.g. 'entity' / 'block' / 'field' / 'field:delta'
        'description' => 'Type of accordion group.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'subtype' => array(
        // e.g. 'node' / 'module' / 'node:nid' / 'node:nid:field_name'
        'description' => 'Subtype of accordion group.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      ),
      'id' => array(
        // e.g. 'nid' / 'delta' / 'field_name' / 'delta'
        'description' => 'ID of accordion group within type/subtype.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'name' => array(
        // e.g. 'sidebar-blocks' (or anything else)
        'description' => 'Name of accordion group.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'initial' => array(
        'description' => 'Binary flag to indicate whether the item should initially be expanded or not.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'type',
      'subtype',
      'id',
    ),
    'indexes' => array(
      'ti' => array(
        'type',
        'id',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function accordions_install() {
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'configure accordion items',
  ));
}

/**
 * Implements hook_enable().
 */
function accordions_enable() {
  drupal_set_message(t('<a href="!link">Configure the allowed types of accordions</a> and then edit/configure some content of those types to make them into accordions.', array(
    '!link' => url('admin/config/user-interface/accordions'),
  )), 'warning');
}

/**
 * Implements hook_uninstall().
 */
function accordions_uninstall() {
  variable_del('accordions_enabled_types');
}

Functions