function tripal_featuremap_node_presave

2.x tripal_featuremap.chado_node.inc tripal_featuremap_node_presave($node)
3.x tripal_featuremap.chado_node.inc tripal_featuremap_node_presave($node)

Implements hook_node_presave(). Acts on all content types.

Related topics

File

tripal_featuremap/includes/tripal_featuremap.chado_node.inc, line 480
Hooks implementing the feature map node content type

Code

function tripal_featuremap_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_featuremap':
      // for a form submission the 'fmapname' field will be set,
      // for a sync, we must pull from the featuremap object
      if (property_exists($node, 'fmapname')) {
        // set the title
        $node->title = $node->fmapname;
      }
      else if (property_exists($node, 'featuremap')) {
        $node->title = $node->featuremap->name;
      }
      break;
  }
}