]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13766 fixed some obvious problems with missing global $CFG and undefined variables
authorskodak <skodak>
Tue, 11 Aug 2009 09:40:59 +0000 (09:40 +0000)
committerskodak <skodak>
Tue, 11 Aug 2009 09:40:59 +0000 (09:40 +0000)
lib/form/editor.php
lib/form/filemanager.php
lib/form/filepicker.php

index 0f47db13f446bdda13c3d25eaffcd9625a8dde56..1da0ec0b4699ec0a655b49f0cc81ac115f8a1679 100644 (file)
@@ -1,6 +1,9 @@
-<?php  // $Id$
+<?php
+
+global $CFG;
 
 require_once('HTML/QuickForm/element.php');
+require_once($CFG->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) {
index f12dc563a0ce5676818085f96da208ce140da3ef..ebb27a05fef5a8b4ae18680db96d8f6b4797581b 100644 (file)
@@ -1,7 +1,9 @@
-<?php  // $Id$
+<?php
+
+global $CFG;
 
 require_once('HTML/QuickForm/element.php');
-require_once(dirname(dirname(dirname(__FILE__))) . '/lib/filelib.php');
+require_once($CFG->dirroot.'/lib/filelib.php');
 
 class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
     protected $_helpbutton = '';
index 427683829d53be40dbf8d0f7662f12c926934c74..94b50943204d4b313b3d69d25ec564609208b48e 100644 (file)
@@ -1,8 +1,9 @@
 <?php
-// $Id$
+
+global $CFG;
 
 require_once("HTML/QuickForm/button.php");
-require_once(dirname(dirname(dirname(__FILE__))) . '/repository/lib.php');
+require_once($CFG->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 .= '<input type="hidden" name="'.$elname.'" id="'.$id.'" '.$draftvalue.' />';
         $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 .= <<<EOD
 <a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$client_id', '$id', '$draftvalue')">$straddfile</a>
@@ -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