You are here

function reviews_node_view in Reviews 7

Implements hook_node_view().

File

./reviews.module, line 408
This file defines all the necessary hooks and functions to create a system for enabling and authoring content reviews on a per content type basis.

Code

function reviews_node_view($node, $view_mode, $langcode) {
  if (variable_get('reviews_link_type', 'tab') == 'link') {
    if ($view_mode == 'full' && reviews_user_reviewed_load($node->nid)) {
      $review_dest = 'node/' . $node->nid . '/add-review';
      $options = array();
      if (user_access('add reviews')) {
        $dest = $review_dest;
        $text = t('Add review');
      }
      else {
        $dest = 'user';
        $options['query'] = array(
          'destination' => $review_dest,
        );
        $text = t('Login to add review');
      }
      $node->content['add_review_link'] = array(
        '#markup' => '<div class="reviews add-review-link">' . l($text, $dest, $options) . '</div>',
        '#weight' => 100,
      );
    }
  }
}