mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-33445 Added file size check to files inserted by reference
This commit is contained in:
parent
2dfa16ef8a
commit
9945ec5e13
@ -254,21 +254,24 @@ switch ($action) {
|
||||
$event['existingfile']->filepath = $saveas_path;
|
||||
$event['existingfile']->filename = $saveas_filename;
|
||||
$event['existingfile']->url = moodle_url::make_draftfile_url($itemid, $saveas_path, $saveas_filename)->out();;
|
||||
echo json_encode($event);
|
||||
die;
|
||||
} else {
|
||||
$storedfile = $fs->create_file_from_reference($record, $repo_id, $reference);
|
||||
$event = array(
|
||||
'url'=>moodle_url::make_draftfile_url($storedfile->get_itemid(), $storedfile->get_filepath(), $storedfile->get_filename())->out(),
|
||||
'id'=>$storedfile->get_itemid(),
|
||||
'file'=>$storedfile->get_filename(),
|
||||
'icon' => $OUTPUT->pix_url(file_file_icon($storedfile, 32))->out(),
|
||||
);
|
||||
}
|
||||
if ($maxbytes !== -1 && $storedfile->get_filesize() > $maxbytes) {
|
||||
$storedfile->delete();
|
||||
throw new file_exception('maxbytes');
|
||||
}
|
||||
$storedfile = $fs->create_file_from_reference($record, $repo_id, $reference);
|
||||
// Repository plugin callback
|
||||
// You can cache reository file in this callback
|
||||
// or complete other tasks.
|
||||
$repo->cache_file_by_reference($reference, $storedfile);
|
||||
$info = array(
|
||||
'url'=>moodle_url::make_draftfile_url($storedfile->get_itemid(), $storedfile->get_filepath(), $storedfile->get_filename())->out(),
|
||||
'id'=>$storedfile->get_itemid(),
|
||||
'file'=>$storedfile->get_filename(),
|
||||
'icon' => $OUTPUT->pix_url(file_file_icon($storedfile, 32))->out(),
|
||||
);
|
||||
echo json_encode($info);
|
||||
echo json_encode($event);
|
||||
die;
|
||||
} else if ($repo->has_moodle_files()) {
|
||||
// Some repository plugins (local, user, coursefiles, recent) are hosting moodle
|
||||
|
Loading…
x
Reference in New Issue
Block a user