You are here

function webform_install in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform.install \webform_install()
  2. 5 webform.install \webform_install()
  3. 6.3 webform.install \webform_install()
  4. 6.2 webform.install \webform_install()
  5. 7.3 webform.install \webform_install()

Implements hook_install().

File

./webform.install, line 738
Webform module install/schema hooks.

Code

function webform_install() {
  module_load_include('inc', 'node', 'content_types');
  db_update('system')
    ->condition('name', 'webform')
    ->condition('type', 'module')
    ->fields(array(
    'weight' => -1,
  ))
    ->execute();

  // Optionally create the default webform type.
  if (variable_get('webform_install_create_content_type', TRUE)) {
    $webform_type = array(
      'type' => 'webform',
      'name' => st('Webform'),
      'base' => 'node_content',
      'description' => st('Create a new form or questionnaire accessible to users. Submission results and statistics are recorded and accessible to privileged users.'),
      'custom' => TRUE,
      'modified' => TRUE,
      'locked' => FALSE,
    );
    $webform_type = node_type_set_defaults($webform_type);
    node_type_save($webform_type);

    // Enable webform components by default on Webform nodes.
    variable_set('webform_node_webform', TRUE);

    // Now that a webform node type has been created, reset the cache of the
    // node types that support webforms. This is needed for tests which will
    // create nodes in the same execution.
    drupal_static_reset('webform_node_types');
    if (variable_get('webform_install_add_body_field', FALSE)) {
      node_add_body_field($webform_type);
    }

    // Disable comments by default on Webform nodes.
    variable_set('comment_webform', '0');
  }
  else {
    variable_set('webform_node_types_primary', array());
  }

  // Note: MS SQL Server does not support size-limited indexes and the column
  // type (text) is too big to fit inside index size limits.
  if (!db_index_exists('webform_submitted_data', 'data') && db_driver() != 'sqlsrv') {
    db_add_index('webform_submitted_data', 'data', array(
      array(
        'data',
        64,
      ),
    ));
  }
}