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)

Implementation of tripal_contact_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

File

tripal_contact/tripal_contact.module, line 511
This file contains the basic functions needed for this drupal module. The drupal tripal_contact module maps directly to the chado X module.

Code

function chado_contact_delete(&$node) {

  $contact_id = chado_get_id_for_node('contact', $node);

  // 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 = %d " .
    "AND vid = %d";
  db_query($sql_del, $node->nid, $node->vid);
  $sql_del = "DELETE FROM {node_revisions} " .
    "WHERE nid = %d " .
    "AND vid = %d";
  db_query($sql_del, $node->nid, $node->vid);
  $sql_del = "DELETE FROM {node} " .
    "WHERE nid = %d " .
    "AND vid = %d";
  db_query($sql_del, $node->nid, $node->vid);

  // Remove data from contact and contactprop tables of chado database as well
  chado_query("DELETE FROM {contactprop} WHERE contact_id = %d", $contact_id);
  chado_query("DELETE FROM {contact} WHERE contact_id = %d", $contact_id);
}