function webform_update_7402 in Webform 7.4
Add the webform_conditional database table.
File
- ./
webform.install, line 1422 - Webform module install/schema hooks.
Code
function webform_update_7402() {
// Sanity checks.
if (db_table_exists('webform_conditional')) {
// Both tables exist, so these are Webform-core provided tables.
if (db_table_exists('webform_conditional_rules')) {
return;
}
else {
throw new DrupalUpdateException(t('The "Webform Conditional" module has previously been installed on your site. Either uninstall the module or drop the database table "webform_conditional".'));
}
}
$schema['webform_conditional'] = array(
'description' => 'Holds information about conditional logic.',
'fields' => array(
'nid' => array(
'description' => 'The node identifier of a webform.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'rgid' => array(
'description' => 'The rule group identifier for this group of rules.',
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'andor' => array(
'description' => 'Whether to AND or OR the actions in this group. All actions within the same crid should have the same andor value.',
'type' => 'varchar',
'length' => 128,
),
'action' => array(
'description' => 'The action to be performed on the target. Typically "show" or "hide" for targets of type "component", and "send" for targets of type "email".',
'type' => 'varchar',
'length' => 128,
),
'target_type' => array(
'description' => 'The type of target to be affected. Either "component" or "email". Indicates what type of ID the "target" column contains.',
'type' => 'varchar',
'length' => 128,
),
'target' => array(
'description' => 'The ID of the target to be affected. Typically a component ID.',
'type' => 'varchar',
'length' => 128,
),
'weight' => array(
'description' => 'Determines the position of this conditional compared to others.',
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
'rgid',
),
);
$schema['webform_conditional_rules'] = array(
'description' => 'Holds information about conditional logic.',
'fields' => array(
'nid' => array(
'description' => 'The node identifier of a webform.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'rgid' => array(
'description' => 'The rule group identifier for this group of rules.',
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'rid' => array(
'description' => 'The rule identifier for this conditional rule.',
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'source_type' => array(
'description' => 'The type of source on which the conditional is based. Currently always "component". Indicates what type of ID the "source" column contains.',
'type' => 'varchar',
'length' => 128,
),
'source' => array(
'description' => 'The component ID being used in this condition.',
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'operator' => array(
'description' => 'Which operator (equal, contains, starts with, etc.) should be used for this comparison between the source and value?',
'type' => 'varchar',
'length' => 128,
),
'value' => array(
'description' => 'The value to be compared with source.',
'type' => 'text',
),
),
'primary key' => array(
'nid',
'rgid',
'rid',
),
);
db_create_table('webform_conditional', $schema['webform_conditional']);
db_create_table('webform_conditional_rules', $schema['webform_conditional_rules']);
// Rebuild schema so that webform_update_7403() can use drupal_write_record().
if (db_table_exists('system') && db_field_exists('system', 'status')) {
drupal_get_schema(NULL, TRUE);
}
}