From 6ac6ba53c1aec0a2019a318c9427fec8b4fdfd2b Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 7 Sep 2022 13:54:03 +0000 Subject: [PATCH] Current status --- classes/template.php | 7 +++++-- load_template_cli.php | 1 + view.php | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/classes/template.php b/classes/template.php index 3a08ee2..7be3397 100644 --- a/classes/template.php +++ b/classes/template.php @@ -18,7 +18,7 @@ * Class represents a customcert template. * * @package mod_customcert - * @copyright 2016 Mark Nelson + * @copyright 2016 Mark Nelson , 2022 Kumi Systems e.U. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -26,6 +26,7 @@ namespace mod_customcert; error_reporting(E_ALL); require_once(__DIR__ . "/../vendor/autoload.php"); +require_once($CFG->dirroot.'/user/profile/lib.php'); use mikehaertl\wkhtmlto\Pdf; @@ -272,6 +273,8 @@ class template { require_once($CFG->libdir . '/pdflib.php'); + profile_load_data($user); + // Get the pages for the template, there should always be at least one page for each template. if ($pages = $DB->get_records('customcert_pages', array('templateid' => $this->id), 'sequence ASC')) { // Create the pdf object. @@ -376,7 +379,7 @@ class template { $html = str_replace("__DATE__", userdate($date, '%B %d, %Y'), $html); - $html = str_replace("__PIN__", $user->profile["pin"], $html); + $html = str_replace("__PIN__", $user->username, $html); $pdf->addPage($html); $pdf->send(); diff --git a/load_template_cli.php b/load_template_cli.php index 92cbda4..5452285 100644 --- a/load_template_cli.php +++ b/load_template_cli.php @@ -54,3 +54,4 @@ if ($elements = $DB->get_records_sql($sql, array('templateid' => $template->get_ $DB->delete_records('customcert_pages', array('templateid' => $template->get_id())); $loadtemplate->copy_to_template($template->get_id()); + diff --git a/view.php b/view.php index 9b8af82..a888f14 100644 --- a/view.php +++ b/view.php @@ -18,7 +18,7 @@ * Handles viewing a customcert. * * @package mod_customcert - * @copyright 2013 Mark Nelson + * @copyright 2013 Mark Nelson , 2022 Kumi Systems e.U. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -142,6 +142,7 @@ if (!$downloadown && !$downloadissue) { $link = new moodle_url('/mod/customcert/view.php', array('id' => $cm->id, 'downloadown' => true)); $downloadbutton = new single_button($link, $linkname, 'get', true); $downloadbutton->class .= ' m-b-1'; // Seems a bit hackish, ahem. + $downloadbutton->add_action(new \popup_action('click', $link)); $downloadbutton = $OUTPUT->render($downloadbutton); }