function question_import_validate_extensions in Quiz 6.6
Same name and namespace in other branches
- 6.3 includes/questions_import/questions_import.admin.inc \question_import_validate_extensions()
@function Checks the extension of import file.
Return value
Return error message if the import file extension is not in $extensions array.
1 call to question_import_validate_extensions()
- questions_import_form_validate in includes/
questions_import/ questions_import.admin.inc - Implementation of hook_validate()
File
- includes/
questions_import/ questions_import.admin.inc, line 933 - Administration file for Questions Import module
Code
function question_import_validate_extensions($file, $extensions) {
global $user;
$errors = '';
// Bypass validation for uid = 1.
//if ($user->uid != 1) {
$regex = '/\\.(' . ereg_replace(' +', '|', preg_quote($extensions)) . ')$/i';
if (!preg_match($regex, $file->filename)) {
$errors = '<p>' . t('Only files with the following extensions are allowed: %files-allowed.', array(
'%files-allowed' => $extensions,
)) . '</p>';
}
//}
return $errors;
}