You are here

function media_gallery_uninstall in Media Gallery 7

Same name and namespace in other branches
  1. 8 media_gallery.install \media_gallery_uninstall()
  2. 7.2 media_gallery.install \media_gallery_uninstall()

Implements hook_uninstall().

File

./media_gallery.install, line 935
Install file for media_gallery. Includes field and instance definitions.

Code

function media_gallery_uninstall() {

  // Delete all existing galleries.
  $nids = db_query('SELECT nid FROM {node} n WHERE n.type = :type', array(
    ':type' => 'media_gallery',
  ))
    ->fetchCol();
  node_delete_multiple($nids);

  // Delete fields and instances.
  foreach (array_keys(_media_gallery_controlled_fields()) as $field) {
    field_delete_field($field);
  }
  $instances = _media_gallery_controlled_instances();
  $instances += field_info_instances('node', 'media_gallery');
  foreach ($instances as $instance_name => $instance) {
    field_delete_instance($instance);
  }

  // Delete the content type itself.
  // @todo: We can't run this since the content type already ceased to exist
  //   when the module was disabled. But we'd like to be able to, so that the
  //   proper hooks within node_type_delete() get fired.
  // node_type_delete('media_gallery');
  // Delete the taxonomy vocabulary.
  $vid = variable_get('media_gallery_collection_vid');
  if ($vid && function_exists('taxonomy_vocabulary_delete')) {
    taxonomy_vocabulary_delete($vid);
  }

  // Delete variables for the media gallery node type.
  variable_del('node_submitted_media_gallery');
  variable_del('node_options_media_gallery');
  variable_del('comment_media_gallery');
  variable_del('media_gallery_collection_vid');
  variable_del('media_gallery_default_collection_tid');
}