You are here

function pmorganization_uninstall in Drupal PM (Project Management) 7.2

Same name and namespace in other branches
  1. 8 pmorganization/pmorganization.install \pmorganization_uninstall()
  2. 7.3 pmorganization/pmorganization.install \pmorganization_uninstall()
  3. 7 pmorganization/pmorganization.install \pmorganization_uninstall()

Implements hook_uninstall().

File

pmorganization/pmorganization.install, line 34
PM Organization install file.

Code

function pmorganization_uninstall() {
  variable_del('node_options_pmorganization');
  variable_del('pmpermission_field_org_member_reference');
  variable_del('pmpermission_node_pmorganization_enabled');

  // Clean up field instances (and field) and its data.
  module_load_include('inc', 'pmorganization', 'includes/pmorganization.field_instance');
  module_load_include('inc', 'pmorganization', 'includes/pmorganization.field_base');
  $declared_field_bases = pmorganization_default_field_bases();
  $declared_field_instances = pmorganization_default_field_instances();
  $field_instance = field_info_instances('node', 'pmorganization');
  foreach ($declared_field_instances as $declared_instance) {
    $instance = $field_instance[$declared_instance['field_name']];
    if ($instance) {

      // Only delete field base if declared by this module.
      $delete_field_base = isset($declared_field_bases[$declared_instance['field_name']]);
      field_delete_instance($instance, $delete_field_base);
    }
  }
}