function multichoice_uninstall in Quiz 5.2
Same name and namespace in other branches
- 8.6 question_types/quiz_multichoice/quiz_multichoice.install \multichoice_uninstall()
- 8.4 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 8.5 question_types/quiz_multichoice/quiz_multichoice.install \multichoice_uninstall()
- 6.6 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 6.2 multichoice.install \multichoice_uninstall()
- 6.3 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 6.4 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 6.5 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 7.6 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 7 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 7.4 question_types/multichoice/multichoice.install \multichoice_uninstall()
- 7.5 question_types/multichoice/multichoice.install \multichoice_uninstall()
Implementation of hook_uninstall()
File
- ./
multichoice.install, line 79
Code
function multichoice_uninstall() {
// Remove the two tables we created for this module.
if (db_table_exists('quiz_multichoice_answers')) {
db_query('DROP TABLE {quiz_multichoice_answers}');
}
if (db_table_exists('quiz_multichoice_user_answers')) {
db_query('DROP TABLE {quiz_multichoice_user_answers}');
}
// Erase any saved variable settings from the database.
db_query("DELETE FROM {variable} WHERE name LIKE '%s%%'", 'multichoice_');
// Delete from nodes and node_revisions.
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query('DELETE FROM {node}, {node_revisions}, {quiz_node_question_properties} USING node LEFT JOIN {node_revisions} USING (nid) LEFT JOIN {quiz_node_question_properties} USING (nid) WHERE type IN ("multichoice")');
break;
case 'pgsql':
db_query("DELETE FROM {quiz_node_question_properties} WHERE nid IN (SELECT nid FROM {node} WHERE type IN ('multichoice'))");
db_query("DELETE FROM {node_revisions} WHERE nid IN (SELECT nid FROM {node} WHERE type IN ('multichoice'))");
db_query("DELETE FROM {node} WHERE type IN ('multichoice')");
break;
}
// Truncate the cache so users don't run into any unexpected errors.
cache_clear_all('variables', 'cache');
// Inform the user that uninstall was sucessful.
drupal_set_message(t("The Multichoice module, it's settings, and all saved questions were successfully removed."));
}