You are here

function reviews_settings in Reviews 7

Form builder for the main settings page.

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

File

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

Code

function reviews_settings($form, &$form_state) {
  $form = array();
  $form['main'] = array(
    '#type' => 'fieldset',
    '#title' => 'Enable/Disable',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['main']['reviews_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled'),
    '#default_value' => variable_get('reviews_enabled', ''),
    '#description' => t('Turn the review system on or off. When the reviews system is turned off all existing reviews data is retained but the ability to leave or view reviews is disabled.'),
  );
  $form['main']['reviews_sort_order'] = array(
    '#type' => 'select',
    '#title' => t('Sort order for displaying reviews'),
    '#options' => array(
      0 => 'Oldest first.',
      1 => 'Newest first.',
    ),
    '#default_value' => variable_get('reviews_sort_order', 0),
  );
  $form['main']['reviews_allow_multiple'] = array(
    '#type' => 'select',
    '#title' => t('Allow multiple reviews per content item from a single user'),
    '#options' => array(
      0 => 'No',
      1 => 'Yes',
    ),
    '#default_value' => variable_get('reviews_allow_multiple', 0),
  );
  $form['main']['reviews_link_type'] = array(
    '#type' => 'select',
    '#title' => t('Add Review Link Type'),
    '#description' => t('Show Add Review link as a node tab or a link at the bottom of the content.'),
    '#options' => array(
      'tab' => t('Tab'),
      'link' => t('Link'),
    ),
    '#default_value' => variable_get('reviews_link_type', 'tab'),
  );
  $form['main']['reviews_per_page'] = array(
    '#type' => 'textfield',
    '#title' => t('Reviews per Page'),
    '#description' => t('Number of reviews to show per page, enter 0 to show all reviews without pagination.'),
    '#size' => 5,
    '#required' => FALSE,
    '#default_value' => variable_get('reviews_per_page', 0),
  );
  $form['main']['reviews_notify_admin'] = array(
    '#type' => 'select',
    '#title' => t('Notify Admin'),
    '#description' => t('Notify the site administrator when a review is left.'),
    '#options' => array(
      0 => 'No',
      1 => 'Yes',
    ),
    '#default_value' => variable_get('reviews_notify_admin', 0),
  );
  if (module_exists('fivestar')) {
    $form['rating'] = array(
      '#type' => 'fieldset',
      '#title' => t('Rating Field'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['rating']['reviews_use_rating'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use Rating field'),
      '#description' => t('Allow users to leave Fivestar ratings with their reviews.'),
      '#default_value' => variable_get('reviews_use_rating', 0) && module_exists('fivestar'),
    );
    $state = array(
      'visible' => array(
        ':input[name="reviews_use_rating"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $star_range = range(0, 100);
    unset($star_range[0]);
    $form['rating']['reviews_rating_star_count'] = array(
      '#type' => 'select',
      '#title' => t('Number of Stars'),
      '#description' => t('Maximum number of stars in a rating.'),
      '#options' => $star_range,
      '#default_value' => variable_get('reviews_rating_star_count', 5),
      '#states' => $state,
    );
    $widgets = module_invoke_all('fivestar_widgets');
    $form['rating']['reviews_rating_star_widget'] = array(
      '#type' => 'select',
      '#title' => t('Star Widget'),
      '#description' => t('Star widget to use for displaying a rating.'),
      '#options' => array(
        'default' => 'Default',
      ) + $widgets,
      '#default_value' => variable_get('reviews_rating_star_widget', 'Default'),
      '#states' => $state,
    );
  }
  else {
    variable_set('reviews_use_rating', 0);
  }
  $form['ctypes'] = array(
    '#type' => 'fieldset',
    '#title' => 'Reviewable Content Types',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['ctypes']['reviews_enabled_content_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Available Content Types'),
    '#options' => reviews_get_node_types(),
    '#default_value' => variable_get('reviews_enabled_content_types', array()),
  );
  $form['moderation'] = array(
    '#type' => 'fieldset',
    '#title' => 'Moderation Settings',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['moderation']['reviews_moderate_content_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Do Not Moderate'),
    '#description' => t('<em>WARNING:</em> Reviews posted against any of the checked content types above will be published <em>immediately</em>.'),
    '#options' => reviews_get_node_types(),
    '#default_value' => variable_get('reviews_moderate_content_types', array()),
  );
  $form['#submit'][] = 'reviews_set_block_content_types';
  $form['#submit'][] = 'reviews_cache_clear';
  return system_settings_form($form);
}