function merci_delete_node_type_validate in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6
Same name and namespace in other branches
- 6.2 merci.module \merci_delete_node_type_validate()
- 7.2 merci.module \merci_delete_node_type_validate()
Validates deletion of node types.
Parameters
$type: The type being deleted.
1 call to merci_delete_node_type_validate()
- merci_form_alter in ./
merci.module - Implementation of hook_form_alter().
File
- ./
merci.module, line 1576 - MERCI - Managed Equipment Reservation Checkout and Inventory
Code
function merci_delete_node_type_validate($type) {
$settings = merci_load_content_type_settings($type);
// Only validate active MERCI node types.
if ($settings->type_setting != 'disabled') {
// Determine CCK table and columns the date data is stored in.
$field = content_fields('field_merci_date');
$db_info = content_database_info($field);
$table = $db_info['table'];
// Join on nid here so that any version of the reservation that contain
// the bucket/resource is caught.
$reservations = db_query("SELECT ctn.nid, ctn.title FROM {" . $table . "} ct INNER JOIN {merci_reservation_detail} md ON ct.vid = md.vid INNER JOIN {node} ctn ON ct.nid = ctn.nid INNER JOIN {merci_{$settings->type_setting}_node} m ON md.placeholder_nid = m.nid INNER JOIN {node} mn ON m.vid = mn.vid WHERE mn.type = '%s' AND m.sub_type = %d ORDER BY ct.nid, ct.vid", $settings->type, MERCI_SUB_TYPE_RESERVATION);
$bad_reservations = array();
while ($reservation = db_fetch_object($reservations)) {
$bad_reservations[$reservation->nid] = l($reservation->title, "node/{$reservation->nid}/edit", array(
'query' => drupal_get_destination(),
));
}
if (!empty($bad_reservations)) {
drupal_set_message(t('@type can not be deleted because it is associated with the following reservations:', array(
'@type' => $settings->name,
)) . theme('item_list', $bad_reservations), 'error');
module_invoke_all('exit');
drupal_access_denied();
}
}
}