You are here

function casetracker_node_insert in Case Tracker 7

Implements hook_node_insert().

File

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

Code

function casetracker_node_insert($node) {
  $user = NULL;
  if (casetracker_is_case($node->type)) {

    // cases: generate a case ID and send it along.
    $record = $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;
    drupal_write_record('casetracker_case', $record);
    if (is_callable('rules_invoke_event')) {

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