Skip to content

Commit

Permalink
Merge branch 'MDL-28099_wip' of git://github.com/jamiepratt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jun 30, 2011
2 parents 7ace3a2 + 5b5206e commit f9d2eb4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/form/filepicker.php
Expand Up @@ -112,9 +112,13 @@ function toHtml() {
function exportValue(&$submitValues, $assoc = false) {
global $USER;

$draftitemid = $this->_findValue($submitValues);
if (null === $draftitemid) {
$draftitemid = $this->getValue();
}

// make sure max one file is present and it is not too big
if (!empty($submitValues[$this->_attributes['name']])) {
$draftitemid = $submitValues[$this->_attributes['name']];
if (!is_null($draftitemid)) {
$fs = get_file_storage();
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) {
Expand All @@ -128,10 +132,8 @@ function exportValue(&$submitValues, $assoc = false) {
$file->delete();
}
}
return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]);
} else {
return null;
}

return $this->_prepareValue($draftitemid, true);
}
}

0 comments on commit f9d2eb4

Please sign in to comment.