function drush_tripal_phylogeny_trp_delete_phylotree

2.x tripal_phylogeny.drush.inc drush_tripal_phylogeny_trp_delete_phylotree()
3.x tripal_phylogeny.drush.inc drush_tripal_phylogeny_trp_delete_phylotree()

Deletes a phylotree record.

Executed when 'drush trp-delete-phylotree' is called.

Related topics

File

tripal_phylogeny/tripal_phylogeny.drush.inc, line 221
Contains function relating to drush-integration of this module.

Code

function drush_tripal_phylogeny_trp_delete_phylotree() {
  $username = drush_get_option('username');
  drush_tripal_core_set_user($username);

  $options = array(
    'phylotree_id' => drush_get_option('phylotree_id'),
    'name' => trim(drush_get_option('name')),
  );
  if (!$options['phylotree_id'] and $options['name']) {
    $phylotree = chado_select_record('phylotree', array('phylotree_id'), array('name' => $options['name']));
    if (count($phylotree) > 0) {
      $options['phylotree_id'] = $phylotree[0]->phylotree_id;
    }
    else {
      drush_print('A phylotree record with this name does not exists.');
    }
  }

  if ($options['phylotree_id'] and tripal_delete_phylotree($options['phylotree_id'])) {
    chado_cleanup_orphaned_nodes('phylotree');
  }
  drush_print("Done.");
}