You are here

function rate_comment in Rate 6.2

Implements hook_comment().

File

./rate.module, line 590
Rate module

Code

function rate_comment(&$comment, $op) {

  // Adding the form to the node view
  if ($op == 'view') {
    $node = node_load($comment->nid);
    $widgets = rate_get_active_widgets('comment', $node->type);
    foreach ($widgets as $widget_id => $widget) {
      $widget_name = 'rate_' . $widget->name;
      _rate_check_widget($widget);
      $widget_code = rate_generate_widget($widget_id, 'comment', $comment->cid, $widget->comment_display_mode);
      switch ($widget->comment_display) {
        case RATE_DISPLAY_ABOVE_CONTENT:
          $comment->comment = $widget_code . $comment->comment;
          break;
        case RATE_DISPLAY_BELOW_CONTENT:
          $comment->comment = $comment->comment . $widget_code;
          break;
        case RATE_DISPLAY_DISABLE:
          $comment->{$widget_name} = $widget_code;
          break;
      }
    }
  }
}