#80 Fixed user picture not displaying on PDF

This commit is contained in:
Mark Nelson 2017-02-16 18:41:58 +08:00
parent e31236cbf2
commit db879187bf

View file

@ -113,21 +113,20 @@ class element extends \mod_customcert\element {
$context = \context_user::instance($user->id); $context = \context_user::instance($user->id);
// Prepare file record object. // Get files in the user icon area.
$fileinfo = array(
'component' => 'user',
'filearea' => 'icon',
'itemid' => 0,
'contextid' => $context->id,
'filepath' => '/',
'filename' => 'f1.png');
// Get file.
$fs = get_file_storage(); $fs = get_file_storage();
$file = $fs->get_file($fileinfo['contextid'], $fileinfo['component'], $fileinfo['filearea'], $files = $fs->get_area_files($context->id, 'user', 'icon', 0);
$fileinfo['itemid'], $fileinfo['filepath'], $fileinfo['filename']);
// Show image. // Get the file we want to display.
$file = null;
foreach ($files as $filefound) {
if (!$filefound->is_directory()) {
$file = $filefound;
break;
}
}
// Show image if we found one.
if ($file) { if ($file) {
$contenthash = $file->get_contenthash(); $contenthash = $file->get_contenthash();
$l1 = $contenthash[0] . $contenthash[1]; $l1 = $contenthash[0] . $contenthash[1];