You are here

function casetracker_node_update in Case Tracker 7

Implements hook_node_update().

File

./casetracker.module, line 253
Enables the handling of projects and their cases.

Code

function casetracker_node_update($node) {
  if (casetracker_is_case($node->type)) {
    $record = (object) $node->casetracker;
    $record->assign_to = is_numeric($record->assign_to) ? $record->assign_to : casetracker_get_uid($record->assign_to);
    $record->nid = $node->nid;
    $record->vid = $node->vid;
    $primary = isset($node->revision) && $node->revision ? array(
      'nid',
    ) : array(
      'nid',
      'vid',
    );
    drupal_write_record('casetracker_case', $record, $primary);
    if (is_callable('rules_invoke_event')) {

      //Determine if the user id has changed
      if ($record->assign_to && $record->assign_to != $node->original->casetracker->assign_to) {
        $user = user_load($record->assign_to);
        rules_invoke_event('casetracker_assign_case', $node, $user);
      }
      _casetracker_change_event($node, $node->original->casetracker, $record);
    }
  }
}