You are here

function reviews_edit_review in Reviews 7

Form builder for edit review page.

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

File

includes/reviews.pages.inc, line 194
This file contain all function necessary for displaying and leaving reviews.

Code

function reviews_edit_review($form, &$form_state, $nid, $rid) {
  global $user;
  $form = array();
  $node = node_load($nid);
  $title = $node->title;
  $review = reviews_load($rid);
  $form['intro'] = array(
    '#type' => 'item',
    '#markup' => t('Use the form below to edit your review of <em>!title</em>', array(
      '!title' => check_plain($title),
    )),
  );
  $form['nid'] = array(
    '#type' => 'hidden',
    '#value' => $nid,
  );
  $form['rid'] = array(
    '#type' => 'hidden',
    '#value' => $rid,
  );
  $form['review'] = array(
    '#type' => 'text_format',
    '#title' => t('Your review'),
    '#rows' => 10,
    '#required' => TRUE,
    '#default_value' => $review->review['value'],
    '#format' => $review->review['format'],
  );
  if (variable_get('reviews_use_rating') and module_exists('fivestar')) {
    $widget = array(
      'name' => variable_get('reviews_rating_star_widget'),
      'css' => 'active',
    );
    $settings = array(
      'stars' => variable_get('reviews_rating_star_count', 5),
      'allow_clear' => FALSE,
      'style' => 'user',
      'text' => 'none',
      'widget' => $widget,
    );
    $values = array(
      'user' => 0,
      'average' => 0,
      'count' => 0,
    );
    $form['rating'] = array(
      '#type' => 'fivestar',
      '#title' => t('Your rating'),
      '#stars' => variable_get('reviews_rating_star_count', 5),
      '#allow_clear' => FALSE,
      '#settings' => $settings,
      '#values' => $values,
      '#required' => TRUE,
      '#default_value' => $review->rating,
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save Review'),
  );
  return $form;
}