You are here

rules_forms.install in Rules Forms Support 7.2

Same filename and directory in other branches
  1. 7 rules_forms.install

Installation function for Rules Forms module.

File

rules_forms.install
View source
<?php

/**
 * @file
 * Installation function for Rules Forms module.
 */

/**
 * Implements hook_schema().
 */
function rules_forms_schema() {
  $schema = array();
  $schema['rules_forms'] = array(
    'description' => 'Rules Forms active forms.',
    'fields' => array(
      'form_id' => array(
        'description' => 'The form ID of the active form.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'label' => array(
        'description' => 'The human-readable label of the form.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'properties' => array(
        'description' => 'Serialized information about form properties.',
        'type' => 'text',
        'size' => 'medium',
      ),
      'rebuild' => array(
        'description' => 'Indicates whether form element property information needs to be rebuilt.',
        'type' => 'int',
        'size' => 'tiny',
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'form_id',
    ),
    'unique keys' => array(
      'form_id' => array(
        'form_id',
      ),
    ),
  );
  return $schema;
}

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

  // Set the modules' weight to 20, because we want it to be the last one using
  // hook_form_alter().
  db_update('system')
    ->fields(array(
    'weight',
    20,
  ))
    ->condition('name', 'rules_forms');
}

/**
 * Implements hook_enable().
 */
function rules_forms_enable() {

  // Notify the user of configuration requirements for Rules Forms.
  $t = get_t();
  $link = l(t('enable Rules Forms rules'), RULES_FORMS_ADMIN_PATH);
  drupal_set_message($t('You may now !rules_forms_settings_link for individual forms. For more information please consult the documentation in README.txt in your Rules forms support module folder.', array(
    '!rules_forms_settings_link' => $link,
  )), 'status');
}

/**
 * Implements hook_uninstall().
 */
function rules_forms_uninstall() {
  variable_del('rules_forms_rebuild_needed');
}

/**
 * Deletes the old variable.
 */
function rules_forms_update_7101() {
  variable_del('rules_forms_events');
}

/**
 * Removes empty values from rules_forms_event_info.
 *
 * Unset rules_forms_event_info array values with empty keys to
 * cleanse the settings array of bad form information.
 *
 * @see http://drupal.org/node/1447328#comment-5640172
 */
function rules_forms_update_7102() {
  $event_info = variable_get('rules_forms_event_info', array());
  foreach ($event_info as $key => $value) {

    // Any form of empty key is unwanted (NULL, 0, FALSE, '', etc).
    if (empty($key)) {
      unset($event_info[$key]);
    }
  }
  variable_set('rules_forms_event_info', $event_info);
}

/**
 * Change Rules Forms settings variable name.
 */
function rules_forms_update_7103() {
  $form_info = variable_get('rules_forms_event_info', array());
  variable_set('rules_forms_form_info', $form_info);
  variable_del('rules_forms_event_info');
}

/**
 * Updates from Rules Forms Support 7.x-1.x.
 */
function rules_forms_update_7200() {
  if (!db_table_exists('rules_forms')) {
    drupal_install_schema('rules_forms');
  }
  $form_info = variable_get('rules_forms_form_info', array());
  foreach ($form_info as $form_id => $info) {
    db_insert('rules_forms')
      ->fields(array(
      'form_id' => $form_id,
      'rebuild' => 1,
      'label' => $info['label'],
      // We'll need to rebuild to get all of the form_state anyway.
      'properties' => serialize(array()),
    ))
      ->execute();
  }
  variable_del('rules_forms_form_info');
}

Functions

Namesort descending Description
rules_forms_enable Implements hook_enable().
rules_forms_install Implements hook_install().
rules_forms_schema Implements hook_schema().
rules_forms_uninstall Implements hook_uninstall().
rules_forms_update_7101 Deletes the old variable.
rules_forms_update_7102 Removes empty values from rules_forms_event_info.
rules_forms_update_7103 Change Rules Forms settings variable name.
rules_forms_update_7200 Updates from Rules Forms Support 7.x-1.x.