Removed unnecessary second parameter for the render function

This commit is contained in:
Mark Nelson 2013-06-05 16:42:18 +08:00
parent 220d83935f
commit 59ea1afd75
9 changed files with 18 additions and 26 deletions

View file

@ -183,7 +183,7 @@ if ($data = $mform->get_data()) {
// Check if we want to preview this custom certificate.
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.

View file

@ -33,15 +33,14 @@ class customcert_element_code extends customcert_element_base {
* Handles rendering the element on the pdf.
*
* @param stdClass $pdf the pdf object
* @param int $userid
*/
public function render($pdf, $userid) {
global $DB;
public function render($pdf) {
global $DB, $USER;
// Get the page.
$page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST);
// 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);
}

View file

@ -91,9 +91,8 @@ class customcert_element_date extends customcert_element_base {
* Handles rendering the element on the pdf.
*
* @param stdClass $pdf the pdf object
* @param int $userid
*/
public function render($pdf, $userid) {
public function render($pdf) {
// TO DO.
}

View file

@ -169,9 +169,8 @@ class customcert_element_base {
* Must be overridden.
*
* @param stdClass $pdf the pdf object
* @param int $userid
*/
public function render($pdf, $userid) {
public function render($pdf) {
// Must be overridden.
}
@ -179,7 +178,7 @@ class customcert_element_base {
* Common behaviour for rendering specified content on the pdf.
*
* @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) {
$this->set_font($pdf);

View file

@ -103,9 +103,10 @@ class customcert_element_grade extends customcert_element_base {
* Handles rendering the element on the pdf.
*
* @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 (empty($this->element->data)) {
return;
@ -115,7 +116,7 @@ class customcert_element_grade extends customcert_element_base {
$gradeinfo = json_decode($this->element->data);
// 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);
}

View file

@ -144,9 +144,8 @@ class customcert_element_image extends customcert_element_base {
* Handles rendering the element on the pdf.
*
* @param stdClass $pdf the pdf object
* @param int $userid
*/
public function render($pdf, $userid) {
public function render($pdf) {
global $CFG;
// If there is no element data, we have nothing to display.

View file

@ -33,14 +33,10 @@ class customcert_element_studentname extends customcert_element_base {
* Handles rendering the element on the pdf.
*
* @param stdClass $pdf the pdf object
* @param int $userid
*/
public function render($pdf, $userid) {
global $DB;
public function render($pdf) {
global $USER;
$user = $DB->get_record('user', array('id' => $userid), 'id, firstname, lastname', MUST_EXIST);
$fullname = fullname($user);
parent::render_content($pdf, $fullname);
parent::render_content($pdf, fullname($USER));
}
}

View file

@ -817,9 +817,8 @@ function customcert_generate_code() {
* Generate the PDF for the specified customcert and user.
*
* @param stdClass $customcert
* @param int $userid
*/
function customcert_generate_pdf($customcert, $userid) {
function customcert_generate_pdf($customcert) {
global $CFG, $DB;
require_once($CFG->libdir . '/pdflib.php');
@ -848,7 +847,7 @@ function customcert_generate_pdf($customcert, $userid) {
foreach ($elements as $element) {
// Get an instance of the element class.
if ($e = customcert_get_element_instance($element)) {
$e->render($pdf, $userid);
$e->render($pdf);
}
}
}

View file

@ -120,5 +120,5 @@ if (empty($action)) {
$DB->insert_record('customcert_issues', $customcertissue);
}
// Now we want to generate the PDF.
customcert_generate_pdf($customcert, $USER->id);
customcert_generate_pdf($customcert);
}