You are here

function notifications_tags_notifications_object_node in Notifications 6.4

Same name and namespace in other branches
  1. 7 notifications_tags/notifications_tags.module \notifications_tags_notifications_object_node()

Implementation of hook_notifications_object_node()

File

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

Code

function notifications_tags_notifications_object_node($op, $node, $account = NULL) {
  switch ($op) {
    case 'conditions':

      // For a queue query, when not account, we must use our own function to retrieve terms
      $tids = notifications_tags_node_get_terms($node);
      if (!empty($tids)) {
        return array(
          'tid' => $tids,
        );
      }
      break;
    case 'subscriptions':

      // Get all available subscriptions to current node
      $options = array();
      if (!$account || user_access('subscribe to taxonomy terms', $account)) {
        $vocabs = notifications_tags_vocabularies();
        if (notifications_content_type_enabled($node->type, 'taxonomy') && !empty($node->taxonomy)) {
          foreach ($node->taxonomy as $tid => $term) {
            if (array_key_exists($term->vid, $vocabs)) {
              $options[] = array(
                'name' => t('Posts tagged with @name', array(
                  '@name' => $term->name,
                )),
                'type' => 'taxonomy',
                'fields' => array(
                  'tid' => $term->tid,
                ),
                'module' => 'notifications',
              );
            }
          }
        }
      }
      return $options;
  }
}