| Línea 611... |
Línea 611... |
| 611 |
* @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime)
|
611 |
* @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime)
|
| 612 |
* @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
|
612 |
* @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
|
| 613 |
* @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
|
613 |
* @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
|
| 614 |
* @param array $options additional options affecting the file serving
|
614 |
* @param array $options additional options affecting the file serving
|
| 615 |
*/
|
615 |
*/
|
| 616 |
public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) {
|
616 |
public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) {
|
| 617 |
$reference = $storedfile->get_reference();
|
617 |
$reference = $storedfile->get_reference();
|
| 618 |
$file = $this->get_rootpath() . ltrim($reference, '/');
|
618 |
$file = $this->get_rootpath() . ltrim($reference, '/');
|
| 619 |
if ($this->is_in_repository($reference) && is_readable($file)) {
|
619 |
if ($this->is_in_repository($reference) && is_readable($file)) {
|
| 620 |
$filename = $storedfile->get_filename();
|
620 |
$filename = $storedfile->get_filename();
|
| 621 |
if ($options && isset($options['filename'])) {
|
621 |
if ($options && isset($options['filename'])) {
|
| 622 |
$filename = $options['filename'];
|
622 |
$filename = $options['filename'];
|
| 623 |
}
|
623 |
}
|
| 624 |
$dontdie = ($options && isset($options['dontdie']));
|
624 |
$dontdie = ($options && isset($options['dontdie']));
|
| - |
|
625 |
// If the file is linked to the original then we should not cache it.
|
| - |
|
626 |
$lifetime = 0;
|
| 625 |
send_file($file, $filename, $lifetime , $filter, false, $forcedownload, '', $dontdie);
|
627 |
send_file($file, $filename, $lifetime , $filter, false, $forcedownload, '', $dontdie);
|
| 626 |
} else {
|
628 |
} else {
|
| 627 |
send_file_not_found();
|
629 |
send_file_not_found();
|
| 628 |
}
|
630 |
}
|
| 629 |
}
|
631 |
}
|