You are here

function mediafront_preset_submit in MediaFront 7.2

Same name and namespace in other branches
  1. 6.2 includes/mediafront.preset.inc \mediafront_preset_submit()
  2. 6 includes/mediafront.preset.inc \mediafront_preset_submit()
  3. 7 includes/mediafront.preset.inc \mediafront_preset_submit()

Submit handler for the preset form.

1 string reference to 'mediafront_preset_submit'
mediafront_preset_form in includes/mediafront.preset.inc

File

includes/mediafront.preset.inc, line 292

Code

function mediafront_preset_submit($form, &$form_state) {
  $preset = array();
  if (isset($form_state['values']['pid'])) {
    $preset['pid'] = check_plain($form_state['values']['pid']);
  }
  $preset['name'] = check_plain($form_state['values']['name']);
  $preset['description'] = check_plain($form_state['values']['description']);
  $preset['player'] = check_plain($form_state['values']['player']);
  $is_controller = array();
  if (isset($form_state['values']['iscontroller'])) {
    foreach ($form_state['values']['iscontroller'] as $id) {
      $id = check_plain($id);
      $is_controller[$id] = $id;
    }
  }
  $is_playlist = array();
  if (isset($form_state['values']['isplaylist'])) {
    foreach ($form_state['values']['isplaylist'] as $id) {
      $id = check_plain($id);
      $is_playlist[$id] = $id;
    }
  }
  $preset['connect'] = array(
    'iscontroller' => $is_controller,
    'isplaylist' => $is_playlist,
  );

  // Now set the player settings that are only different from the defaults.
  $preset['settings'] = mediafront_get_settings($preset['player'], mediafront_preset_array_flatten($form_state['values']['player_settings']));

  // Save this preset.
  mediafront_preset_save($preset);
  $form_state['redirect'] = mediafront_get_presets_path() . '/preset/' . $preset['name'];
}