formassembly.install in FormAssembly 7
The Drupal .install file for the formassembly module
This file sets up the database table and fa_form entity. By using hook_schema, Drupal automatically cleans up if the Drupal uninstall process is run on the module.
Author: Shawn P. Duncan Date: 7/22/14 Time: 3:56 PM
File
formassembly.installView source
<?php
/**
* @file
* The Drupal .install file for the formassembly module
*
* This file sets up the database table and fa_form entity.
* By using hook_schema, Drupal automatically cleans up
* if the Drupal uninstall process is run on the module.
*
* Author: Shawn P. Duncan
* Date: 7/22/14
* Time: 3:56 PM
*/
/**
* Implements hook_schema().
*
* @fields:
* eid: internal entity id
* faid: external formsassembly id
* modified: unix timestamp
*/
function formassembly_schema() {
$schema = array();
$schema['formassembly'] = array(
'description' => 'A table to hold forms synced from the FormAssembly service',
'fields' => array(
'eid' => array(
'description' => 'Primary Key eid',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'faid' => array(
'description' => 'Unique key assigned by FormAssembly to identify each form',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'name' => array(
'description' => 'name as it is keyed by FormAssembly',
'type' => 'text',
'size' => 'normal',
'not null' => FALSE,
),
'modified' => array(
'description' => 'Unix timestamp since the external data of the entity was last updated.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'eid',
),
'unique keys' => array(
'faid' => array(
'faid',
),
),
'indexes' => array(
'form_id' => array(
'faid',
),
'changed' => array(
'modified',
),
),
);
return $schema;
}
/**
* Implementation of hook_install().
*
* @todo the 'display' item in $field_instance is not hiding the field
*/
function formassembly_install() {
$field = array(
'field_name' => 'fa_query_params',
'cardinality' => 1,
'type' => 'text_long',
);
field_create_field($field);
$field_instance = array(
'field_name' => 'fa_query_params',
'label' => 'Form query parameters',
'entity_type' => 'fa_form',
'bundle' => 'fa_form',
'display' => array(
'default' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
'markup' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
),
'full' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
),
),
'description' => t('Enter parameters to be added to FormAssembly form request.<br />' . 'Parameter definitions should be of the form \'key|value\', with one parameter per line.'),
);
field_create_instance($field_instance);
}
/**
* Implementation of hook_uninstall().
*/
function formassembly_uninstall() {
$result = db_query("SELECT v.name FROM {variable} v WHERE v.name LIKE 'formassembly_%'");
foreach ($result as $var) {
variable_del($var->name);
}
field_delete_field('fa_query_params');
db_drop_table('formassembly');
}
Functions
Name | Description |
---|---|
formassembly_install | Implementation of hook_install(). |
formassembly_schema | Implements hook_schema(). |
formassembly_uninstall | Implementation of hook_uninstall(). |