You are here

function _pmtask_beforesave in Drupal PM (Project Management) 7

Prepares pmtask for saving.

2 calls to _pmtask_beforesave()
pmtask_insert in pmtask/pmtask.module
Implements hook_insert().
pmtask_update in pmtask/pmtask.module
Implements hook_update().

File

pmtask/pmtask.module, line 564

Code

function _pmtask_beforesave(&$node) {
  $org_query = db_select('node', 'n');
  $org_query
    ->join('pmorganization', 'sor', 'n.vid = sor.vid');
  $org_result = $org_query
    ->fields('n', array(
    'title',
  ))
    ->condition('n.type', 'pmorganization')
    ->condition('n.nid', $node->organization_nid)
    ->execute();
  $o = $org_result
    ->fetchObject();
  $node->organization_title = $o->title;
  $pro_query = db_select('node', 'n');
  $pro_query
    ->join('pmproject', 'spr', 'n.vid = spr.vid');
  $pro_result = $pro_query
    ->fields('n', array(
    'title',
  ))
    ->fields('spr', array(
    'organization_title',
  ))
    ->condition('n.type', 'pmproject')
    ->condition('n.nid', $node->project_nid)
    ->execute();
  $p = $pro_result
    ->fetchObject();
  $node->project_title = $p->title;
  $assigned = node_load($node->assigned_nid);
  $node->assigned_title = isset($assigned->title) ? $assigned->title : NULL;

  // Allow use of comma when inputting numerical values - str_replace with period decimal
  $node->duration = floatval(str_replace(',', '.', $node->duration));
  $node->price = floatval(str_replace(',', '.', $node->price));
}