You are here

function reviews_get_my_reviews_block in Reviews 7

Helper function to return content for My Reviews block.

1 call to reviews_get_my_reviews_block()
reviews_block_view in ./reviews.module
Implements hook_block_view().

File

./reviews.module, line 355
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_get_my_reviews_block() {
  global $user;

  // Get the sort order for reviews.
  if (variable_get('reviews_sort_order', 0) == 0) {
    $sort = 'ASC';
  }
  else {
    $sort = 'DESC';
  }
  $reviews = db_select('reviews', 'r')
    ->fields('r')
    ->condition('uid', $user->uid, '=')
    ->condition('status', 1, '=')
    ->orderBy('created', $sort)
    ->range(0, 5)
    ->execute()
    ->fetchAll();
  if (count($reviews) != 0) {
    return theme('block_my_reviews', array(
      'reviews' => $reviews,
    ));
  }
  else {
    return '';
  }
}