Fix the issue with displaying PDF when debugging is ON (#420)

This commit is contained in:
Mikhail Golenkov 2021-04-15 14:54:11 +10:00 committed by Mark Nelson
parent f6d875d147
commit c3602b11b3
2 changed files with 11 additions and 11 deletions

View file

@ -272,15 +272,15 @@ class template {
$customcert = $DB->get_record('customcert', ['templateid' => $this->id]); $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. // If the template belongs to a certificate then we need to check what permissions we set for it.
$protection = $customcert->protection; if (!empty($customcert->protection)) {
if (!empty($protection)) { $protection = explode(', ', $customcert->protection);
$protection = explode(', ', $protection);
$pdf->SetProtection($protection); $pdf->SetProtection($protection);
} }
$deliveryoption = $customcert->deliveryoption; if (empty($customcert->deliveryoption)) {
if (empty($deliveryoption)) {
$deliveryoption = certificate::DELIVERY_OPTION_INLINE; $deliveryoption = certificate::DELIVERY_OPTION_INLINE;
} else {
$deliveryoption = $customcert->deliveryoption;
} }
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);

View file

@ -52,6 +52,12 @@ if (($userid != $USER->id) && !has_capability('mod/customcert:viewallcertificate
print_error('You are not allowed to view these certificates'); 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. // Check if we requested to download a certificate.
if ($downloadcert) { if ($downloadcert) {
$template = $DB->get_record('customcert_templates', array('id' => $customcert->templateid), '*', MUST_EXIST); $template = $DB->get_record('customcert_templates', array('id' => $customcert->templateid), '*', MUST_EXIST);
@ -68,12 +74,6 @@ if ($table->is_downloading()) {
exit(); 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. // Additional page setup.
$PAGE->navbar->add(get_string('profile'), new moodle_url('/user/profile.php', array('id' => $userid))); $PAGE->navbar->add(get_string('profile'), new moodle_url('/user/profile.php', array('id' => $userid)));
$PAGE->navbar->add(get_string('mycertificates', 'customcert')); $PAGE->navbar->add(get_string('mycertificates', 'customcert'));