You are here

function community_tags_nodeapi in Community Tags 6.2

Same name and namespace in other branches
  1. 5 community_tags.module \community_tags_nodeapi()
  2. 6 community_tags.module \community_tags_nodeapi()

Implementation of hook_nodeapi(). Community tags hooks should be called after taxonomy module hooks - see system weight in community_tags.install.

File

./community_tags.module, line 212
Implements community tagging of nodes using a specific vocabulary for Drupal v6.x

Code

function community_tags_nodeapi(&$node, $op, $teaser) {
  switch ($op) {
    case 'load':
      $node->community_tags_form = _community_tags_is_tagging_view_visible($node, COMMUNITY_TAGS_MODE_INLINE);
      break;
    case 'delete':
      _community_tags_node_delete($node);
    case 'view':
      global $user;

      // Show quick tag form for this node if we're on a node page view and the
      // form is enabled for this node and the default quick tag vocab is set and it's not a search build.
      if (!$teaser && $node->build_mode != NODE_BUILD_SEARCH_INDEX && $node->community_tags_form) {
        $node->content['community_tags'] = array(
          '#value' => community_tags_node_view($node, TRUE),
          '#weight' => 50,
        );
      }
      break;
    case 'alter':
      $hide_terms_modes = variable_get('community_tags_hide_terms_' . $node->type, array());
      $hide_terms_modes = drupal_map_assoc($hide_terms_modes);
      if ($teaser && isset($hide_terms_modes[COMMUNITY_TAGS_MODE_HIDE_TERMS_TEASER]) || !$teaser && isset($hide_terms_modes[COMMUNITY_TAGS_MODE_HIDE_TERMS_PAGE])) {
        unset($node->taxonomy);
      }
      break;
  }
}