From 1859ffa651c769384322b87a8d01544b86761105 Mon Sep 17 00:00:00 2001 From: Mikhail Golenkov Date: Thu, 15 Apr 2021 14:54:11 +1000 Subject: [PATCH] Fix the issue with displaying PDF when debugging is ON (#420) --- classes/template.php | 10 +++++----- my_certificates.php | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/template.php b/classes/template.php index 10be74c..de1424c 100644 --- a/classes/template.php +++ b/classes/template.php @@ -272,15 +272,15 @@ class template { $customcert = $DB->get_record('customcert', ['templateid' => $this->id]); // If the template belongs to a certificate then we need to check what permissions we set for it. - $protection = $customcert->protection; - if (!empty($protection)) { - $protection = explode(', ', $protection); + if (!empty($customcert->protection)) { + $protection = explode(', ', $customcert->protection); $pdf->SetProtection($protection); } - $deliveryoption = $customcert->deliveryoption; - if (empty($deliveryoption)) { + if (empty($customcert->deliveryoption)) { $deliveryoption = certificate::DELIVERY_OPTION_INLINE; + } else { + $deliveryoption = $customcert->deliveryoption; } $pdf->setPrintHeader(false); diff --git a/my_certificates.php b/my_certificates.php index 3312c12..5ac04ea 100644 --- a/my_certificates.php +++ b/my_certificates.php @@ -52,6 +52,12 @@ if (($userid != $USER->id) && !has_capability('mod/customcert:viewallcertificate print_error('You are not allowed to view these certificates'); } +$PAGE->set_url($pageurl); +$PAGE->set_context(context_user::instance($userid)); +$PAGE->set_title(get_string('mycertificates', 'customcert')); +$PAGE->set_pagelayout('standard'); +$PAGE->navigation->extend_for_user($user); + // Check if we requested to download a certificate. if ($downloadcert) { $template = $DB->get_record('customcert_templates', array('id' => $customcert->templateid), '*', MUST_EXIST); @@ -68,12 +74,6 @@ if ($table->is_downloading()) { exit(); } -$PAGE->set_url($pageurl); -$PAGE->set_context(context_user::instance($userid)); -$PAGE->set_title(get_string('mycertificates', 'customcert')); -$PAGE->set_pagelayout('standard'); -$PAGE->navigation->extend_for_user($user); - // Additional page setup. $PAGE->navbar->add(get_string('profile'), new moodle_url('/user/profile.php', array('id' => $userid))); $PAGE->navbar->add(get_string('mycertificates', 'customcert'));