You are here

function subscriptions_taxonomy_subscriptions in Subscriptions 5.2

Same name and namespace in other branches
  1. 6 subscriptions_taxonomy.module \subscriptions_taxonomy_subscriptions()
  2. 7 subscriptions_taxonomy.module \subscriptions_taxonomy_subscriptions()
  3. 2.0.x subscriptions_taxonomy/subscriptions_taxonomy.module \subscriptions_taxonomy_subscriptions()

Implementation of hook_subscriptions().

File

./subscriptions_taxonomy.module, line 19
Subscriptions to taxonomy terms.

Code

function subscriptions_taxonomy_subscriptions($op, $arg0 = NULL, $arg1 = NULL, $arg2 = NULL) {
  static $stypes = array(
    'taxa' => array(
      'node',
      'tid',
    ),
  );
  $function = '_subscriptions_taxonomy_' . $op;
  if (function_exists($function)) {
    return $function($arg0, $arg1, $arg2);
  }
  switch ($op) {
    case 'queue':

      // $arg0 is $event array.
      if ($arg0['module'] == 'node') {
        $node = $arg0['node'];
        $params['node']['tid'] = array(
          'join' => 'INNER JOIN {term_node} t ON s.value = ' . ($GLOBALS['db_type'] == 'pgsql' ? 'CAST(' : '') . 't.tid' . ($GLOBALS['db_type'] == 'pgsql' ? ' AS VARCHAR)' : ''),
          'where' => 't.nid = %d',
          'args' => array(
            $node->nid,
          ),
        );
        if ($arg0['type'] == 'comment') {
          $where = ' AND s.send_comments = 1';
        }
        elseif ($arg0['type'] == 'node' && $arg0['action'] == 'update') {
          $where = ' AND s.send_updates = 1';
        }
        if (isset($where)) {
          $params['node']['tid']['where'] .= $where;
        }
        return $params;
      }
      break;
    case 'fields':

      // Parameter is module
      if ($arg0 == 'node' || $arg0 == 'comment') {
        $tr = 't';
        return array(
          'tid' => array(
            'mailvars_function' => '_subscriptions_content_node_mailvars',
            '!subs_type' => $tr('category'),
          ),
        );
      }
      break;
    case 'stypes':
      return $stypes;
    case 'stype':
      return isset($stypes[$arg0]) ? array_merge($stypes[$arg0], array(
        $arg1,
        $arg2,
      )) : NULL;
  }
}