You are here

function support_notification in Support Ticketing System 6

Same name and namespace in other branches
  1. 7 support.module \support_notification()

Send notification emails to everyone subscribed to the updated ticket.

2 calls to support_notification()
support_comment in ./support.module
Implementation of hook_comment().
support_nodeapi in ./support.module
Implementation of hook_nodeapi().

File

./support.module, line 1672
support.module

Code

function support_notification($comment = array(), $nid, $op = 'ticket_comment_new', $suppress = FALSE) {
  if (variable_get('support_notifications', TRUE)) {
    $result = db_query('SELECT uid FROM {support_assigned} WHERE nid = %d', $nid);
    while ($account = db_fetch_object($result)) {
      $account = user_load(array(
        'uid' => $account->uid,
      ));

      // always send emails to admins, even if update was suppressed
      if ($account->status && $account->mail && (!$suppress || user_access('administer support', $account))) {
        _support_mail_notify($op, $account, $comment, $nid, $suppress);
        if (variable_get('support_admin_notify', FALSE)) {
          if (variable_get('support_admin_notify', FALSE) == 1 && user_access('administer support') || variable_get('support_admin_notify', FALSE) == 2) {
            drupal_set_message(t('Sent notification to %email.', array(
              '%email' => $account->mail,
            )));
          }
        }
      }
      else {
        if (!$account->mail) {
          watchdog('support', 'User !name (!uid) has no email address.', array(
            '!name' => $account->name,
            '!uid' => $account->uid,
          ), WATCHDOG_NOTICE);
        }
      }
    }
  }
}