You are here

function _support_comment_insert_update2 in Support Ticketing System 7

2 calls to _support_comment_insert_update2()
support_comment_insert in ./support.module
Implementation of hook_comment_insert().
support_comment_update in ./support.module
Implementation of hook_comment_update().

File

./support.module, line 1121
support.module

Code

function _support_comment_insert_update2($node, $comment) {
  global $user;

  // if admin, can update who is assigned to the ticket
  if (user_access('administer support') && (!isset($comment->support_email) || !$comment->support_email)) {
    if (isset($comment->subscribed_users) && !empty($comment->subscribed_users)) {
      $array = drupal_explode_tags($comment->subscribed_users);
      foreach ($array as $name) {
        $uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(
          ':name' => $name,
        ))
          ->fetchField();
        $notify = "notify_{$uid}";
        $comment->{$notify} = 1;
      }
    }
    $available = _support_assigned(0, $node);
    foreach ($available as $uid => $name) {
      if (!$uid || $user->uid == $uid) {
        continue;
      }
      $notify = "notify-{$uid}";
      support_subscribe_user($node->nid, $uid, isset($comment->{$notify}) ? $comment->{$notify} : 0);
    }
  }
}