You are here

function reviews_moderation in Reviews 7

Form builder for reviews moderation.

1 string reference to 'reviews_moderation'
reviews_menu in ./reviews.module
Implements hook_menu().

File

includes/reviews.admin.inc, line 301
This file contains all the functions necessary for the admin pages of the reviews system.

Code

function reviews_moderation($form, &$form_state) {
  $form = array();
  $result = db_select('reviews', 'r')
    ->extend('PagerDefault')
    ->limit(15)
    ->fields('r')
    ->condition('status', 0, '=')
    ->orderBy('created', 'ASC')
    ->execute();
  $header = array(
    'rid' => array(
      'data' => t('Review ID'),
    ),
    'node_title' => array(
      'data' => t('Reviewed Content Title'),
    ),
    'username' => array(
      'data' => t('Reviewer'),
    ),
    'review' => array(
      'data' => t('Review'),
    ),
    'rating' => array(
      'data' => t('Rating'),
    ),
    'actions' => array(
      'data' => t('Operations'),
    ),
  );
  if (!variable_get('reviews_use_rating')) {
    unset($header['rating']);
  }
  $data = array();
  while ($review = $result
    ->fetchAssoc()) {
    $review_content = unserialize($review['review']);
    $data[$review['rid']] = array(
      'rid' => $review['rid'],
      'node_title' => check_plain(reviews_get_node_title($review['nid'])),
      'username' => check_plain(reviews_get_username($review['uid'])),
      'review' => check_markup($review_content['value'], $review_content['format']),
      'rating' => $review['rating'],
      'actions' => l(t('view'), 'node/' . $review['nid'] . '/reviews', array(
        'fragment' => 'review_' . $review['rid'],
      )) . ' / ' . l(t('approve'), 'admin/content/reviews/approve/' . $review['rid']),
    );
    if (!variable_get('reviews_use_rating')) {
      unset($header['rating']);
    }
  }
  $form['reviews'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $data,
    '#empty' => t('There are currently no reviews awaiting moderation.'),
  );
  $form['pager'] = array(
    '#markup' => theme('pager', array(
      'tags' => array(),
    )),
  );
  return $form;
}