diff --git a/lib.php b/lib.php index 9c36591ede1c8fea95ec82a6b9a8b02c27f9e953..bcd3c4bd060815998cb0ca0b64b650cb021e9e6d 100644 --- a/lib.php +++ b/lib.php @@ -396,19 +396,10 @@ function pdfannotator_pluginfile($course, $cm, $context, $filearea, $args, $forc // Intro is handled automatically in pluginfile.php. return false; } - - $commentid = 0; - foreach ($args as $param) { - if ($DB->record_exists('pdfannotator_comments', ['id' => $param])) { - $commentid = $param; - break; - } - } - array_shift($args); // Ignore revision - designed to prevent caching problems only. - $fs = get_file_storage(); - $relativepath = implode('/', $args); if ($filearea === 'content') { + array_shift($args); // Ignore revision - designed to prevent caching problems only. + $relativepath = implode('/', $args); $fullpath = rtrim("/$context->id/mod_pdfannotator/$filearea/0/$relativepath", '/'); do { if (!$file = $fs->get_file_by_hash(sha1($fullpath))) { @@ -444,6 +435,15 @@ function pdfannotator_pluginfile($course, $cm, $context, $filearea, $args, $forc } if ($filearea === 'post') { + $commentid = 0; + foreach ($args as $param) { + if (filter_var($param, FILTER_VALIDATE_INT) && $DB->record_exists('pdfannotator_comments', ['id' => $param])) { + $commentid = $param; + break; + } + } + array_shift($args); + $relativepath = implode('/', $args); $fullpath = rtrim("/$context->id/mod_pdfannotator/$filearea/$commentid/$relativepath", '/'); if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { //Annotations from other documents might have another contextid. diff --git a/version.php b/version.php index d3b1a565b7e6461259e7e349260bd643b27f0b59..3e4e9294bedbc7d733a3d71460bbf237b7ae4b0c 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_pdfannotator'; -$plugin->version = 2023041100; +$plugin->version = 2023041400; $plugin->release = 'PDF Annotator v1.5 release 3'; $plugin->requires = 2021051700; $plugin->maturity = MATURITY_STABLE;