MDL-31071 blocks: replace deprecated file_encode_url
Signed-off-by: Daniel Ziegenberg <[email protected]>
This commit is contained in:
@@ -24,6 +24,9 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core\output\html_writer;
|
||||
use core\url;
|
||||
|
||||
class block_private_files_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
@@ -78,8 +81,16 @@ class block_private_files_renderer extends plugin_renderer_base {
|
||||
}
|
||||
}
|
||||
foreach ($dir['files'] as $file) {
|
||||
$url = file_encode_url("$CFG->wwwroot/pluginfile.php", '/'.$tree->context->id.'/user/private'.$file->get_filepath().$file->get_filename(), true);
|
||||
$filename = $file->get_filename();
|
||||
$url = url::make_pluginfile_url(
|
||||
contextid: $tree->context->id,
|
||||
component: 'user',
|
||||
area: 'private',
|
||||
itemid: null,
|
||||
pathname: $file->get_filepath(),
|
||||
filename: $filename,
|
||||
forcedownload: true
|
||||
)->out();
|
||||
$image = $this->output->pix_icon(file_file_icon($file), '');
|
||||
$result .= '<li role="treeitem">'.html_writer::link($url, $image.$filename, ['tabindex' => -1]).'</li>';
|
||||
}
|
||||
|
||||
@@ -26,3 +26,5 @@ Feature: The private files block allows users to store files privately in moodle
|
||||
And I upload "blocks/private_files/tests/fixtures/testfile.txt" file to "Files" filemanager
|
||||
And I press "Save changes"
|
||||
Then I should see "testfile.txt" in the "Private files" "block"
|
||||
And following "testfile.txt" should download a file that:
|
||||
| contains text | This is a test file |
|
||||
|
||||
@@ -24,3 +24,5 @@ Feature: The private files block allows users to store files privately in moodle
|
||||
And I upload "blocks/private_files/tests/fixtures/testfile.txt" file to "Files" filemanager
|
||||
And I press "Save changes"
|
||||
Then I should see "testfile.txt" in the "Private files" "block"
|
||||
And following "testfile.txt" should download a file that:
|
||||
| contains text | This is a test file |
|
||||
|
||||
@@ -18,3 +18,5 @@ Feature: The private files block allows users to store files privately in moodle
|
||||
And I upload "blocks/private_files/tests/fixtures/testfile.txt" file to "Files" filemanager
|
||||
And I press "Save changes"
|
||||
Then I should see "testfile.txt" in the "Private files" "block"
|
||||
And following "testfile.txt" should download a file that:
|
||||
| contains text | This is a test file |
|
||||
|
||||
@@ -30,3 +30,5 @@ Feature: The private files block allows users to store files privately in moodle
|
||||
And I upload "blocks/private_files/tests/fixtures/testfile.txt" file to "Files" filemanager
|
||||
And I press "Save changes"
|
||||
Then I should see "testfile.txt" in the "Private files" "block"
|
||||
And following "testfile.txt" should download a file that:
|
||||
| contains text | This is a test file |
|
||||
|
||||
Reference in New Issue
Block a user