MDL-32471 preview thumbnails support for activity modules
Activity module's xxx_pluginfile() now accepts the $options parameter that is to be passed to the send_stored_file() function.
This commit is contained in:
+2
-2
@@ -3946,10 +3946,10 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {
|
||||
$filefunctionold = $modname.'_pluginfile';
|
||||
if (function_exists($filefunction)) {
|
||||
// if the function exists, it must send the file and terminate. Whatever it returns leads to "not found"
|
||||
$filefunction($course, $cm, $context, $filearea, $args, $forcedownload);
|
||||
$filefunction($course, $cm, $context, $filearea, $args, $forcedownload, array('preview' => $preview));
|
||||
} else if (function_exists($filefunctionold)) {
|
||||
// if the function exists, it must send the file and terminate. Whatever it returns leads to "not found"
|
||||
$filefunctionold($course, $cm, $context, $filearea, $args, $forcedownload);
|
||||
$filefunctionold($course, $cm, $context, $filearea, $args, $forcedownload, array('preview' => $preview));
|
||||
}
|
||||
|
||||
send_file_not_found();
|
||||
|
||||
@@ -1971,11 +1971,15 @@ class assignment_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a file
|
||||
*
|
||||
* @param string $filearea
|
||||
* @param array $args
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool
|
||||
*/
|
||||
function send_file($filearea, $args) {
|
||||
function send_file($filearea, $args, $forcedownload, array $options=array()) {
|
||||
debugging('plugin does not implement file sending', DEBUG_DEVELOPER);
|
||||
return false;
|
||||
}
|
||||
@@ -3079,9 +3083,10 @@ function assignment_get_participants($assignmentid) {
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - just send the file
|
||||
*/
|
||||
function assignment_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function assignment_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -3098,7 +3103,7 @@ function assignment_pluginfile($course, $cm, $context, $filearea, $args, $forced
|
||||
$assignmentclass = 'assignment_'.$assignment->assignmenttype;
|
||||
$assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course);
|
||||
|
||||
return $assignmentinstance->send_file($filearea, $args);
|
||||
return $assignmentinstance->send_file($filearea, $args, $forcedownload, $options);
|
||||
}
|
||||
/**
|
||||
* Checks if a scale is being used by an assignment
|
||||
|
||||
@@ -375,7 +375,7 @@ class assignment_online extends assignment_base {
|
||||
}
|
||||
}
|
||||
|
||||
public function send_file($filearea, $args) {
|
||||
public function send_file($filearea, $args, $forcedownload, $options) {
|
||||
global $USER;
|
||||
require_capability('mod/assignment:view', $this->context);
|
||||
|
||||
@@ -391,7 +391,8 @@ class assignment_online extends assignment_base {
|
||||
}
|
||||
|
||||
session_get_instance()->write_close(); // unlock session during fileserving
|
||||
send_stored_file($file, 60*60, 0, true);
|
||||
|
||||
send_stored_file($file, 60*60, 0, true, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
This file describes changes in the assignment type API and DB structures.
|
||||
Information provided here is intended especially for developers.
|
||||
|
||||
=== 2.3 ===
|
||||
|
||||
API changes:
|
||||
* send_file() methods now accept $forcedownload and $options parameters
|
||||
@@ -614,7 +614,7 @@ class assignment_upload extends assignment_base {
|
||||
die;
|
||||
}
|
||||
|
||||
function send_file($filearea, $args) {
|
||||
function send_file($filearea, $args, $forcedownload, $options) {
|
||||
global $CFG, $DB, $USER;
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
@@ -638,7 +638,8 @@ class assignment_upload extends assignment_base {
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
return false;
|
||||
}
|
||||
send_stored_file($file, 0, 0, true); // download MUST be forced - security!
|
||||
|
||||
send_stored_file($file, 0, 0, true, $options); // download MUST be forced - security!
|
||||
|
||||
} else if ($filearea === 'response') {
|
||||
$submissionid = (int)array_shift($args);
|
||||
@@ -658,7 +659,7 @@ class assignment_upload extends assignment_base {
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
return false;
|
||||
}
|
||||
send_stored_file($file, 0, 0, true);
|
||||
send_stored_file($file, 0, 0, true, $options);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -300,7 +300,7 @@ class assignment_uploadsingle extends assignment_base {
|
||||
return true;
|
||||
}
|
||||
|
||||
function send_file($filearea, $args) {
|
||||
function send_file($filearea, $args, $forcedownload, $options) {
|
||||
global $CFG, $DB, $USER;
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
@@ -329,7 +329,7 @@ class assignment_uploadsingle extends assignment_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
send_stored_file($file, 0, 0, true); // download MUST be forced - security!
|
||||
send_stored_file($file, 0, 0, true, $options); // download MUST be forced - security!
|
||||
}
|
||||
|
||||
function extend_settings_navigation($node) {
|
||||
|
||||
+3
-2
@@ -2963,9 +2963,10 @@ function mod_data_get_file_info($browser, $areas, $course, $cm, $context, $filea
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function data_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function data_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -3028,7 +3029,7 @@ function data_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 0, 0, true); // download MUST be forced - security!
|
||||
send_stored_file($file, 0, 0, true, $options); // download MUST be forced - security!
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -182,9 +182,10 @@ function feedback_update_instance($feedback) {
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function feedback_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function feedback_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($filearea === 'item' or $filearea === 'template') {
|
||||
@@ -273,7 +274,7 @@ function feedback_pluginfile($course, $cm, $context, $filearea, $args, $forcedow
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 0, 0, true); // download MUST be forced - security!
|
||||
send_stored_file($file, 0, 0, true, $options); // download MUST be forced - security!
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-2
@@ -293,9 +293,10 @@ function folder_get_file_info($browser, $areas, $course, $cm, $context, $fileare
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - just send the file
|
||||
*/
|
||||
function folder_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function folder_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -323,7 +324,7 @@ function folder_pluginfile($course, $cm, $context, $filearea, $args, $forcedownl
|
||||
|
||||
// finally send the file
|
||||
// for folder module, we force download file all the time
|
||||
send_stored_file($file, 86400, 0, true);
|
||||
send_stored_file($file, 86400, 0, true, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -4108,9 +4108,10 @@ function forum_get_file_info($browser, $areas, $course, $cm, $context, $filearea
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function forum_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function forum_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -4162,9 +4163,8 @@ function forum_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 0, 0, true); // download MUST be forced - security!
|
||||
send_stored_file($file, 0, 0, true, $options); // download MUST be forced - security!
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1538,9 +1538,10 @@ function mod_glossary_get_file_info($browser, $areas, $course, $cm, $context, $f
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function glossary_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function glossary_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -1590,7 +1591,7 @@ function glossary_pluginfile($course, $cm, $context, $filearea, $args, $forcedow
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 0, 0, true); // download MUST be forced - security!
|
||||
send_stored_file($file, 0, 0, true, $options); // download MUST be forced - security!
|
||||
|
||||
} else if ($filearea === 'export') {
|
||||
require_login($course, false, $cm);
|
||||
|
||||
+4
-3
@@ -337,9 +337,10 @@ function imscp_get_file_info($browser, $areas, $course, $cm, $context, $filearea
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function imscp_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function imscp_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -367,7 +368,7 @@ function imscp_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 86400, 0, $forcedownload);
|
||||
send_stored_file($file, 86400, 0, $forcedownload, $options);
|
||||
|
||||
} else if ($filearea === 'backup') {
|
||||
if (!has_capability('moodle/course:managefiles', $context)) {
|
||||
@@ -383,7 +384,7 @@ function imscp_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 86400, 0, $forcedownload);
|
||||
send_stored_file($file, 86400, 0, $forcedownload, $options);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+3
-2
@@ -876,9 +876,10 @@ function lesson_get_import_export_formats($type) {
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function lesson_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function lesson_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -917,7 +918,7 @@ function lesson_pluginfile($course, $cm, $context, $filearea, $args, $forcedownl
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 0, 0, $forcedownload); // download MUST be forced - security!
|
||||
send_stored_file($file, 0, 0, $forcedownload, $options); // download MUST be forced - security!
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -360,9 +360,10 @@ function page_get_file_info($browser, $areas, $course, $cm, $context, $filearea,
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - just send the file
|
||||
*/
|
||||
function page_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function page_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
require_once("$CFG->libdir/resourcelib.php");
|
||||
|
||||
@@ -418,7 +419,7 @@ function page_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 86400, 0, $forcedownload);
|
||||
send_stored_file($file, 86400, 0, $forcedownload, $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -1655,9 +1655,10 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -1687,7 +1688,7 @@ function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
return false;
|
||||
}
|
||||
send_stored_file($file, 0, 0, true);
|
||||
send_stored_file($file, 0, 0, true, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1704,10 +1705,11 @@ function quiz_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
* @param int $slot the id of a question in this quiz attempt.
|
||||
* @param array $args the remaining bits of the file path.
|
||||
* @param bool $forcedownload whether the user must be forced to download the file.
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - justsend the file
|
||||
*/
|
||||
function mod_quiz_question_pluginfile($course, $context, $component,
|
||||
$filearea, $qubaid, $slot, $args, $forcedownload) {
|
||||
$filearea, $qubaid, $slot, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
|
||||
@@ -1739,7 +1741,7 @@ function mod_quiz_question_pluginfile($course, $context, $component,
|
||||
send_file_not_found();
|
||||
}
|
||||
|
||||
send_stored_file($file, 0, 0, $forcedownload);
|
||||
send_stored_file($file, 0, 0, $forcedownload, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -382,9 +382,10 @@ function resource_get_file_info($browser, $areas, $course, $cm, $context, $filea
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - just send the file
|
||||
*/
|
||||
function resource_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function resource_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG, $DB;
|
||||
require_once("$CFG->libdir/resourcelib.php");
|
||||
|
||||
@@ -443,7 +444,7 @@ function resource_pluginfile($course, $cm, $context, $filearea, $args, $forcedow
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, 86400, $filter, $forcedownload);
|
||||
send_stored_file($file, 86400, $filter, $forcedownload, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -927,9 +927,10 @@ function scorm_get_file_info($browser, $areas, $course, $cm, $context, $filearea
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if file not found, does not return if found - just send the file
|
||||
*/
|
||||
function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -968,7 +969,7 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, $lifetime, 0, false);
|
||||
send_stored_file($file, $lifetime, 0, false, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,9 @@ information provided here is intended especially for developers.
|
||||
required changes in code:
|
||||
* define the capability mod/xxx:addinstance (and the corresponding lang string)
|
||||
(unless your mod is a MOD_ARCHETYPE_SYSTEM).
|
||||
* xxx_pluginfile() is now given the 7th parameter (hopefully the last one) that
|
||||
contains additional options for the file serving. The array should be re-passed
|
||||
to send_stored_file().
|
||||
|
||||
|
||||
=== 2.2 ===
|
||||
|
||||
+4
-2
@@ -445,8 +445,10 @@ function wiki_scale_used_anywhere($scaleid) {
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if the file was not found, just send the file otherwise and do not return anything
|
||||
*/
|
||||
function wiki_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
|
||||
function wiki_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
|
||||
global $CFG;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -477,7 +479,7 @@ function wiki_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa
|
||||
|
||||
$lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
|
||||
|
||||
send_stored_file($file, $lifetime, 0);
|
||||
send_stored_file($file, $lifetime, 0, $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,10 @@ require_once($CFG->libdir . '/gradelib.php'); // to handle float vs de
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool
|
||||
*/
|
||||
function workshopform_accumulative_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
|
||||
function workshopform_accumulative_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()) {
|
||||
global $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -72,7 +73,7 @@ function workshopform_accumulative_pluginfile($course, $cm, $context, $filearea,
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file);
|
||||
send_stored_file($file, 0, 0, $forcedownload, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,9 +38,10 @@ require_once($CFG->libdir . '/gradelib.php'); // to handle float vs de
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool
|
||||
*/
|
||||
function workshopform_comments_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
|
||||
function workshopform_comments_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()) {
|
||||
global $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -72,7 +73,7 @@ function workshopform_comments_pluginfile($course, $cm, $context, $filearea, arr
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file);
|
||||
send_stored_file($file, 0, 0, $forcedownload, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,9 +38,10 @@ require_once($CFG->libdir . '/gradelib.php'); // to handle float vs de
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool
|
||||
*/
|
||||
function workshopform_numerrors_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
|
||||
function workshopform_numerrors_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()) {
|
||||
global $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -72,7 +73,7 @@ function workshopform_numerrors_pluginfile($course, $cm, $context, $filearea, ar
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file);
|
||||
send_stored_file($file, 0, 0, $forcedownload, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,9 +38,10 @@ require_once($CFG->libdir . '/gradelib.php'); // to handle float vs de
|
||||
* @param string $filearea file area
|
||||
* @param array $args extra arguments
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool
|
||||
*/
|
||||
function workshopform_rubric_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
|
||||
function workshopform_rubric_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()) {
|
||||
global $DB;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -72,7 +73,7 @@ function workshopform_rubric_pluginfile($course, $cm, $context, $filearea, array
|
||||
}
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file);
|
||||
send_stored_file($file, 0, 0, $forcedownload, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+13
-12
@@ -1221,15 +1221,16 @@ function workshop_get_file_areas($course, $cm, $context) {
|
||||
* @package mod_workshop
|
||||
* @category files
|
||||
*
|
||||
* @param stdClass $course
|
||||
* @param stdClass $cm
|
||||
* @param stdClass $context
|
||||
* @param string $filearea
|
||||
* @param array $args
|
||||
* @param bool $forcedownload
|
||||
* @return void this should never return to the caller
|
||||
* @param stdClass $course the course object
|
||||
* @param stdClass $cm the course module object
|
||||
* @param stdClass $context the workshop's context
|
||||
* @param string $filearea the name of the file area
|
||||
* @param array $args extra arguments (itemid, path)
|
||||
* @param bool $forcedownload whether or not force download
|
||||
* @param array $options additional options affecting the file serving
|
||||
* @return bool false if the file not found, just send the file otherwise and do not return anything
|
||||
*/
|
||||
function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) {
|
||||
function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()) {
|
||||
global $DB, $CFG;
|
||||
|
||||
if ($context->contextlevel != CONTEXT_MODULE) {
|
||||
@@ -1246,7 +1247,7 @@ function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $fo
|
||||
|
||||
array_shift($args); // we do not use itemids here
|
||||
$relativepath = implode('/', $args);
|
||||
$fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath"; // beware, slashes are not used here!
|
||||
$fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath";
|
||||
|
||||
$fs = get_file_storage();
|
||||
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
|
||||
@@ -1256,7 +1257,7 @@ function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $fo
|
||||
$lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, $lifetime, 0);
|
||||
send_stored_file($file, $lifetime, 0, $forcedownload, $options);
|
||||
}
|
||||
|
||||
if ($filearea === 'instructreviewers') {
|
||||
@@ -1277,7 +1278,7 @@ function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $fo
|
||||
$lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
|
||||
|
||||
// finally send the file
|
||||
send_stored_file($file, $lifetime, 0);
|
||||
send_stored_file($file, $lifetime, 0, $forcedownload, $options);
|
||||
|
||||
} else if ($filearea === 'submission_content' or $filearea === 'submission_attachment') {
|
||||
$itemid = (int)array_shift($args);
|
||||
@@ -1296,7 +1297,7 @@ function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $fo
|
||||
}
|
||||
// finally send the file
|
||||
// these files are uploaded by students - forcing download for security reasons
|
||||
send_stored_file($file, 0, 0, true);
|
||||
send_stored_file($file, 0, 0, true, $options);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user