Removed unnecessary second parameter for the render function
This commit is contained in:
parent
220d83935f
commit
59ea1afd75
9 changed files with 18 additions and 26 deletions
2
edit.php
2
edit.php
|
@ -183,7 +183,7 @@ if ($data = $mform->get_data()) {
|
||||||
|
|
||||||
// Check if we want to preview this custom certificate.
|
// Check if we want to preview this custom certificate.
|
||||||
if (!empty($data->previewbtn)) {
|
if (!empty($data->previewbtn)) {
|
||||||
customcert_generate_pdf($customcert, $USER->id);
|
customcert_generate_pdf($customcert);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to the editing page to show form with recent updates.
|
// Redirect to the editing page to show form with recent updates.
|
||||||
|
|
|
@ -33,15 +33,14 @@ class customcert_element_code extends customcert_element_base {
|
||||||
* Handles rendering the element on the pdf.
|
* Handles rendering the element on the pdf.
|
||||||
*
|
*
|
||||||
* @param stdClass $pdf the pdf object
|
* @param stdClass $pdf the pdf object
|
||||||
* @param int $userid
|
|
||||||
*/
|
*/
|
||||||
public function render($pdf, $userid) {
|
public function render($pdf) {
|
||||||
global $DB;
|
global $DB, $USER;
|
||||||
|
|
||||||
// Get the page.
|
// Get the page.
|
||||||
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
|
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
|
||||||
// Now we can get the issue for this user.
|
// Now we can get the issue for this user.
|
||||||
$issue = $DB->get_record('customcert_issues', array('userid' => $userid, 'customcertid' => $page->customcertid), '*', MUST_EXIST);
|
$issue = $DB->get_record('customcert_issues', array('userid' => $USER->id, 'customcertid' => $page->customcertid), '*', MUST_EXIST);
|
||||||
|
|
||||||
parent::render_content($pdf, $issue->code);
|
parent::render_content($pdf, $issue->code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,8 @@ class customcert_element_date extends customcert_element_base {
|
||||||
* Handles rendering the element on the pdf.
|
* Handles rendering the element on the pdf.
|
||||||
*
|
*
|
||||||
* @param stdClass $pdf the pdf object
|
* @param stdClass $pdf the pdf object
|
||||||
* @param int $userid
|
|
||||||
*/
|
*/
|
||||||
public function render($pdf, $userid) {
|
public function render($pdf) {
|
||||||
// TO DO.
|
// TO DO.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,9 +169,8 @@ class customcert_element_base {
|
||||||
* Must be overridden.
|
* Must be overridden.
|
||||||
*
|
*
|
||||||
* @param stdClass $pdf the pdf object
|
* @param stdClass $pdf the pdf object
|
||||||
* @param int $userid
|
|
||||||
*/
|
*/
|
||||||
public function render($pdf, $userid) {
|
public function render($pdf) {
|
||||||
// Must be overridden.
|
// Must be overridden.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +178,7 @@ class customcert_element_base {
|
||||||
* Common behaviour for rendering specified content on the pdf.
|
* Common behaviour for rendering specified content on the pdf.
|
||||||
*
|
*
|
||||||
* @param stdClass $pdf the pdf object
|
* @param stdClass $pdf the pdf object
|
||||||
* @param stdClass $content the content to render
|
* @param string $content the content to render
|
||||||
*/
|
*/
|
||||||
public function render_content($pdf, $content) {
|
public function render_content($pdf, $content) {
|
||||||
$this->set_font($pdf);
|
$this->set_font($pdf);
|
||||||
|
|
|
@ -103,9 +103,10 @@ class customcert_element_grade extends customcert_element_base {
|
||||||
* Handles rendering the element on the pdf.
|
* Handles rendering the element on the pdf.
|
||||||
*
|
*
|
||||||
* @param stdClass $pdf the pdf object
|
* @param stdClass $pdf the pdf object
|
||||||
* @param int $userid
|
|
||||||
*/
|
*/
|
||||||
public function render($pdf, $userid) {
|
public function render($pdf) {
|
||||||
|
global $USER;
|
||||||
|
|
||||||
// If there is no element data, we have nothing to display.
|
// If there is no element data, we have nothing to display.
|
||||||
if (empty($this->element->data)) {
|
if (empty($this->element->data)) {
|
||||||
return;
|
return;
|
||||||
|
@ -115,7 +116,7 @@ class customcert_element_grade extends customcert_element_base {
|
||||||
$gradeinfo = json_decode($this->element->data);
|
$gradeinfo = json_decode($this->element->data);
|
||||||
|
|
||||||
// Get the grade for the grade item.
|
// Get the grade for the grade item.
|
||||||
$grade = customcert_element_grade::get_grade($gradeinfo, $userid);
|
$grade = customcert_element_grade::get_grade($gradeinfo, $USER->id);
|
||||||
parent::render_content($pdf, $grade);
|
parent::render_content($pdf, $grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,9 +144,8 @@ class customcert_element_image extends customcert_element_base {
|
||||||
* Handles rendering the element on the pdf.
|
* Handles rendering the element on the pdf.
|
||||||
*
|
*
|
||||||
* @param stdClass $pdf the pdf object
|
* @param stdClass $pdf the pdf object
|
||||||
* @param int $userid
|
|
||||||
*/
|
*/
|
||||||
public function render($pdf, $userid) {
|
public function render($pdf) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
// If there is no element data, we have nothing to display.
|
// If there is no element data, we have nothing to display.
|
||||||
|
|
|
@ -33,14 +33,10 @@ class customcert_element_studentname extends customcert_element_base {
|
||||||
* Handles rendering the element on the pdf.
|
* Handles rendering the element on the pdf.
|
||||||
*
|
*
|
||||||
* @param stdClass $pdf the pdf object
|
* @param stdClass $pdf the pdf object
|
||||||
* @param int $userid
|
|
||||||
*/
|
*/
|
||||||
public function render($pdf, $userid) {
|
public function render($pdf) {
|
||||||
global $DB;
|
global $USER;
|
||||||
|
|
||||||
$user = $DB->get_record('user', array('id' => $userid), 'id, firstname, lastname', MUST_EXIST);
|
parent::render_content($pdf, fullname($USER));
|
||||||
$fullname = fullname($user);
|
|
||||||
|
|
||||||
parent::render_content($pdf, $fullname);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
lib.php
5
lib.php
|
@ -817,9 +817,8 @@ function customcert_generate_code() {
|
||||||
* Generate the PDF for the specified customcert and user.
|
* Generate the PDF for the specified customcert and user.
|
||||||
*
|
*
|
||||||
* @param stdClass $customcert
|
* @param stdClass $customcert
|
||||||
* @param int $userid
|
|
||||||
*/
|
*/
|
||||||
function customcert_generate_pdf($customcert, $userid) {
|
function customcert_generate_pdf($customcert) {
|
||||||
global $CFG, $DB;
|
global $CFG, $DB;
|
||||||
|
|
||||||
require_once($CFG->libdir . '/pdflib.php');
|
require_once($CFG->libdir . '/pdflib.php');
|
||||||
|
@ -848,7 +847,7 @@ function customcert_generate_pdf($customcert, $userid) {
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
// Get an instance of the element class.
|
// Get an instance of the element class.
|
||||||
if ($e = customcert_get_element_instance($element)) {
|
if ($e = customcert_get_element_instance($element)) {
|
||||||
$e->render($pdf, $userid);
|
$e->render($pdf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
view.php
2
view.php
|
@ -120,5 +120,5 @@ if (empty($action)) {
|
||||||
$DB->insert_record('customcert_issues', $customcertissue);
|
$DB->insert_record('customcert_issues', $customcertissue);
|
||||||
}
|
}
|
||||||
// Now we want to generate the PDF.
|
// Now we want to generate the PDF.
|
||||||
customcert_generate_pdf($customcert, $USER->id);
|
customcert_generate_pdf($customcert);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue