function chado_project_update

2.x tripal_project.chado_node.inc chado_project_update($node)
3.x tripal_project.chado_node.inc chado_project_update($node)
1.x tripal_project.module chado_project_update($node)

Implements hook_update().

Parameters

$node: The node which is to have its containing information updated when the user modifies information pertaining to the specific project

Related topics

File

tripal_project/includes/tripal_project.chado_node.inc, line 347
Implement the project node content type

Code

function chado_project_update($node) {

  $node->title = trim($node->title);
  $node->description = trim($node->description['value']);

  // update the project and the description
  $project_id = chado_get_id_from_nid('project', $node->nid);
  $match = array('project_id' => $project_id);
  $values = array(
    'name' => $node->title,
    'description' => '',
  );
  $status = chado_update_record('project', $match, $values);
  if (!$status) {
    drupal_set_message(t('Unable to update project.', 'warning'));
    watchdog('tripal_project', 'Update project: Unable to update project where values: %values', 
    array('%values' => print_r($values, TRUE)), WATCHDOG_ERROR);
  }

  // * Properties Form *
  // Add the description property
  $properties = chado_retrieve_node_form_properties($node);
  $descrip_id = tripal_get_cvterm(array(
    'name' => 'Project Description',
    'cv_id' => array('name' => 'project_property')
  ));
  $properties[$descrip_id->cvterm_id][0] = $node->description;

  $details = array(
    'property_table' => 'projectprop',
    'base_table' => 'project',
    'foreignkey_name' => 'project_id',
    'foreignkey_value' => $project_id
  );
  chado_update_node_form_properties($node, $details, $properties);

  // * Relationships Form *
  $details = array(
    'relationship_table' => 'project_relationship', // name of the _relationship table
    'foreignkey_value' => $project_id // value of the example_id key
  );
  chado_update_node_form_relationships($node, $details);
}