From: skodak Date: Tue, 11 Aug 2009 09:40:59 +0000 (+0000) Subject: MDL-13766 fixed some obvious problems with missing global $CFG and undefined variables X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ae4a98a108e7e9464ad47f0ded7b0b1d69d172be;p=moodle.git MDL-13766 fixed some obvious problems with missing global $CFG and undefined variables --- diff --git a/lib/form/editor.php b/lib/form/editor.php index 0f47db13f4..1da0ec0b46 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -1,6 +1,9 @@ -dirroot.'/lib/filelib.php'); //TODO: // * locking @@ -15,7 +18,6 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element { function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG; - require_once("$CFG->dirroot/repository/lib.php"); $options = (array)$options; foreach ($options as $name=>$value) { diff --git a/lib/form/filemanager.php b/lib/form/filemanager.php index f12dc563a0..ebb27a05fe 100644 --- a/lib/form/filemanager.php +++ b/lib/form/filemanager.php @@ -1,7 +1,9 @@ -dirroot.'/lib/filelib.php'); class MoodleQuickForm_filemanager extends HTML_QuickForm_element { protected $_helpbutton = ''; diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php index 427683829d..94b5094320 100644 --- a/lib/form/filepicker.php +++ b/lib/form/filepicker.php @@ -1,8 +1,9 @@ dirroot.'/repository/lib.php'); /** * HTML class for a single filepicker element (based on button) @@ -72,13 +73,13 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { $straddfile = get_string('openpicker', 'repository'); $currentfile = ''; $draftvalue = ''; - if ($draftid = (int)$this->getValue()) { + if ($draftitemid = (int)$this->getValue()) { $fs = get_file_storage(); $usercontext = get_context_instance(CONTEXT_USER, $USER->id); - if ($files = $fs->get_area_files($usercontext->id, 'user_draft', $draftid, 'id DESC', false)) { + if ($files = $fs->get_area_files($usercontext->id, 'user_draft', $draftitemid, 'id DESC', false)) { $file = reset($files); $currentfile = $file->get_filename(); - $draftvalue = 'value="'.$draftid.'"'; + $draftvalue = 'value="'.$draftitemid.'"'; } } if ($COURSE->id == SITEID) { @@ -96,7 +97,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { $str .= ''; $str .= $repojs; - $str .= $PAGE->requires->data_for_js('filepicker', Array('maxbytes'=>$this->_options['maxbytes'],'maxfiles'=>$this->_options['maxfiles']))->asap(); + $str .= $PAGE->requires->data_for_js('filepicker', Array('maxbytes'=>$this->_options['maxbytes'],'maxfiles'=>1))->asap(); $str .= $PAGE->requires->js('lib/form/filepicker.js')->asap(); $str .= <<$straddfile @@ -113,10 +114,10 @@ EOD; global $USER; // make sure max one file is present and it is not too big - if ($draftid = $submitValues[$this->_attributes['name']]) { + if ($draftitemid = $submitValues[$this->_attributes['name']]) { $fs = get_file_storage(); $usercontext = get_context_instance(CONTEXT_USER, $USER->id); - if ($files = $fs->get_area_files($usercontext->id, 'user_draft', $draftid, 'id DESC', false)) { + if ($files = $fs->get_area_files($usercontext->id, 'user_draft', $draftitemid, 'id DESC', false)) { $file = array_shift($files); if ($this->_options['maxbytes'] and $file->get_filesize() > $this->_options['maxbytes']) { // bad luck, somebody tries to sneak in oversized file