You are here

function support_node_insert in Support Ticketing System 7

Implementation of hook_node_insert().

File

./support.module, line 1027
support.module

Code

function support_node_insert($node) {
  if ($node->type == 'support_ticket') {
    _support_node_insert_update($node);

    // auto-subscribe ticket creator
    if (variable_get('support_autosubscribe_creator', FALSE) || isset($node->created_by_email)) {
      support_subscribe_user($node->nid, $node->uid);
    }
    else {
      support_subscribe_user($node->nid, $node->uid, isset($node->notification) ? $node->notification : FALSE);
    }

    // auto-subscribe assigned user
    if ($node->assigned || isset($node->created_by_email) || !user_access('can subscribe other users to notifications')) {
      support_subscribe_user($node->nid, $node->assigned);
    }

    // auto-subscribe configured users
    if (variable_get('support_autosubscribe_force', FALSE) || isset($node->created_by_email) || !user_access('can subscribe other users to notifications')) {
      _support_autosubscribe($node->nid, $node->client);
    }

    // generate notification emails
    support_notification(array(), $node->nid, 'ticket_new', isset($node->suppress) ? $node->suppress : FALSE);
    cache_clear_all();
  }
}