You are here

public function video_zencoder::admin_settings_validate in Video 6.5

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

Overrides video_plugin::admin_settings_validate

File

plugins/video_zencoder/transcoders/video_zencoder.inc, line 190
Transcoder class file to handle Zencoder settings and conversions.

Class

video_zencoder

Code

public function admin_settings_validate($form, &$form_state) {
  $zencoder_api = isset($form_state['values']['video_zencoder_api_key']) ? $form_state['values']['video_zencoder_api_key'] : NULL;
  if (!empty($zencoder_api) || $form_state['values']['vid_convertor'] != 'video_zencoder') {
    if (variable_get('vid_filesystem', 'drupal') != 'video_s3') {
      form_set_error('video_zencoder', t('You must enable Amazon S3 at !link.', array(
        '!link' => l(t('the File System tab'), 'admin/settings/video/filesystem'),
      )));
    }
    return;
  }
  $errors = FALSE;

  // check terms and condition
  if ($form_state['values']['agree_terms_zencoder'] == 0) {
    $errors = TRUE;
    form_set_error('agree_terms_zencoder', t('You must agree to the terms and conditions.'));
  }

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

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