function pmproject_insert in Drupal PM (Project Management) 7
Implements hook_insert().
1 call to pmproject_insert()
- pmproject_update in pmproject/
pmproject.module - Implements hook_update().
File
- pmproject/
pmproject.module, line 405
Code
function pmproject_insert($node) {
_pmproject_beforesave($node);
$org_result = db_select('node', 'n')
->fields('n', array(
'title',
))
->condition('n.type', 'pmorganization')
->condition('n.nid', $node->organization_nid)
->execute();
$organization = $org_result
->fetchObject();
$per_result = db_select('node', 'n')
->fields('n', array(
'title',
))
->condition('n.type', 'pmperson')
->condition('n.nid', $node->manager_nid)
->execute();
$manager = $per_result
->fetchObject();
if (!$manager) {
$manager = new stdClass();
$manager->title = '';
}
$assigned = node_load($node->assigned_nid);
if (!$assigned) {
$assigned = new stdClass();
$assigned->title = '';
}
db_insert('pmproject')
->fields(array(
'vid' => $node->vid,
'nid' => $node->nid,
'organization_nid' => $node->organization_nid,
'organization_title' => $organization->title,
'projectcategory' => $node->projectcategory,
'projectstatus' => $node->projectstatus,
'projectpriority' => $node->projectpriority,
'pricemode' => $node->pricemode,
'price' => $node->price,
'currency' => $node->currency,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'manager_nid' => $node->manager_nid,
'manager_title' => $manager->title,
'assigned_nid' => $node->assigned_nid,
'assigned_title' => $assigned->title,
))
->execute();
}