You are here

function uc_file_files_form_validate in Ubercart 5

File

uc_file/uc_file.module, line 738
Allows products to be associated with downloadable files.

Code

function uc_file_files_form_validate($form_id, $form_values) {
  switch ($form_values['step']) {
    case 2:
      switch ($form_values['action']) {
        case 'uc_file_delete':

          //Nothing to validate for file delete
          break;
        case 'uc_file_upload':

          //Check any if any hook_file_action('validate', $args) are implemented
          if ($temp_file = file_check_upload()) {
            foreach (module_implements('file_action') as $module) {
              $name = $module . '_file_action';
              $result = $name('upload_validate', array(
                'file_object' => $temp_file,
                'form_id' => $form_id,
                'form_values' => $form_values,
              ));
            }
          }
          else {
            form_set_error('', t('An error occurred while uploading the file'));
          }
          break;
        default:

          //Check any if any hook_file_action('validate', $args) are implemented
          foreach (module_implements('file_action') as $module) {
            $name = $module . '_file_action';
            $result = $name('validate', array(
              'form_id' => $form_id,
              'form_values' => $form_values,
            ));
          }
          break;
      }
      break;
    default:
      break;
  }
}