You are here

function _support_autosubscribe in Support Ticketing System 7

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

Autosubscribe users to new client ticket.

3 calls to _support_autosubscribe()
support_comment_insert in ./support.module
Implementation of hook_comment_insert().
support_node_insert in ./support.module
Implementation of hook_node_insert().
_support_subscribe_form_attach in ./support.module
Provide option to subscribe/unsubscribe from ticket notification emails.

File

./support.module, line 2035
support.module

Code

function _support_autosubscribe($nid, $client, $save = TRUE) {
  $accounts = array();
  $autosubscribe = db_query('SELECT autosubscribe FROM {support_client} WHERE clid = :clid', array(
    ':clid' => $client,
  ))
    ->fetchField();
  $autosubscribe = explode(',', $autosubscribe);
  foreach ($autosubscribe as $name) {
    $accounts = user_load_multiple(array(), array(
      'name' => trim($name),
    ));
    $account = array_shift($accounts);
    if (is_object($account) && $account->uid) {
      $accounts[$account->uid] = $account->uid;
      if ($save) {
        support_subscribe_user($nid, $account->uid);
      }
    }
  }
  return $accounts;
}