You are here

function fillpdf_form_edit_validate in FillPDF 7

Same name and namespace in other branches
  1. 5 fillpdf.module \fillpdf_form_edit_validate()
  2. 7.2 fillpdf.admin.inc \fillpdf_form_edit_validate()

File

./fillpdf.admin.inc, line 549
Allows mappings of PDFs to site content.

Code

function fillpdf_form_edit_validate($form, &$form_state) {
  $file = isset($_FILES['files']['name']['upload_pdf']) ? $_FILES['files']['name']['upload_pdf'] : NULL;
  if ($file) {
    $validate_file = _fillpdf_validate_upload($file);
    if (isset($validate_file['#error'])) {
      form_set_error('url', $validate_file['#message']);
    }
  }
  $scheme = $form_state['values']['scheme'];
  $using_private_files = $scheme === 'private';
  $destination_set = !empty($form_state['values']['destination_path']);
  $private_destination_path_is_absolute = $using_private_files && $destination_set && strpos($form_state['values']['destination_path'], '/') === 0;
  if ($private_destination_path_is_absolute) {
    form_set_error('destination_path', t('You have chosen to use <em>Private files</em> for storage. Your destination
      path must be a subdirectory of the <em>fillpdf</em> directory and cannot be absolute.'));
  }
}