You are here

function og_uninstall in Organic groups 7.2

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 og.install \og_uninstall()

Implements hook_uninstall().

File

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

Code

function og_uninstall() {
  db_delete('variable')
    ->condition('name', 'og_group_manager_default_rids_%', 'LIKE')
    ->execute();
  db_delete('variable')
    ->condition('name', 'og_is_group_default_access__%__%', 'LIKE')
    ->execute();
  $vars = array(
    'og_context',
    'og_group_manager_full_access',
    'og_skip_access',
    'og_update_batch_size',
    'og_upgrade_7001',
    'og_node_access_strict',
    'og_features_ignore_og_fields',
    'og_maintain_overridden_roles',
  );
  foreach ($vars as $var) {
    variable_del($var);
  }

  // Delete OG-core fields.
  $og_fields = array(
    'group_group',
    'og_description',
    'og_membership_request',
  );
  foreach (field_info_instances() as $bundles) {
    foreach ($bundles as $instances) {
      foreach ($instances as $instance) {
        if (in_array($instance['field_name'], $og_fields)) {
          field_delete_instance($instance);
        }
        else {
          $field = field_info_field($instance['field_name']);
          if ($field['type'] == 'entityreference' && ($field['settings']['handler'] == 'og' || strpos($field['settings']['handler'], 'og_') === 0)) {

            // Last instance will take care also of deleting the field itself.
            field_delete_instance($instance);
          }
        }
      }
    }
  }
}