diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php
index 99993a327df..4c3064e9661 100644
--- a/lib/form/filepicker.php
+++ b/lib/form/filepicker.php
@@ -14,7 +14,13 @@ require_once(dirname(dirname(dirname(__FILE__))) . '/repository/lib.php');
*/
class MoodleQuickForm_filepicker extends HTML_QuickForm_button
{
+ var $_filearea;
var $_helpbutton='';
+
+ function MoodleQuickForm_filepicker($elementName=null, $value=null, $filearea=null, $attributes=null) {
+ parent::HTML_QuickForm_button($elementName, $value, $attributes);
+ $this->_filearea = $filearea;
+ }
function setHelpButton($helpbuttonargs, $function='helpbutton'){
if (!is_array($helpbuttonargs)){
$helpbuttonargs=array($helpbuttonargs);
@@ -55,6 +61,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_button
$str = $this->_getTabs();
$str .= '';
$id = $this->_attributes['id'];
+ $filearea = $this->_filearea;
$str .= <<
function updatefile_$suffix(){
@@ -66,11 +73,12 @@ function callpicker_$suffix(){
picker.id = 'file-picker-$suffix';
document.body.appendChild(picker);
var el=document.getElementById('${id}_${suffix}');
- openpicker_$suffix({"env":"form", 'target':el, 'callback':updatefile_$suffix})
+ openpicker_$suffix({"env":"form", 'target':el, 'callback':updatefile_$suffix, 'filearea':${filearea}})
}
EOD;
// $this->_getAttrString($this->_attributes);
+ $str .= "\n";
$str .= ''.''.$ret['css'].$ret['js'];
return $str;
}
diff --git a/mod/forum/post_form.php b/mod/forum/post_form.php
index ceebe57114f..60d16672726 100644
--- a/mod/forum/post_form.php
+++ b/mod/forum/post_form.php
@@ -16,7 +16,6 @@ class mod_forum_post_form extends moodleform {
$forum = $this->_customdata['forum'];
$post = $this->_customdata['post']; // hack alert
-
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_data
$mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
@@ -54,9 +53,8 @@ class mod_forum_post_form extends moodleform {
}
if ($forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) { // 1 = No attachments at all
- $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
+ $mform->addElement('filepicker', 'attachment', get_string('attachment', 'forum'), 'forum_submission');
$mform->setHelpButton('attachment', array('attachment', get_string('attachment', 'forum'), 'forum'));
-
}
if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) { // hack alert