You are here

function reviews_check_user_review in Reviews 7

Check previous reviews.

Helper function returns TRUE or FALSE based on whether the current user has reviewed the node being displayed. If admin setting is set to allow multiple reviews from a single user then we return FALSE immediately.

3 calls to reviews_check_user_review()
reviews.tpl.php in theme/reviews.tpl.php
Theme template file used to format the reviews page of enabled content types when there are reviews. $variables: $nid: the node ID of the main node being viewed. $review_count: the number of published reviews. $pending_count: the number of reviews…
reviews_add_review in includes/reviews.pages.inc
Form builder for add review page.
reviews_user_reviewed_load in ./reviews.module
Menu callback. Returns the argument passed form the URL if content type allows reviews and reviews are enabled globally and the current user has not already reviewed the node.

File

includes/reviews.api.inc, line 15
This file contains API functions for the reviews system.

Code

function reviews_check_user_review($nid, $uid) {
  if (variable_get('reviews_allow_multiple', 0)) {
    return FALSE;
  }
  $results = db_select('reviews', 'r')
    ->fields('r')
    ->condition('uid', $uid, '=')
    ->condition('nid', $nid, '=')
    ->execute()
    ->fetchAll();
  if (count($results) == 0) {
    return FALSE;
  }
  else {
    return TRUE;
  }
}