You are here

function support_comment_insert in Support Ticketing System 7

Implementation of hook_comment_insert().

File

./support.module, line 1147
support.module

Code

function support_comment_insert($comment) {
  if (is_array($comment)) {
    $node = node_load($comment['nid']);
  }
  else {
    $node = node_load($comment->nid);
  }
  if ($node->type == 'support_ticket') {
    _support_comment_insert_update($comment);

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

    // force auto-subscribe configured users
    if (variable_get('support_autosubscribe_force', FALSE)) {
      _support_autosubscribe($comment->nid, $comment->client);
    }

    // auto-subscribe assigned user
    if ($comment->assigned) {
      support_subscribe_user($comment->nid, $comment->assigned);
    }

    // generate notification emails
    support_notification($comment, $comment->nid, 'ticket_comment_new', isset($comment->suppress) ? $comment->suppress : FALSE);
    _support_comment_insert_update2($node, $comment);
  }
}