You are here

function fivestar_node_type_form_submit in Fivestar 5

Same name and namespace in other branches
  1. 6 fivestar.module \fivestar_node_type_form_submit()

Additional submit handler for the node type form.

File

./fivestar.module, line 283
A simple n-star voting widget, usable in other forms.

Code

function fivestar_node_type_form_submit($form_id, &$form_values) {

  // Do not save any fivestar variables if fivestar is disabled.
  if (isset($form_values['fivestar']) && $form_values['fivestar'] === 0) {
    foreach ($form_values as $key => $value) {
      if (strpos($key, 'fivestar') === 0) {
        variable_del($key . '_' . $form_values['type']);
      }
    }
  }

  // Merge labels into a single variable.
  $labels = array();
  for ($n = 0; $n <= 10; $n++) {
    $labels[] = $form_values['fivestar_label_' . $n];
    variable_del('fivestar_label_' . $n . '_' . $form_values['type']);
  }
  variable_del('fivestar_labels_' . $form_values['type']);
  if ($form_values['fivestar_labels_enable']) {
    variable_set('fivestar_labels_' . $form_values['type'], $labels);
  }
}