You are here

form_builder.install in Form Builder 7

Same filename and directory in other branches
  1. 6 form_builder.install
  2. 7.2 form_builder.install

File

form_builder.install
View source
<?php

/**
 * Implementation of hook_uninstall().
 */
function form_builder_uninstall() {
  $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'form_builder_%'");
  foreach ($result as $row) {
    variable_del($row->name);
  }
}

/**
 * Implementation of hook_requirements().
 */
function form_builder_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'runtime') {
    $form_builder_types = module_invoke_all('form_builder_form_types');
    if (empty($form_builder_types)) {
      $requirements['form_builder_types']['title'] = $t('Form builder');
      $requirements['form_builder_types']['severity'] = REQUIREMENT_ERROR;
      $requirements['form_builder_types']['value'] = $t('No dependent modules found.');
      $requirements['form_builder_types']['description'] = t('Form builder module is installed but no modules implement support for it. You may want to disable Form builder module until it is needed.');
    }
  }
  return $requirements;
}

/**
 * Change the {form_builder_cache} table to use a 'longblob' data column.
 */
function form_builder_update_7000() {
  $spec = array(
    'type' => 'blob',
    'not null' => FALSE,
    'size' => 'big',
  );
  db_change_field('form_builder_cache', 'data', 'data', $spec);
}

/**
 * Change the {form_builder_cache} table to use a longer form_id column.
 */
function form_builder_update_7001() {
  $spec = array(
    'type' => 'varchar',
    'length' => '128',
    'not null' => FALSE,
  );
  db_change_field('form_builder_cache', 'form_id', 'form_id', $spec);
}

/**
 * Migrate to ctools_object_cache.
 */
function form_builder_update_7002() {
  module_enable(array(
    'ctools',
  ));
  $sql = <<<SQL
INSERT INTO {ctools_object_cache}
  (sid, name, obj, updated, data)
SELECT l.sid, 'form_builder_cache', CONCAT(l.type, ':', l.form_id), l.updated, l.data
FROM {form_builder_cache} l
  LEFT OUTER JOIN {form_builder_cache} r ON l.sid=r.sid AND l.type=r.type AND l.form_id=r.form_id AND l.updated<r.updated
WHERE r.sid IS NULL
SQL;
  db_query($sql);
  db_drop_table('form_builder_cache');
}

Functions

Namesort descending Description
form_builder_requirements Implementation of hook_requirements().
form_builder_uninstall Implementation of hook_uninstall().
form_builder_update_7000 Change the {form_builder_cache} table to use a 'longblob' data column.
form_builder_update_7001 Change the {form_builder_cache} table to use a longer form_id column.
form_builder_update_7002 Migrate to ctools_object_cache.