Skip to content

Commit

Permalink
Merge branch 'wip-MDL-33329-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
danpoltawski committed May 24, 2012
2 parents 5744ea3 + 2d7c111 commit 4b0992c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/form/filepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,26 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
* @param array $options set of options to initalize filepicker
*/
function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
global $CFG;
global $CFG, $PAGE;

$options = (array)$options;
foreach ($options as $name=>$value) {
if (array_key_exists($name, $this->_options)) {
$this->_options[$name] = $value;
}
}
if (!empty($options['return_types'])) {
$this->_options['return_types'] = FILE_INTERNAL | FILE_REFERENCE;
if (empty($options['return_types'])) {
$this->_options['return_types'] = FILE_INTERNAL;
}
$fpmaxbytes = 0;
if (!empty($options['maxbytes'])) {
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
$fpmaxbytes = $options['maxbytes'];
}
$coursemaxbytes = 0;
if (!empty($PAGE->course)) {
$coursemaxbytes = $PAGE->course->maxbytes;
}
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $coursemaxbytes, $fpmaxbytes);
$this->_type = 'filepicker';
parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
}
Expand Down Expand Up @@ -143,7 +149,7 @@ function toHtml() {
$args = new stdClass();
// need these three to filter repositories list
$args->accepted_types = $this->_options['accepted_types']?$this->_options['accepted_types']:'*';
$args->return_types = FILE_INTERNAL | FILE_REFERENCE;
$args->return_types = $this->_options['return_types'];
$args->itemid = $draftitemid;
$args->maxbytes = $this->_options['maxbytes'];
$args->context = $PAGE->context;
Expand Down

0 comments on commit 4b0992c

Please sign in to comment.