You are here

function notifications_tags_notifications in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications_tags/notifications_tags.module \notifications_tags_notifications()
  2. 6 notifications_tags/notifications_tags.module \notifications_tags_notifications()
  3. 6.2 notifications_tags/notifications_tags.module \notifications_tags_notifications()
  4. 6.3 notifications_tags/notifications_tags.module \notifications_tags_notifications()
  5. 7 notifications_tags/notifications_tags.module \notifications_tags_notifications()

Implementation of hook_notifications().

File

notifications_tags/notifications_tags.module, line 41
Subscriptions to taxonomy terms

Code

function notifications_tags_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
  switch ($op) {
    case 'names':
      $subs =& $arg0;
      if ($subs->event_type == 'node') {
        if (!empty($subs->fields['tid'])) {
          $term = taxonomy_get_term($subs->fields['tid']);
          $subs->names['term'] = t('Term: %name', array(
            '%name' => $term->name,
          ));
        }
      }
      break;
    case 'subscription types':
      $types['taxonomy'] = array(
        'event_type' => 'node',
        'title' => t('Tags'),
        'access' => 'subscribe to taxonomy terms',
        'fields' => array(
          'tid',
        ),
      );
      return $types;
    case 'subscription fields':

      // Information about available fields for subscriptions
      $fields['tid'] = array(
        'name' => t('Taxonomy term'),
        'field' => 'tid',
        'type' => 'int',
      );
      return $fields;
    case 'query':
      if ($arg0 == 'event' && $arg1 == 'node' && ($node = $arg2->node) || $arg0 == 'user' && $arg1 == 'node' && ($node = $arg2)) {
        if ($tids = notifications_tags_node_get_terms($node->nid)) {
          $query[]['fields']['tid'] = $tids;
          return $query;
        }
      }
      break;
  }
}