MDL-55289 workshop: Include repository/lib.php to use its constants
authorDavid Mudrák <david@moodle.com>
Mon, 25 Jul 2016 17:30:30 +0000 (19:30 +0200)
committerDavid Mudrák <david@moodle.com>
Thu, 28 Jul 2016 07:51:16 +0000 (09:51 +0200)
As a result of MDL-41556 (146893d6), the repository/lib.php was included
in submission.php so that its constant FILE_INTERNAL could be used in
field options. Recent development in MDL-50794 (996f7e8) moved the
options declaration to standalone methods but we forgot to check they
work in exsubmission.php too.

This patch moves the repository/lib.php inclusion to where the
library is actually needed.

Additionally it unifies how options are set for overall feedback content
and overall feedback attachment fields.

mod/workshop/locallib.php
mod/workshop/submission.php

index b26d56a..d074add 100644 (file)
@@ -2486,6 +2486,9 @@ class workshop {
      * @return array
      */
     public function submission_content_options() {
+        global $CFG;
+        require_once($CFG->dirroot.'/repository/lib.php');
+
         return array(
             'trusttext' => true,
             'subdirs' => false,
@@ -2502,6 +2505,8 @@ class workshop {
      * @return array
      */
     public function submission_attachment_options() {
+        global $CFG;
+        require_once($CFG->dirroot.'/repository/lib.php');
 
         $options = array(
             'subdirs' => true,
@@ -2523,12 +2528,16 @@ class workshop {
      * @return array
      */
     public function overall_feedback_content_options() {
+        global $CFG;
+        require_once($CFG->dirroot.'/repository/lib.php');
+
         return array(
             'subdirs' => 0,
             'maxbytes' => $this->overallfeedbackmaxbytes,
             'maxfiles' => $this->overallfeedbackfiles,
             'changeformat' => 1,
             'context' => $this->context,
+            'return_types' => FILE_INTERNAL,
         );
     }
 
@@ -2538,6 +2547,8 @@ class workshop {
      * @return array
      */
     public function overall_feedback_attachment_options() {
+        global $CFG;
+        require_once($CFG->dirroot.'/repository/lib.php');
 
         $options = array(
             'subdirs' => 1,
index 3d7e1fb..6fc9724 100644 (file)
@@ -25,7 +25,6 @@
 
 require(__DIR__.'/../../config.php');
 require_once(__DIR__.'/locallib.php');
-require_once($CFG->dirroot . '/repository/lib.php');
 
 $cmid = required_param('cmid', PARAM_INT); // Course module id.
 $id = optional_param('id', 0, PARAM_INT); // Submission id.