You are here

function faq_uninstall in Frequently Asked Questions 7

Same name and namespace in other branches
  1. 8 faq.install \faq_uninstall()
  2. 5.2 faq.install \faq_uninstall()
  3. 5 faq.install \faq_uninstall()
  4. 6 faq.install \faq_uninstall()

Implements hook_uninstall().

Remove the variables, nodes and schema corresponding to the FAQ module.

File

./faq.install, line 110
FAQ module install file.

Code

function faq_uninstall() {

  // Delete the variables we created.
  // General settings.
  variable_del('faq_title');
  variable_del('faq_description');
  variable_del('faq_path');

  // Questions page.
  variable_del('faq_display');
  variable_del('faq_question_listing');
  variable_del('faq_qa_mark');
  variable_del('faq_question_label');
  variable_del('faq_answer_label');
  variable_del('faq_question_length');
  variable_del('faq_hide_qa_accordion');
  variable_del('faq_show_expand_all');
  variable_del('faq_use_teaser');
  variable_del('faq_show_node_links');
  variable_del('faq_back_to_top');
  variable_del('faq_disable_node_links');
  variable_del('faq_default_sorting');
  variable_del('faq_question_long_form');

  // Categories page.
  variable_del('faq_use_categories');
  variable_del('faq_category_display');
  variable_del('faq_category_listing');
  variable_del('faq_category_hide_qa_accordion');
  variable_del('faq_count');
  variable_del('faq_answer_category_name');
  variable_del('faq_group_questions_top');
  variable_del('faq_hide_child_terms');
  variable_del('faq_show_term_page_children');
  variable_del('faq_omit_vocabulary');
  variable_del('faq_enable_term_links');

  // Block settings.
  variable_del('faq_block_recent_faq_count');
  variable_del('faq_block_random_faq_count');

  // Custom breadcrumbs control.
  variable_del('faq_custom_breadcrumbs');

  // Deprecated.
  variable_del('faq_more_link');

  // Remove content type and the fields created.
  $faq_type = 'faq';
  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
  $result = db_query($sql, array(
    ':type' => $faq_type,
  ));
  $nodeids = array();
  foreach ($result as $row) {
    $nodeids[] = $row->nid;
  }
  node_delete_multiple($nodeids);
  _faq_delete_custom_fields();
  node_type_delete($faq_type);
  field_purge_batch(500);

  // Remove content type and the fields created.
  $faq_type = 'faq';
  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
  $result = db_query($sql, array(
    ':type' => $faq_type,
  ));
  $nodeids = array();
  foreach ($result as $row) {
    $nodeids[] = $row->nid;
  }
  node_delete_multiple($nodeids);
  _faq_delete_custom_fields();
  node_type_delete($faq_type);
  field_purge_batch(500);

  // Clear the cache tables.
  cache_clear_all('*', 'cache', TRUE);
  cache_clear_all('*', 'cache_filter', TRUE);
  cache_clear_all('*', 'cache_menu', TRUE);
  cache_clear_all('*', 'cache_page', TRUE);
}