You are here

function vote_up_down_nodeapi in Vote Up/Down 5

Same name and namespace in other branches
  1. 6 vote_up_down.module \vote_up_down_nodeapi()

Implementation of hook_nodeapi().

File

./vote_up_down.module, line 210
vote_up_down is a module that adds a widget for +1/-1 votes on nodes. It depends upon Voting API. It's based upon "simplevote.module".

Code

function vote_up_down_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'view':
      $node_type = in_array($node->type, variable_get('vote_up_down_node_types', array()), TRUE);
      if ($node_type) {
        $style = variable_get('vote_up_down_widget_style_node', 0) == 1 ? '_alt' : '';
        if ($teaser && variable_get('vote_up_down_widget_node', 0) && variable_get('vote_up_down_widget_node', 0) != 2) {
          $node->content['vote_up_down'] = array(
            '#value' => theme("vote_up_down_widget{$style}", $node->nid, 'node'),
            '#weight' => -10,
          );
        }
        else {
          if (!$teaser && variable_get('vote_up_down_widget_node', 0) > 1) {
            $node->content['vote_up_down'] = array(
              '#value' => theme("vote_up_down_widget{$style}", $node->nid, 'node'),
              '#weight' => -10,
            );
          }
        }
      }
      break;
  }
}