You are here

function question_import_validate_extensions in Quiz 6.3

Same name and namespace in other branches
  1. 6.6 includes/questions_import/questions_import.admin.inc \question_import_validate_extensions()
1 call to question_import_validate_extensions()
questions_import_form_validate in includes/questions_import/questions_import.admin.inc

File

includes/questions_import/questions_import.admin.inc, line 599

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;
}