You are here

function pmperson_uninstall in Drupal PM (Project Management) 7.2

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

Implements hook_uninstall().

File

pmperson/pmperson.install, line 28
Installation and update functions for PM Person module.

Code

function pmperson_uninstall() {

  // Clean up field instances (and field) and its data.
  module_load_include('inc', 'pmperson', 'includes/pmperson.field_instance');
  module_load_include('inc', 'pmperson', 'includes/pmperson.field_base');
  $declared_field_bases = pmperson_default_field_bases();
  $declared_field_instances = pmperson_default_field_instances();
  $field_instance = field_info_instances('user', 'user');
  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);
    }
  }
}