You are here

function subscriptions_content_subscriptions in Subscriptions 5.2

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

Implementation of hook_subscriptions().

File

./subscriptions_content.module, line 20
Subscriptions to content events

Code

function subscriptions_content_subscriptions($op, $arg0 = NULL, $arg1 = NULL, $arg2 = NULL) {
  static $stypes = array(
    'node' => array(
      'node',
      'nid',
    ),
    'type' => array(
      'node',
      'type',
    ),
  );
  $function = '_subscriptions_content_' . $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']['nid']['value'] = $node->nid;
        $params['node']['type']['value'] = $node->type;
        if ($arg0['type'] == 'comment') {
          $where = 's.send_comments = 1';
        }
        elseif ($arg0['type'] == 'node' && $arg0['action'] == 'update') {
          $where = 's.send_updates = 1';
        }
        if (isset($where)) {
          $params['node']['nid']['where'] = $where;
          $params['node']['type']['where'] = $where;
        }
        return $params;
      }
      break;
    case 'fields':

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