You are here

function biblio_uninstall in Bibliography Module 7.2

Same name and namespace in other branches
  1. 5 biblio.install \biblio_uninstall()
  2. 6.2 biblio.install \biblio_uninstall()
  3. 6 biblio.install \biblio_uninstall()
  4. 7 biblio.install \biblio_uninstall()

File

./biblio.install, line 67

Code

function biblio_uninstall() {

  // @todo remove after development
  $timer_name = 'biblio_uninstall()';
  timer_start($timer_name);
  if (module_exists('taxonomy')) {
    $voc = taxonomy_get_vocabularies();
    foreach ($voc as $vid => $vocabulary) {
      if ($vocabulary->module == 'biblio') {
        taxonomy_vocabulary_delete($vid);
      }
    }
  }
  $result = db_query("SELECT * FROM {node} WHERE type='biblio' ");
  foreach ($result as $node) {
    db_query('DELETE FROM {node} WHERE nid = :nid', array(
      ':nid' => $node->nid,
    ));
    db_query('DELETE FROM {node_revision} WHERE nid = :nid', array(
      ':nid' => $node->nid,
    ));

    // Remove this node from the search index if needed.
    if (function_exists('search_wipe')) {
      search_wipe($node->nid, 'node');
    }
  }
  $vars = db_query("SELECT * FROM {variable} WHERE name LIKE 'biblio_%'");
  foreach ($vars as $var) {
    variable_del($var->name);
  }
  module_load_include('inc', 'biblio', 'includes/biblio.fields');
  biblio_delete_fields();

  // @todo: delete after development
  field_purge_batch(10);
  cache_clear_all();

  // @todo remove after development
  timer_stop($timer_name);
  drupal_set_message($timer_name . ' run time: ' . timer_read($timer_name) . 'ms.');
}