You are here

function search_files_helpers_validate_add_edit in Search Files 6.2

Same name and namespace in other branches
  1. 5 search_files.module \search_files_helpers_validate_add_edit()
  2. 7.2 search_files.module \search_files_helpers_validate_add_edit()

validate the existance of the helper app supplied by the helper_add or helper_edit form

Parameters

unknown_type $field:

File

./search_files.module, line 359
Used to index files in attachments and directories

Code

function search_files_helpers_validate_add_edit($field) {
  if (!preg_match('/%file%/', $field['#value'])) {
    form_set_error($field['#title'], t('"%field" must contain the token %file%', array(
      '%field' => $field['#title'],
    )));
  }

  // Check to see if helper app can be found
  $helper_file = preg_replace('/\\s.+$/', '', $field['#value']);
  if (!file_exists($helper_file)) {
    form_set_error($field['#title'], t("Can't find helper app %helper -- please verify it is installed.", array(
      '%helper' => $helper_file,
    )));
  }
}