You are here

function support_notification in Support Ticketing System 7

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

Send notification emails to everyone subscribed to the updated ticket.

2 calls to support_notification()
support_comment_insert in ./support.module
Implementation of hook_comment_insert().
support_node_insert in ./support.module
Implementation of hook_node_insert().

File

./support.module, line 2055
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 = :nid', array(
      ':nid' => $nid,
    ));
    foreach ($result as $account) {
      $account = user_load($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);
        }
      }
    }
  }
}