From 7c4e8def0c491494e46f4ec5d31890ccb39ab581 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Thu, 11 Apr 2013 18:52:30 +0800 Subject: [PATCH] Altered the render function in the studentname element to use the common rendering function --- elements/studentname/lib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/elements/studentname/lib.php b/elements/studentname/lib.php index c87db3e..6421ce3 100644 --- a/elements/studentname/lib.php +++ b/elements/studentname/lib.php @@ -41,13 +41,15 @@ class customcert_element_studentname extends customcert_element_base { /** * Handles rendering the element on the pdf. * - * @param $pdf the pdf object, see lib/pdflib.php + * @param stdClass $pdf the pdf object + * @param int $userid */ - public function render($pdf) { - global $USER; + public function render($pdf, $userid) { + global $DB; - $pdf->setFont($this->element->font, '', $this->element->size); - $pdf->SetXY($this->element->posx, $this->element->posy); - $pdf->writeHTMLCell(0, 0, '', '', fullname($USER), 0, 0, 0, true, $align); + $user = $DB->get_record('user', array('id' => $userid), 'id, firstname, lastname', MUST_EXIST); + $fullname = fullname($user); + + parent::render_content($pdf, $fullname); } }