You are here

function _support_mail_notify in Support Ticketing System 7

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

Use drupal_mail to send email.

1 call to _support_mail_notify()
support_notification in ./support.module
Send notification emails to everyone subscribed to the updated ticket.

File

./support.module, line 2089
support.module

Code

function _support_mail_notify($op, $account, $comment = array(), $nid = NULL, $suppress = FALSE, $language = NULL) {
  $notify = variable_get('support_mail_' . $op . '_notify', TRUE);
  if ($notify) {
    $node = node_load($nid);
    $params['account'] = $account;
    $params['nid'] = $nid;
    if (isset($comment->cid)) {
      $params['cid'] = $comment->cid;
      $params['comment'] = $comment;
    }
    else {
      $params['cid'] = 0;
    }
    $params['suppress'] = $suppress;
    $language = $language ? $language : user_preferred_language($account);
    $params['integrate_email'] = db_query('SELECT integrate_email FROM {support_client} WHERE clid = :clid', array(
      ':clid' => $node->client,
    ))
      ->fetchField();
    if ($params['integrate_email'] == TRUE) {
      $mailfrom = db_query('SELECT mailfrom FROM {support_client} WHERE clid = :clid', array(
        ':clid' => $node->client,
      ))
        ->fetchField();
    }
    else {
      $mailfrom = variable_get('support_global_mailfrom', '');
    }
    $mail = drupal_mail('support', $op, $account->mail, $language, $params, $mailfrom);

    // TODO: notify admins as necessary
  }
  return empty($mail) ? NULL : $mail['result'];
}