You are here

function og_uninstall in Organic groups 7

Same name and namespace in other branches
  1. 8 og.install \og_uninstall()
  2. 5.8 og.install \og_uninstall()
  3. 5 og.install \og_uninstall()
  4. 5.3 og.install \og_uninstall()
  5. 5.7 og.install \og_uninstall()
  6. 6.2 og.install \og_uninstall()
  7. 6 og.install \og_uninstall()
  8. 7.2 og.install \og_uninstall()

Implements hook_uninstall().

File

./og.install, line 48
Install, update, and uninstall functions for the Organic groups module.

Code

function og_uninstall() {
  $vars = array(
    'og_context',
    'og_group_manager_full_access',
    'og_skip_access',
    'og_update_batch_size',
    'og_upgrade_7001',
    'og_node_access_strict',
  );
  foreach ($vars as $var) {
    variable_del($var);
  }

  // Remove all fields owned by organic groups.
  foreach (field_read_fields(array(
    'module' => 'og',
  ), array(
    'include_inactive' => TRUE,
  )) as $field) {

    // We need to invoke the storage_delete hook and the field_delete_instance
    // here, even though this should be done by field_delete_field().
    // The current version of this function only works on active fields,
    // and during uninstall, the fields will be inactive.
    // Can be removed once
    // http://drupal.org/node/943772
    // is fixed.
    module_invoke($field['storage']['module'], 'field_storage_delete_field', $field);
    $instances = field_read_instances(array(
      'field_id' => $field['id'],
    ), array(
      'include_inactive' => TRUE,
    ));
    foreach ($instances as $instance) {
      field_delete_instance($instance, FALSE);
    }
    field_delete_field($field['field_name']);
  }
}