webform_civicrm.install in Webform CiviCRM Integration 7
Webform CiviCRM module's install and uninstall code.
File
webform_civicrm.installView source
<?php
/**
* @file
* Webform CiviCRM module's install and uninstall code.
*/
/**
* Implements hook_schema().
*/
function webform_civicrm_schema() {
$schema['webform_civicrm_forms'] = array(
'description' => 'CiviCRM settings for individual Webform nodes.',
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Webform Node ID',
),
'activity_type_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'FK to {civicrm_activity} activity_type_id',
),
'activity_subject' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Subject of auto-created activities',
),
'prefix_known' => array(
'description' => 'Form prefix for known users.',
'type' => 'text',
'not null' => TRUE,
),
'prefix_unknown' => array(
'description' => 'Form prefix for unknown users.',
'type' => 'text',
'not null' => TRUE,
),
'message' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Message to show to known users',
),
'confirm_subscription' => array(
'description' => 'Send confirmation for mailing list subscriptions.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'block_unknown_users' => array(
'description' => 'Only allow known contacts to use form.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
),
);
$schema['webform_civicrm_submissions'] = array(
'description' => 'Link between form submissions and CiviCRM contacts.',
'fields' => array(
'sid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Webform Submission ID',
),
'contact_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'FK to {civicrm_contact} id',
),
'activity_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'FK to {civicrm_activity} id',
),
),
'primary key' => array(
'sid',
),
);
return $schema;
}
/**
* Add column for message to webform_civicrm_forms table.
*/
function webform_civicrm_update_6100() {
$message = array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Message to show to known users',
);
db_add_field('webform_civicrm_forms', 'message', $message);
}
/**
* Add missing activity targets.
*/
function webform_civicrm_update_6101() {
civicrm_initialize();
$db = db_query('SELECT * FROM {webform_civicrm_submissions} WHERE contact_id <> 0 AND activity_id <> 0');
$sql = 'INSERT INTO civicrm_activity_target (activity_id, target_contact_id) VALUES (%1,%2)';
$n = 1;
$c = 0;
$params = array();
foreach ($db as $row) {
$params[$n] = array(
$row['activity_id'],
'Integer',
);
$params[$n + 1] = array(
$row['contact_id'],
'Integer',
);
if ($n > 1) {
$sql .= ',(%' . $n . ',%' . ($n + 1) . ')';
}
$n += 2;
++$c;
}
if ($n > 1) {
CRM_Core_DAO::executeQuery($sql, $params);
}
}
/**
* Add column for confirm_subscription to webform_civicrm_forms table.
*/
function webform_civicrm_update_6102() {
$confirm_subscription = array(
'description' => 'Send confirmation for mailing list subscriptions.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
);
db_add_field('webform_civicrm_forms', 'confirm_subscription', $confirm_subscription);
}
Functions
Name![]() |
Description |
---|---|
webform_civicrm_schema | Implements hook_schema(). |
webform_civicrm_update_6100 | Add column for message to webform_civicrm_forms table. |
webform_civicrm_update_6101 | Add missing activity targets. |
webform_civicrm_update_6102 | Add column for confirm_subscription to webform_civicrm_forms table. |