function quotes_uninstall in Quotes 7
Same name and namespace in other branches
- 5 quotes.install \quotes_uninstall()
- 6 quotes.install \quotes_uninstall()
Implements hook_uninstall().
File
- ./
quotes.install, line 342 - Handles installation and updates for the quotes module.
Code
function quotes_uninstall() {
// Gather all the content that might have been created while this
// module was enabled. Simple selects still use db_query().
// http://api.drupal.org/api/function/db_query/7
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(
':type' => 'quotes',
));
$nids = array();
foreach ($result as $row) {
$nids[] = $row->nid;
}
// Delete all the nodes at once.
// http://api.drupal.org/api/function/node_delete_multiple/7
node_delete_multiple($nids);
// Loop over any remaining field instances attached to the node_example
// content type (such as the body field) and delete them individually.
// http://api.drupal.org/api/function/field_delete_field/7
$instances = field_info_instances('node', 'quotes');
foreach ($instances as $instance_name => $instance) {
field_delete_instance($instance);
}
// Delete our content type.
// http://api.drupal.org/api/function/node_type_delete/7
node_type_delete('quotes');
// Purge all field infromation.
// http://api.drupal.org/api/function/field_purge_batch/7
field_purge_batch(1000);
// Delete all our variable we set.
db_query("DELETE FROM {variable} WHERE name LIKE ('quotes_%')");
// Delete the extra_fields.
variable_del('field_bundle_settings_node__quotes');
// Delete all our blocks.
db_query("DELETE FROM {block} WHERE module='quotes'");
// Delete our vocabulary and all terms under it.
$names = db_query('SELECT vid FROM {taxonomy_vocabulary} WHERE name = :name', array(
':name' => 'quotes',
))
->fetchField();
taxonomy_vocabulary_delete($names);
// Include a uninstall message.
drupal_set_message(st('quotes module uninstalled.'));
}