General developer forum

Trying to approve plugin. Uploading files to 3rd party service using get_file_by_hash from plagiarism plugin.

 
Picture of Eli Rabinovitz
Re: Trying to approve plugin. Uploading files to 3rd party service using get_file_by_hash from plagiarism plugin.
 
Thanks Dan, good idea.

Here is the code:

https://github.com/Copyleaks/moodle-plagiarism_copyleaks/blob/master/lib.php:

$scanurl = new moodle_url('/plagiarism/copyleaks/scan.php',

            array('pathnamehash' => $file->get_pathnamehash(),

                  'cmid' => $cmid));

        $output = html_writer::div(

            html_writer::link($scanurl, html_writer::tag('span',

                html_writer::empty_tag('img',

                    array('src' => $CFG->wwwroot . '/plagiarism/copyleaks/pix/small-logo.png', 'alt' => 'Copyleaks logo')) .

                get_string('copyleaks_report', 'plagiarism_copyleaks'))

                , array('target' => '_blank')));

        return $output;


And https://github.com/Copyleaks/moodle-plagiarism_copyleaks/blob/master/scan.php,

$pathnamehash = required_param('pathnamehash', PARAM_TEXT);

$fs = get_file_storage();

$file = $fs->get_file_by_hash($pathnamehash);


For broader context, The code can be found in the following 2 files:

  1. https://github.com/Copyleaks/moodle-plagiarism_copyleaks/blob/master/lib.php ( lines 232-242 )
  2. https://github.com/Copyleaks/moodle-plagiarism_copyleaks/blob/master/scan.php ( lines 60 - 61 )


So if I understand correctly, to fix this, there is a set of parameters that can point to a moodle file and are safe to pass between pages so that the file can be served and its permissions be checked?

Thanks, Eli.

 
Average of ratings: -