function chado_pub_delete

2.x tripal_pub.chado_node.inc chado_pub_delete(&$node)
3.x tripal_pub.chado_node.inc chado_pub_delete(&$node)
1.x tripal_pub.module chado_pub_delete(&$node)

Implements hook_delete().

This function takes a node and if the delete button has been chosen by the user, the publication and it's details will be removed.Following,given the node-ID, the instance will be deleted from the 'chado_pub' table.

@parm $node Then node to be deleted

Related topics

File

legacy/tripal_pub/includes/tripal_pub.chado_node.inc, line 1035
Implements Drupal Node hooks to create the chado_analysis node content type.

Code

function chado_pub_delete(&$node) {

  $pub_id = chado_get_id_from_nid('pub', $node->nid);

  // if we don't have a pub id for this node then this isn't a node of
  // type chado_pub or the entry in the chado_pub table was lost.
  if (!$pub_id) {
    return;
  }

  // Remove data from {chado_pub}, {node} and {node_revision} tables of
  // drupal database
  $sql_del = "DELETE FROM {chado_pub} 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 pub and pubprop tables of chado database as well
  chado_query("DELETE FROM {pubprop} WHERE pub_id = :pub_id", array(':pub_id' => $pub_id));
  chado_query("DELETE FROM {pub} WHERE pub_id = :pub_id", array(':pub_id' => $pub_id));
}