From 0b0b37ed3542b9e853533da00dbed1f8d6e4dff3 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Thu, 23 May 2019 11:25:14 +0800 Subject: [PATCH] Check that a certificate issue exists (#269) --- my_certificates.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/my_certificates.php b/my_certificates.php index 599d0b1..3312c12 100644 --- a/my_certificates.php +++ b/my_certificates.php @@ -30,6 +30,11 @@ $downloadcert = optional_param('downloadcert', '', PARAM_BOOL); if ($downloadcert) { $certificateid = required_param('certificateid', PARAM_INT); $customcert = $DB->get_record('customcert', array('id' => $certificateid), '*', MUST_EXIST); + + // Check there exists an issued certificate for this user. + if (!$issue = $DB->get_record('customcert_issues', ['userid' => $userid, 'customcertid' => $customcert->id])) { + throw new moodle_exception('You have not been issued a certificate'); + } } $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', \mod_customcert\certificate::CUSTOMCERT_PER_PAGE, PARAM_INT);