function chado_phylotree_update

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

Implements hook_update().

Related topics

File

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

Code

function chado_phylotree_update($node) {

  global $user;

  $node->tree_name = trim($node->tree_name);
  $node->description = trim($node->description);
  $node->dbxref = trim($node->dbxref);

  // Get the phylotree_id for this node.
  $phylotree_id = chado_get_id_from_nid('phylotree', $node->nid);


  $options = array(
    'phylotree_id' => $node->phylotree_id,
    'name' => $node->tree_name,
    'description' => $node->description,
    'analysis_id' => $node->analysis_id,
    'leaf_type' => $node->leaf_type,
    'tree_file' => $node->tree_file,
    'format' => 'newick',
    'dbxref' => $node->dbxref,
    'match' => $node->match,
    'name_re' => $node->name_re,
  );

  $success = tripal_update_phylotree($phylotree_id, $options);

  if (!$success) {
    drupal_set_message("Unable to update phylotree.", "error");
    tripal_report_error('tripal_phylogeny', TRIPAL_WARNING, 
    'Update phylotree: Unable to update phylotree where values: %values', 
    array('%values' => print_r($options, TRUE))
    );
    return;
  }

  // Remove any variables and then add back the variables from the form.
  tripal_delete_node_variables($node->nid);
  tripal_add_node_variable($node->nid, 'phylotree_name_re', $node->name_re);
  tripal_add_node_variable($node->nid, 'phylotree_use_uniquename', $node->match);
  tripal_add_node_variable($node->nid, 'phylotree_tree_file', $node->tree_file);
}