function merci_uninstall in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2
Same name and namespace in other branches
- 6.2 merci.install \merci_uninstall()
- 6 merci.install \merci_uninstall()
Implements hook_uninstall().
File
- ./
merci.install, line 24 - merci Installer / Uninstaller
Code
function merci_uninstall() {
// Delete the vocabulary.
$vid = variable_get('merci_equipment_grouping_vid', 0);
taxonomy_vocabulary_delete($vid);
// Loop over each of the fields defined by this module and delete
// all instances of the field, their data, and the field itself.
// http://api.drupal.org/api/function/field_delete_field/7
foreach (array_keys(_merci_installed_fields()) as $field) {
field_delete_field($field);
}
// 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', 'merci_reservation');
foreach ($instances as $instance_name => $instance) {
field_delete_instance($instance);
}
// Remove all MERCI variables.
$variables = db_query("SELECT name FROM {variable} WHERE name LIKE 'merci_%'");
foreach ($variables as $variable) {
variable_del($variable->name);
}
// Remove all MERCI all associated nodes
//No longer removes content types
$content_types = db_query("SELECT type FROM {merci_node_type} WHERE merci_type_setting <> :type_setting", array(
':type_setting' => 'disabled',
));
$nids = array();
foreach ($content_types as $content_type) {
// TODO Please convert this statement to the D7 database API syntax.
$nodes = db_query("SELECT nid FROM {node} n WHERE n.type = :type", array(
':type' => $content_type->type,
));
foreach ($nodes as $node) {
$nids[] = $node->nid;
}
}
// Remove the programatically created reservation node type
// and all associated nodes.
// TODO Please convert this statement to the D7 database API syntax.
$nodes = db_query("SELECT nid FROM {node} n WHERE n.type = :type", array(
':type' => 'merci_reservation',
));
foreach ($nodes as $node) {
$nids[] = $node->nid;
}
// Delete all the nodes at once
// http://api.drupal.org/api/function/node_delete_multiple/7
node_delete_multiple($nids);
// TODO: http://drupal.org/node/943588
//node_type_delete('merci_reservation');
field_purge_batch(1000);
}