Skip to content
Snippets Groups Projects
Commit 67303346 authored by hendrik.donath's avatar hendrik.donath
Browse files

moved the query for comments into a section that is always about a comment,...

moved the query for comments into a section that is always about a comment, check if id is an int value
parent 14b401b5
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
......@@ -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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment