diff --git a/lib.php b/lib.php index 1031060fa8ec18e59ef5df2a76f544b1472ee5ed..fdce7be6ce1c43772302fe1c72b1c698cbccf27f 100644 --- a/lib.php +++ b/lib.php @@ -375,19 +375,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))) { @@ -425,12 +416,13 @@ function pdfannotator_pluginfile($course, $cm, $context, $filearea, $args, $forc if ($filearea === 'post') { $commentid = 0; foreach ($args as $param) { - if (is_int($param) && $DB->record_exists('pdfannotator_comments', ['id' => $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 cc17a4284f7178968c3522f892ee9502130848f5..3e4e9294bedbc7d733a3d71460bbf237b7ae4b0c 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_pdfannotator'; -$plugin->version = 2022120500; +$plugin->version = 2023041400; $plugin->release = 'PDF Annotator v1.5 release 3'; $plugin->requires = 2021051700; $plugin->maturity = MATURITY_STABLE;