You are here

function rate_nodeapi in Rate 6.2

Implements hook_nodeapi().

File

./rate.module, line 565
Rate module

Code

function rate_nodeapi(&$node, $op, $a3, $a4) {

  // Adding the form to the node view
  if ($op == 'view') {
    $widgets = rate_get_active_widgets('node', $node->type, $a3);
    foreach ($widgets as $widget_id => $widget) {
      $widget_name = 'rate_' . $widget->name;
      _rate_check_widget($widget);
      $display_mode = $a3 ? $widget->teaser_display_mode : $widget->node_display_mode;
      $widget_code = array(
        '#value' => rate_generate_widget($widget_id, 'node', $node->nid, $display_mode),
        '#weight' => $widget->node_display == RATE_DISPLAY_ABOVE_CONTENT ? 0 : 50,
      );
      if ($widget->node_display != RATE_DISPLAY_ABOVE_CONTENT && $widget->node_display != RATE_DISPLAY_BELOW_CONTENT) {
        $node->{$widget_name} = $widget_code;
      }
      else {
        $node->content[$widget_name] = $widget_code;
      }
    }
  }
}