function pmticket_update in Drupal PM (Project Management) 7
Implements hook_update().
File
- pmticket/
pmticket.module, line 495 - 1: Hooks 2: Access functions
Code
function pmticket_update($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',
))
->condition('n.type', 'pmproject')
->condition('n.nid', $node->project_nid)
->execute();
$p = $pro_result
->fetchObject();
if ($p) {
$node->project_title = $p->title;
}
else {
$node->project_title = '';
}
$task_query = db_select('node', 'n');
$task_query
->join('pmtask', 'sta', 'n.vid = sta.vid');
$task_result = $task_query
->fields('n', array(
'title',
))
->condition('n.type', 'pmtask')
->condition('n.nid', $node->task_nid)
->execute();
if ($ta = $task_result
->fetchObject()) {
$node->task_title = $ta->title;
}
if ($node->task_nid != $node->task_nid_old) {
module_invoke_all('pmticket_change_hierarchy', $node->nid, $node->organization_nid, $node->organization_title, $node->project_nid, $node->project_title, $node->task_nid, $node->task_title);
}
// if this is a new node or we're adding a new revision,
if ($node->revision) {
pmticket_insert($node);
}
else {
_pmticket_beforesave($node);
db_update('pmticket')
->fields(array(
'organization_nid' => $node->organization_nid,
'organization_title' => $node->organization_title,
'project_nid' => $node->project_nid,
'project_title' => $node->project_title,
'task_nid' => $node->task_nid,
'task_title' => $node->task_title,
'task_stepno' => $node->task_stepno,
'ticketcategory' => $node->ticketcategory,
'ticketstatus' => $node->ticketstatus,
'ticketpriority' => $node->ticketpriority,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'pricemode' => $node->pricemode,
'price' => $node->price,
'currency' => $node->currency,
'assigned_nid' => $node->assigned_nid,
'assigned_title' => $node->assigned_title,
))
->condition('vid', $node->vid)
->execute();
if ($node->title != $node->title_old) {
module_invoke_all('pmticket_change', $node->nid, $node->title);
}
}
}