// HACK to prevent browsers from automatically inserting the user's password into the wrong fields. echo prevent_form_autofill_password(); $repo->print_login(); echo '</form>'; } echo $OUTPUT->footer(); break; case 'download': // Check that user has permission to access this file if (!$repo->file_is_accessible($fileurl)) { print_error('storedfilecannotread'); } $record = new stdClass(); $reference = $repo->get_file_reference($fileurl); $sourcefield = $repo->get_file_source_info($fileurl); $record->source = repository::build_source_field($sourcefield); // If file is already a reference, set $fileurl = file source, $repo = file repository // note that in this case user may not have permission to access the source file directly // so no file_browser/file_info can be used below if ($repo->has_moodle_files()) { $file = repository::get_moodle_file($reference); if ($file && $file->is_external_file()) { $sourcefield = $file->get_source(); // remember the original source $record->source = $repo::build_source_field($sourcefield); $reference = $file->get_reference(); $repo_id = $file->get_repository_id(); $repo = repository::get_repository_by_id($repo_id, $contextid, $repooptions); } } $record->filepath = $savepath;