function student_files_settings_form_validate
Search API
7.x student_files.module | student_files_settings_form_validate($form, &$form_state) |
6.x student_files.module | student_files_settings_form_validate($form, &$form_state) |
We mainly want to make sure nothing got entered in an incorrect format here.
File
- modules/
student_files/ student_files.module, line 701 - This is the student_files module, which will facilitate uploading (securely) files to be associated with student accounts.
Code
function student_files_settings_form_validate($form, &$form_state) {
$values = $form_state ["values"];
// Make sure the absolute system path actually exists.
$student_files_path = $values ["student_files_path"];
// Remove any trailing slashes from the student_files_path.
$student_files_path = rtrim($student_files_path, "/");
$form_state ["values"]["student_files_path"] = $student_files_path;
if (!file_exists($student_files_path)) {
form_error("student_files_path", t("The student files path entered does not exist yet, or the system does not have access
to view it. Make sure it exists and the web server user has file access to read and write
to it."));
return;
}
// Make sure the sub directory pattern doesn't have beginning or trailing slashes.
$form_state ["values"]["student_files_sub_dir_pattern"] = rtrim($form_state ["values"]["student_files_sub_dir_pattern"], "/");
$form_state ["values"]["student_files_sub_dir_pattern"] = ltrim($form_state ["values"]["student_files_sub_dir_pattern"], "/");
// Make sure there are no /'s in the server filename pattern.
if (strstr($form_state ["values"]["student_files_filename_pattern"], "/")) {
form_error("student_files_filename_pattern", t("Do not enter forward slashes (/) in the server filename pattern. If you wish to place
files in subdirectories, use the sub directory pattern field."));
return;
}
}