Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moodle-mod_customcert_patch_rh #637

Open
wants to merge 10 commits into
base: MOODLE_404_STABLE
Choose a base branch
from
12 changes: 9 additions & 3 deletions classes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function delete_element($elementid) {
public function generate_pdf(bool $preview = false, ?int $userid = null, bool $return = false) {
global $CFG, $DB, $USER;

if (empty($userid)) {
if (empty($userid)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change made?

$user = $USER;
} else {
$user = \core_user::get_user($userid);
Expand Down Expand Up @@ -330,8 +330,14 @@ public function generate_pdf(bool $preview = false, ?int $userid = null, bool $r
if (empty($filename)) {
$filename = get_string('certificate', 'customcert');
}

$filename = clean_filename($filename . '.pdf');

$sql = "SELECT course,fullname
FROM {customcert} c, {course} cr
WHERE c.id = :templateid
AND c.course = cr.id";
$course = $DB->get_record_sql($sql, array('templateid' => $this->id));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$filename = clean_filename($filename .'_'. fullname($USER) .'_'. $course->fullname . '.pdf');

// Loop through the pages and display their content.
foreach ($pages as $page) {
// Add the page to the PDF.
Expand Down