function chado_contact_delete
2.x tripal_contact.chado_node.inc | chado_contact_delete(&$node) |
3.x tripal_contact.chado_node.inc | chado_contact_delete(&$node) |
1.x tripal_contact.module | chado_contact_delete(&$node) |
Implements hook_delete().
This function takes a node and if the delete button has been chosen by the user, the contact and it's details will be removed.Following,given the node-ID, the instance will be deleted from the 'chado_contact' table.
@parm $node Then node which contains the information stored within the node-ID
Related topics
File
- tripal_contact/
includes/ tripal_contact.chado_node.inc, line 566 - Implements drupal node hooks.
Code
function chado_contact_delete(&$node) {
$contact_id = chado_get_id_from_nid('contact', $node->nid);
// if we don't have a contact id for this node then this isn't a node of
// type chado_contact or the entry in the chado_contact table was lost.
if (!$contact_id) {
return;
}
// Remove data from {chado_contact}, {node} and {node_revisions} tables of
// drupal database
$sql_del = "DELETE FROM {chado_contact} WHERE nid = :nid AND vid = :vid";
db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
$sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
$sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
// Remove data from contact and contactprop tables of chado database as well
chado_query("DELETE FROM {contactprop} WHERE contact_id = :contact_id", array(':contact_id' => $contact_id));
chado_query("DELETE FROM {contact} WHERE contact_id = :contact_id", array(':contact_id' => $contact_id));
}