function tripal_phylogeny_node_presave

2.x tripal_phylogeny.chado_node.inc tripal_phylogeny_node_presave($node)
3.x tripal_phylogeny.chado_node.inc tripal_phylogeny_node_presave($node)

Implements hook_node_presave(). Acts on all node content types.

Related topics

File

tripal_phylogeny/includes/tripal_phylogeny.chado_node.inc, line 407
Implements the phylotree node content type

Code

function tripal_phylogeny_node_presave($node) {

  switch ($node->type) {
    // This step is for setting the title for the Drupal node.  This title
    // is permanent and thus is created to be unique.  Title changes provided
    // by tokens are generated on the fly dynamically, but the node title
    // seen in the content listing needs to be set here. Do not call
    // the chado_get_node_title() function here to set the title as the node
    // object isn't properly filled out and the function will fail.
    case 'chado_phylotree':
      // for a form submission the 'phylotreename' field will be set,
      // for a sync, we must pull from the phylotree object
      if (property_exists($node, 'phylotreename')) {
        // set the title
        $node->title = $node->tree_name;
      }
      else if (property_exists($node, 'phylotree')) {
        $node->title = $node->phylotree->name;
      }
      break;
  }
}