You are here

function webform_uninstall in Webform 7.4

Same name and namespace in other branches
  1. 8.5 webform.install \webform_uninstall()
  2. 5.2 webform.install \webform_uninstall()
  3. 5 webform.install \webform_uninstall()
  4. 6.3 webform.install \webform_uninstall()
  5. 6.2 webform.install \webform_uninstall()
  6. 7.3 webform.install \webform_uninstall()
  7. 6.x webform.install \webform_uninstall()

Implements hook_uninstall().

File

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

Code

function webform_uninstall() {

  // Unset webform variables.
  variable_del('webform_blocks');
  variable_del('webform_tracking_mode');
  variable_del('webform_allowed_tags');
  variable_del('webform_email_address_format');
  variable_del('webform_email_address_individual');
  variable_del('webform_default_from_name');
  variable_del('webform_default_from_address');
  variable_del('webform_default_subject');
  variable_del('webform_email_replyto');
  variable_del('webform_email_html_capable');
  variable_del('webform_default_format');
  variable_del('webform_format_override');
  variable_del('webform_email_select_max');
  variable_del('webform_fieldset_wrap');
  variable_del('webform_node_types_primary');
  variable_del('webform_date_type');
  variable_del('webform_export_format');
  variable_del('webform_csv_delimiter');
  variable_del('webform_csv_line_ending');
  variable_del('webform_export_wordwrap');
  variable_del('webform_excel_legacy_exporter');
  variable_del('webform_progressbar_style');
  variable_del('webform_progressbar_label_first');
  variable_del('webform_progressbar_label_confirmation');
  variable_del('webform_table');
  variable_del('webform_submission_access_control');
  variable_del('webform_token_access');
  variable_del('webform_update_batch_size');
  variable_del('webform_disabled_components');
  variable_del('webform_export_use_progressive_batch');
  foreach (node_type_get_names() as $type => $name) {
    variable_del('webform_node_' . $type);
  }
  $component_list = array();
  $path = drupal_get_path('module', 'webform') . '/components';
  $files = file_scan_directory($path, '/^.*\\.inc$/');
  foreach ($files as $filename => $file) {
    variable_del('webform_enable_' . $file->name, 1);
  }

  // Delete uploaded files.
  $filepath = file_build_uri('webform');
  file_unmanaged_delete_recursive($filepath);

  // Delete the content type "webform" if:
  // 1. there are no existing nodes of type webform and
  // 2. no additional fields have been defined for node type webform, beyond the
  //    default body field.
  $query = new EntityFieldQuery();
  $results = $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'webform')
    ->range(0, 1)
    ->execute();
  $instances = field_info_instances('node', 'webform');
  unset($instances['body']);
  if (!$results && !$instances) {
    node_type_delete('webform');
    drupal_flush_all_caches();
  }
}