From 05b23b5213ac7a6a95f38ff87ffa67237014b2ee Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Tue, 12 Jun 2018 16:42:27 +0800 Subject: [PATCH] #197 Respect filters in 'My certificates' and 'Verify certificate' pages --- classes/my_certificates_table.php | 10 ++++++++-- classes/output/verify_certificate_result.php | 7 +++++-- verify_certificate.php | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/classes/my_certificates_table.php b/classes/my_certificates_table.php index 3810722..8da1473 100644 --- a/classes/my_certificates_table.php +++ b/classes/my_certificates_table.php @@ -94,7 +94,10 @@ class my_certificates_table extends \table_sql { * @return string */ public function col_name($certificate) { - return $certificate->name; + $cm = get_coursemodule_from_instance('customcert', $certificate->id); + $context = \context_module::instance($cm->id); + + return format_string($certificate->name, true, ['context' => $context]); } /** @@ -104,7 +107,10 @@ class my_certificates_table extends \table_sql { * @return string */ public function col_coursename($certificate) { - return $certificate->coursename; + $cm = get_coursemodule_from_instance('customcert', $certificate->id); + $context = \context_module::instance($cm->id); + + return format_string($certificate->coursename, true, ['context' => $context]); } /** diff --git a/classes/output/verify_certificate_result.php b/classes/output/verify_certificate_result.php index e6b698c..f421eb7 100644 --- a/classes/output/verify_certificate_result.php +++ b/classes/output/verify_certificate_result.php @@ -69,12 +69,15 @@ class verify_certificate_result implements templatable, renderable { * @param \stdClass $result */ public function __construct($result) { + $cm = get_coursemodule_from_instance('customcert', $result->certificateid); + $context = \context_module::instance($cm->id); + $this->userprofileurl = new \moodle_url('/user/view.php', array('id' => $result->userid, 'course' => $result->courseid)); $this->userfullname = fullname($result); $this->courseurl = new \moodle_url('/course/view.php', array('id' => $result->courseid)); - $this->coursefullname = $result->coursefullname; - $this->certificatename = $result->certificatename; + $this->coursefullname = format_string($result->coursefullname, true, ['context' => $context]); + $this->certificatename = format_string($result->certificatename, true, ['context' => $context]); } /** diff --git a/verify_certificate.php b/verify_certificate.php index 8c3bff7..d626f69 100644 --- a/verify_certificate.php +++ b/verify_certificate.php @@ -89,7 +89,8 @@ if ($form->get_data()) { // Ok, now check if the code is valid. $userfields = get_all_user_name_fields(true, 'u'); $sql = "SELECT ci.id, u.id as userid, $userfields, co.id as courseid, - co.fullname as coursefullname, c.name as certificatename, c.verifyany + co.fullname as coursefullname, c.id as certificateid, + c.name as certificatename, c.verifyany FROM {customcert} c JOIN {customcert_issues} ci ON c.id = ci.customcertid