You are here

function subscriptions_taxonomy_subscriptions in Subscriptions 7

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

Implements hook_subscriptions().

Parameters

$op:

null $arg0:

null $arg1:

null $arg2:

Return value

array|null

File

./subscriptions_taxonomy.module, line 26
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' => array(
            'table' => 'taxonomy_index',
            'alias' => 'tn',
            'on' => db_driver() != 'pgsql' ? 's.value = tn.tid' : 's.value = CAST(tn.tid AS VARCHAR)',
          ),
          'where' => array(
            array(
              'tn.nid',
              $node->nid,
              '=',
            ),
          ),
          'groupby' => 'tn.nid',
        );
        if ($arg0['type'] == 'comment') {
          $params['node']['tid']['where'][] = array(
            's.send_comments',
            1,
            '=',
          );
        }
        elseif ($arg0['type'] == 'node' && $arg0['action'] == 'update') {
          $params['node']['tid']['where'][] = array(
            's.send_updates',
            1,
            '=',
          );
        }
        return $params;
      }
      break;
    case 'fields':

      // $arg0 is module.
      if ($arg0 == 'node' || $arg0 == 'comment') {
        $tr = 't';
        return array(
          'tid' => array(
            'data_function' => 'subscriptions_taxonomy_data',
            'subs_mod' => 'subscriptions_taxonomy',
            'subs_type' => $tr('category'),
            'mailkey' => 'node-type-',
          ),
        );
      }
      break;
    case 'stypes':
      return $stypes;
    case 'stype':
      return isset($stypes[$arg0]) ? array_merge($stypes[$arg0], array(
        $arg1,
        $arg2,
      )) : NULL;
  }
  return NULL;
}