Home
Documentation
Downloads
Demo
Tracker
Development
Translation
Moodle.net
Search
projects
/
moodle.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d71b79a
)
MDL-33948 file_save_draft_area_files() validates if references are allowed and allows...
author
Marina Glancy
<marina@moodle.com>
Tue, 26 Jun 2012 03:40:08 +0000
(11:40 +0800)
committer
Marina Glancy
<marina@moodle.com>
Mon, 2 Jul 2012 06:11:55 +0000
(14:11 +0800)
lib/filelib.php
patch
|
blob
|
blame
|
history
diff --git
a/lib/filelib.php
b/lib/filelib.php
index
e814fee
..
523c643
100644
(file)
--- a/
lib/filelib.php
+++ b/
lib/filelib.php
@@
-721,9
+721,16
@@
function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
if (!isset($options['maxfiles'])) {
$options['maxfiles'] = -1; // unlimited
}
if (!isset($options['maxfiles'])) {
$options['maxfiles'] = -1; // unlimited
}
- if (!isset($options['maxbytes'])) {
+ if (!isset($options['maxbytes'])
|| $options['maxbytes'] == USER_CAN_IGNORE_FILE_SIZE_LIMITS
) {
$options['maxbytes'] = 0; // unlimited
}
$options['maxbytes'] = 0; // unlimited
}
+ $allowreferences = true;
+ if (isset($options['return_types']) && !($options['return_types'] & FILE_REFERENCE)) {
+ // we assume that if $options['return_types'] is NOT specified, we DO allow references.
+ // this is not exactly right. BUT there are many places in code where filemanager options
+ // are not passed to file_save_draft_area_files()
+ $allowreferences = false;
+ }
$draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id');
$oldfiles = $fs->get_area_files($contextid, $component, $filearea, $itemid, 'id');
$draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id');
$oldfiles = $fs->get_area_files($contextid, $component, $filearea, $itemid, 'id');
@@
-755,6
+762,9
@@
function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
}
if ($file->is_external_file()) {
}
if ($file->is_external_file()) {
+ if (!$allowreferences) {
+ continue;
+ }
$repoid = $file->get_repository_id();
if (!empty($repoid)) {
$file_record['repositoryid'] = $repoid;
$repoid = $file->get_repository_id();
if (!empty($repoid)) {
$file_record['repositoryid'] = $repoid;
@@
-856,6
+866,9
@@
function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
}
if ($file->is_external_file()) {
}
if ($file->is_external_file()) {
+ if (!$allowreferences) {
+ continue;
+ }
$repoid = $file->get_repository_id();
if (!empty($repoid)) {
$file_record['repositoryid'] = $repoid;
$repoid = $file->get_repository_id();
if (!empty($repoid)) {
$file_record['repositoryid'] = $repoid;