You are here

command_buttons.install in Command Buttons 7

File

command_buttons.install
View source
<?php

/**
 * Implements hook_schema().
 */
function command_buttons_schema() {
  $schema = array();
  $schema['command_buttons'] = array(
    'description' => 'Entity table for panel pane content with fields.',
    'fields' => array(
      'bid' => array(
        'description' => 'The primary identifier for the entity.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'bundle' => array(
        'description' => 'The bundle of the entity.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The machine name of the entity.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'module' => array(
        'description' => 'The module name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'The title of the entity.',
        'type' => 'varchar',
        'length' => 255,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the entity was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the entity was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'description' => 'The {languages}.language of this entity.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'description' => 'The entity status.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'bid',
    ),
  );
  return $schema;
}

/**
 * Create buttons for all node types.
 */
function command_buttons_update_7002() {

  // Commented out because of typo.  See update 7108
  //  $node_info = entity_get_info('node');
  //  foreach ($node_info['bundles'] as $type => $defintiion) {
  //    command_buttons_create_node_button($type, $definition['label']);
  //  }
}

/**
 * Update comman button field values.
 */
function command_buttons_update_7104() {
  foreach (array(
    'lg' => 'large',
    'sm' => 'small',
    'xs' => 'mini',
  ) as $new => $old) {
    db_update('field_data_field_button_size')
      ->fields(array(
      'field_button_size_value' => 'btn-' . $new,
    ))
      ->condition('field_button_size_value', 'btn-' . $old)
      ->execute();
    db_update('field_revision_field_button_size')
      ->fields(array(
      'field_button_size_value' => 'btn-' . $new,
    ))
      ->condition('field_button_size_value', 'btn-' . $old)
      ->execute();
  }
}

/**
 * Make the name and module length bigger.
 */
function command_buttons_update_7105() {
  db_change_field('command_buttons', 'name', 'name', array(
    'description' => 'The machine name of the entity.',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
  ));
  db_change_field('command_buttons', 'module', 'module', array(
    'description' => 'The module name.',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
  ));
}

/**
 * Create entitycache bin.
 */
function command_buttons_update_7106() {
  entity_entitycache_installed_modules(array(
    'command_buttons',
  ));
}

/**
 * Delete duplicate add_file buttons.
 */
function command_buttons_update_7107() {
  $file_buttons = array_keys(command_buttons_load_multiple(FALSE, array(
    'module' => 'oa_files',
  )));
  command_buttons_delete_multiple($file_buttons);
}

/**
 * Create buttons for all node types.
 *
 * This was originally done in update 7002 but had a typo.
 */
function command_buttons_update_7108() {
  $node_info = entity_get_info('node');
  foreach ($node_info['bundles'] as $type => $definition) {
    command_buttons_create_node_button($type, $definition['label']);
  }
}

Functions

Namesort descending Description
command_buttons_schema Implements hook_schema().
command_buttons_update_7002 Create buttons for all node types.
command_buttons_update_7104 Update comman button field values.
command_buttons_update_7105 Make the name and module length bigger.
command_buttons_update_7106 Create entitycache bin.
command_buttons_update_7107 Delete duplicate add_file buttons.
command_buttons_update_7108 Create buttons for all node types.