MDL-19002 file size limits in filepicker + improved options
This commit is contained in:
@@ -5,9 +5,9 @@ require_once(dirname(dirname(dirname(__FILE__))) . '/lib/filelib.php');
|
||||
|
||||
class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
|
||||
protected $_helpbutton = '';
|
||||
protected $_options = array('subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>-1);
|
||||
protected $_options = array('subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>-1, 'filetypes'=>'*', 'returnvalue'=>'*');
|
||||
|
||||
function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $options=null, $attributes=null) {
|
||||
function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
|
||||
global $CFG;
|
||||
|
||||
$options = (array)$options;
|
||||
@@ -16,16 +16,6 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
|
||||
$this->_options[$name] = $value;
|
||||
}
|
||||
}
|
||||
if (!empty($options['filetypes'])) {
|
||||
$this->filetypes = $options['filetypes'];
|
||||
} else {
|
||||
$this->filetypes = '*';
|
||||
}
|
||||
if (!empty($options['returnvalue'])) {
|
||||
$this->returnvalue = $options['returnvalue'];
|
||||
} else {
|
||||
$this->returnvalue = '*';
|
||||
}
|
||||
if (!empty($options['maxbytes'])) {
|
||||
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
|
||||
}
|
||||
|
||||
+15
-5
@@ -13,11 +13,21 @@ require_once(dirname(dirname(dirname(__FILE__))) . '/repository/lib.php');
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
||||
var $_helpbutton='';
|
||||
protected $_helpbutton = '';
|
||||
protected $_options = array('maxbytes'=>0, 'filetypes'=>'*', 'returnvalue'=>'*');
|
||||
|
||||
function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
|
||||
global $CFG;
|
||||
|
||||
function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $filetypes = '*', $returnvalue = '*') {
|
||||
$this->filetypes = $filetypes;
|
||||
$this->returnvalue = $returnvalue;
|
||||
$options = (array)$options;
|
||||
foreach ($options as $name=>$value) {
|
||||
if (array_key_exists($name, $this->_options)) {
|
||||
$this->_options[$name] = $value;
|
||||
}
|
||||
}
|
||||
if (!empty($options['maxbytes'])) {
|
||||
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
|
||||
}
|
||||
parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
|
||||
}
|
||||
|
||||
@@ -73,7 +83,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||
}
|
||||
$client_id = uniqid();
|
||||
$repository_info = repository_get_client($context, $client_id, $this->filetypes, $this->returnvalue);
|
||||
$repository_info = repository_get_client($context, $client_id, $this->_options['filetypes'], $this->_options['returnvalue']);
|
||||
|
||||
$id = $this->_attributes['id'];
|
||||
$elname = $this->_attributes['name'];
|
||||
|
||||
@@ -50,7 +50,7 @@ class mod_forum_post_form extends moodleform {
|
||||
}
|
||||
|
||||
if (!empty($forum->maxattachments) && $forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) { // 1 = No attachments at all
|
||||
$mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'),
|
||||
$mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null,
|
||||
array('subdirs'=>0,
|
||||
'maxbytes'=>$forum->maxbytes,
|
||||
'maxfiles'=>$forum->maxattachments,
|
||||
|
||||
@@ -36,7 +36,7 @@ class mod_glossary_entry_form extends moodleform {
|
||||
$mform->setType('aliases', PARAM_TEXT);
|
||||
$mform->setHelpButton('aliases', array('aliases2', strip_tags(get_string('aliases', 'glossary')), 'glossary'));
|
||||
|
||||
$mform->addElement('filemanager', 'attachment_filemanager', get_string('attachment', 'glossary'), $attachmentoptions);
|
||||
$mform->addElement('filemanager', 'attachment_filemanager', get_string('attachment', 'glossary'), null, $attachmentoptions);
|
||||
$mform->setHelpButton('attachment_filemanager', array('attachment2', get_string('attachment', 'glossary'), 'glossary'));
|
||||
|
||||
if (!$glossary->usedynalink) {
|
||||
|
||||
Reference in New Issue
Block a user