function tripal_pub_node_insert

2.x tripal_pub.chado_node.inc tripal_pub_node_insert($node)
3.x tripal_pub.chado_node.inc tripal_pub_node_insert($node)

Implements hook_node_insert(). Acts on all content types.

We want the publications to always have a URL of http://[base url]/pub/[pub id] where [pub id] is the Chado publication ID. This will allow for easy linking into the publication without needing to know the node. Of course if you know the node that will still work too (e.g. http://[base url]/node/[node id] so the nodeapi function ensures that the URL path is set after insert or update of the node and when the node is loaded if it hasn't yet been set.

Related topics

File

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

Code

function tripal_pub_node_insert($node) {

  if ($node->type == 'chado_pub') {

    // get the pub
    $pub_id = chado_get_id_from_nid('pub', $node->nid);
    $values = array('pub_id' => $pub_id);
    $pub = chado_generate_var('pub', $values);

    // expand the 'text' fields as those aren't included by default
    // and they really shouldn't be so large to cause problems
    $pub = chado_expand_var($pub, 'field', 'pub.title');
    $pub = chado_expand_var($pub, 'field', 'pub.volumetitle');
    $pub = chado_expand_var($pub, 'field', 'pub.uniquename');
    $node->pub = $pub;

    // Now get the title
    $node->title = chado_get_node_title($node);

    tripal_pub_set_pub_url($node, $pub_id);
  }
}