You are here

function rate_expiration_form_rate_widget_form_alter in Rate 6.2

Same name and namespace in other branches
  1. 7 expiration/rate_expiration.module \rate_expiration_form_rate_widget_form_alter()

File

expiration/rate_expiration.module, line 8

Code

function rate_expiration_form_rate_widget_form_alter(&$form, &$form_state) {
  if (isset($form['error'])) {

    // Do not add our fields on forms with an error.
    return;
  }
  if ($form['#widget_id']) {
    $widgets = variable_get(RATE_VAR_WIDGETS, array());
    $widget = $widgets[$form['#widget_id']];
  }
  else {
    $widget = new stdClass();
  }
  $form['expiration'] = array(
    '#type' => 'fieldset',
    '#title' => t('Expiration settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $options = array(
    -1 => t('Never'),
  ) + drupal_map_assoc(array(
    300,
    900,
    1800,
    3600,
    10800,
    21600,
    32400,
    43200,
    86400,
    172800,
    345600,
    604800,
    1209600,
    1814400,
    2419200,
  ), 'format_interval');
  $form['expiration']['expiration'] = array(
    '#type' => 'select',
    '#title' => t('Disable voting after this period'),
    '#options' => $options,
    '#default_value' => isset($widget->expiration) ? $widget->expiration : -1,
    '#description' => t('Time that has to elapse after creating a node before voting is disabled.'),
  );
  $form['expiration']['expiration_allow_override'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow override'),
    '#default_value' => isset($widget->expiration_allow_override) ? $widget->expiration_allow_override : FALSE,
    '#description' => t('When enabled, the expiration date can be customized in the node edit screen.'),
  );
}