You are here

function jw_player_settings_form_validate in JW Player 7.2

General settings form validate.

1 string reference to 'jw_player_settings_form_validate'
jw_player_settings_form in ./jw_player.admin.inc
General settings form

File

./jw_player.admin.inc, line 142
Provides admin settings form(s)

Code

function jw_player_settings_form_validate($form, &$form_state) {
  $values = $form_state['values'];
  $v = (int) $values['jw_player_version'];
  $host = $values['jw_player_hosting'];
  if ($host == 'cloud') {
    if (empty($values['jw_player_cloud_player_default'])) {
      form_set_error('jw_player_cloud_player_default', t('Default Player Library URL is required when Hosting type is Cloud-Hosted.'));
    }
    else {
      preg_match(jw_player_library_url_regex(), $values['jw_player_cloud_player_default'], $matches);
      if (!isset($matches[2])) {
        form_set_error('jw_player_cloud_player_default', t('Default Player Library URL does not match format provided by JWPlayer.com.'));
      }
    }
  }
  else {
    $key = 'jw_player_key' . ($v == 7 ? '_7' : '');
    if (empty($values[$key])) {
      form_set_error($key, t('Self-Hosted Player License Key is required when Hosting type is Self-Hosted.'));
    }
    else {
      if (@base64_encode(base64_decode($values[$key])) !== $values[$key]) {
        form_set_error($key, t('Self-Hosted Player License Key must be a valid Base64 encoded value.'));
      }
    }
  }
}