Thanks Sam for the response. I do have that function in the lib.php file, and I've pasted it below. Perhaps I don't understand that function really well, since I copied the code from one of the plugins last year.
function groupwork_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options = array()) {
global $CFG, $DB;
require_once("$CFG->libdir/resourcelib.php");
if ($context->contextlevel != CONTEXT_MODULE) {
return false;
}
require_course_login($course, true, $cm);
if (!has_capability('mod/groupwork:view', $context)) {
return false;
}
if ($filearea !== 'content' && $filearea !== 'attachment') {
// intro is handled automatically in pluginfile.php
return false;
}
// $arg could be revision number or index.html
$arg = array_shift($args);
if ($arg == 'index.html' || $arg == 'index.htm') {
// serve page content
$filename = $arg;
if (!$groupwork = $DB->get_record('groupwork', array('id' => $cm->instance), '*', MUST_EXIST)) {
return false;
}
// remove https://moodle.org/pluginfile.php/114/mod_forum/post/1466119/
$content = str_replace('https://moodle.org/pluginfile.php/114/mod_forum/post/1466119/', '', $groupwork->content);
$formatoptions = new stdClass;
$formatoptions->noclean = true;
$formatoptions->overflowdiv = true;
$formatoptions->context = $context;
$content = format_text($content, $groupwork->contentformat, $formatoptions);
send_file($content, $filename, 0, 0, true, true);
} else {
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/$context->id/mod_groupwork/$filearea/0/$relativepath";
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
// $groupwork = $DB->get_record('groupwork', array('id' => $cm->instance), 'id, legacyfiles', MUST_EXIST);
// if ($groupwork->legacyfiles != RESOURCELIB_LEGACYFILES_ACTIVE) {
// return false;
//}
if (!$file = resourcelib_try_file_migration('/' . $relativepath, $cm->id, $cm->course, 'mod_groupwork', 'content', 0)) {
return false;
}
//file migrate - update flag
// $groupwork->legacyfileslast = time();
$DB->update_record('groupwork', $groupwork);
}
// finally send the file
send_stored_file($file, null, 0, $forcedownload, $options);
}