You are here

function community_tags_block in Community Tags 5

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

Implementation of hook_block().

File

./community_tags.module, line 118

Code

function community_tags_block($op = 'list', $delta = 0, $edit = array()) {
  global $user;
  switch ($op) {
    case 'list':
      $block[0]['info'] = t('Community tagging form');
      return $block;
    case 'view':
      if (user_access('access content') && user_access('tag content')) {
        if (arg(0) == 'node' && is_numeric(arg(1)) && (arg(2) == '' || arg(2) == 'view')) {
          $node = node_load(arg(1));
          if ($node && variable_get('community_tags_display_' . $node->type, COMMUNITY_TAGS_MODE_TAB) == COMMUNITY_TAGS_MODE_BLOCK) {
            $block['subject'] = t('Tag this');
            $block['content'] = community_tags_node_view($node, TRUE);
            return $block;
          }
        }
      }
      break;
  }
}