You are here

function _pmperson_beforesave in Drupal PM (Project Management) 7

Pre-processing for PM Person node (before saving).

2 calls to _pmperson_beforesave()
pmperson_insert in pmperson/pmperson.module
Implements hook_insert().
pmperson_update in pmperson/pmperson.module
Implements hook_update().

File

pmperson/pmperson.module, line 467

Code

function _pmperson_beforesave(&$node) {
  $username = $node->user_name;
  $ass_user = user_load_by_name($username);
  $node->user_uid = $ass_user->uid;

  // Ignore use of $node->email rather than $node->mail.
  // @ignore coder_tough_love_8
  if (!$node->email) {

    // Ignore use of $node->email rather than $node->mail.
    // @ignore coder_tough_love_8
    $node->email = $ass_user->mail;
  }
  $query = db_select('node', 'n');
  $query
    ->join('pmorganization', 'sor', 'sor.vid = n.vid');
  $result = $query
    ->fields('n', array(
    'title',
  ))
    ->condition('n.type', 'pmorganization')
    ->condition('n.nid', $node->organization_nid)
    ->execute();
  $record = $result
    ->fetchAssoc();
  $node->organization_title = $record['title'];
}