You are here

public function video_zencoder::admin_settings_validate in Video 7

Same name and namespace in other branches
  1. 6.5 plugins/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::admin_settings_validate()
  2. 6.4 plugins/video_zencoder/transcoders/video_zencoder.inc \video_zencoder::admin_settings_validate()

Interface Implementations

Overrides transcoder_interface::admin_settings_validate

See also

sites/all/modules/video/includes/transcoder_interface#admin_settings_validate()

File

modules/video_zencoder/transcoders/video_zencoder.inc, line 221

Class

video_zencoder

Code

public function admin_settings_validate($form, &$form_state) {
  if (variable_get('video_zencoder_api_key', FALSE)) {
    return;
  }

  // check terms and condition
  if ($form_state['values']['agree_terms_zencoder'] == 0) {
    form_set_error('agree_terms_zencoder', t('You must agree !link.', array(
      '!link' => l(t('terms and conditions'), 'http://zencoder.com/terms'),
    )));
  }

  // check for email exists
  // Validate the e-mail address:
  if ($error = user_validate_mail($form_state['values']['zencoder_username'])) {
    form_set_error('zencoder_username', $error);
  }

  // get the API key from zencoder and save it to variable
  if (!form_get_errors()) {
    $email = $form_state['values']['zencoder_username'];
    module_load_include('inc', 'video_zencoder', '/includes/zencoder');
    $zc = new video_zencoder_api();
    $user = new stdClass();
    $user->email = $email;
    $result = $zc
      ->create_user($user);
    if ($result !== TRUE) {
      form_set_error('zencoder_username', $result);
    }
  }
}