You are here

function uc_file_admin_files_form_action_validate in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_file/uc_file.admin.inc \uc_file_admin_files_form_action_validate()

Validation handler for uc_file_admin_files_form().

See also

uc_file_admin_files_form_action()

1 string reference to 'uc_file_admin_files_form_action_validate'
uc_file_admin_files_form in uc_file/uc_file.admin.inc
Form builder for file products admin.

File

uc_file/uc_file.admin.inc, line 370
File administration menu items.

Code

function uc_file_admin_files_form_action_validate($form, &$form_state) {
  switch ($form_state['values']['action']) {
    case 'uc_file_upload':

      // Upload the file and get its object.
      if ($temp_file = file_save_upload('upload', array())) {

        // Check if any hook_file_action('upload_validate', $args) are implemented.
        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_state' => $form_state,
          ));
        }

        // Save the uploaded file for later processing.
        $form_state['storage']['temp_file'] = $temp_file;
      }
      else {
        form_set_error('', t('An error occurred while uploading the file'));
      }
      break;
    default:

      // This action isn't handled by us, so check 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_state' => $form_state,
        ));
      }
      break;
  }
}