function merci_inventory_uninstall in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2
Same name and namespace in other branches
- 6.2 modules/merci_inventory/merci_inventory.install \merci_inventory_uninstall()
- 6 modules/merci_inventory/merci_inventory.install \merci_inventory_uninstall()
- 7.3 merci_inventory/merci_inventory.install \merci_inventory_uninstall()
Implementation of hook_uninstall().
File
- modules/
merci_inventory/ merci_inventory.install, line 30 - merci inventory install / uninstall
Code
function merci_inventory_uninstall() {
// delete any merci_inventory_master nodes... even though there really shouldn't be any
$result = db_query("SELECT nid FROM {node} n WHERE type IN ('merci_inventory_master', 'merci_inventory')");
foreach ($result as $node) {
node_delete($node->nid);
}
// 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_inventory_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_inventory');
foreach ($instances as $instance_name => $instance) {
field_delete_instance($instance);
}
$instances = field_info_instances('node', 'merci_inventory_master');
foreach ($instances as $instance_name => $instance) {
field_delete_instance($instance);
}
// delete CCK content_types
$return = node_type_delete('merci_inventory_master');
$return = node_type_delete('merci_inventory');
// You'd think the uninstall submit function would take care of this
// but it doesn't look like it.
node_types_rebuild();
menu_rebuild();
drupal_set_message(t('MERCI Inventory module successfully uninstalled. merci_inventory_master content type and nodes deleted.'));
}