#89 Copy files to temp directory before accessing

This commit is contained in:
Andrew Nicols 2017-03-08 14:30:34 +08:00 committed by Mark Nelson
parent 7b58fb9ae6
commit 086cb16b3c
3 changed files with 6 additions and 16 deletions

View file

@ -161,8 +161,6 @@ class element extends \mod_customcert\element {
* @param \stdClass $user the user we are rendering this for
*/
public function render($pdf, $preview, $user) {
global $CFG;
// If there is no element data, we have nothing to display.
if (empty($this->element->data)) {
return;
@ -173,10 +171,8 @@ class element extends \mod_customcert\element {
// Get the image.
$fs = get_file_storage();
if ($file = $fs->get_file_by_hash($imageinfo->pathnamehash)) {
$contenthash = $file->get_contenthash();
$l1 = $contenthash[0] . $contenthash[1];
$l2 = $contenthash[2] . $contenthash[3];
$location = $CFG->dataroot . '/filedir' . '/' . $l1 . '/' . $l2 . '/' . $contenthash;
$location = make_request_directory() . '/target';
$file->copy_content_to($location);
$pdf->Image($location, $this->element->posx, $this->element->posy, $imageinfo->width, $imageinfo->height);
}
}