diff --git a/edit.php b/edit.php index c1a2c6a..d0f777a 100644 --- a/edit.php +++ b/edit.php @@ -103,7 +103,7 @@ if ((!empty($moveup)) || (!empty($movedown))) { $DB->set_field('customcert_elements', 'sequence', $movecertelement->sequence, array('id' => $swapcertelement->id)); } } else if (!empty($deletepage)) { // Check if we are deleting a page. - if (!empty($confirm)) { // Check they have confirmed the deletion + if (!empty($confirm)) { // Check they have confirmed the deletion. customcert_delete_page($deletepage); } else { // Set deletion flag to true. @@ -118,7 +118,7 @@ if ((!empty($moveup)) || (!empty($movedown))) { 'sesskey' => sesskey())); } } else if (!empty($deleteelement)) { // Check if we are deleting an element. - if (!empty($confirm)) { // Check they have confirmed the deletion + if (!empty($confirm)) { // Check they have confirmed the deletion. // Ensure element exists and delete it. $element = $DB->get_record('customcert_elements', array('id' => $deleteelement), '*', MUST_EXIST); // Get an instance of the element class. @@ -191,7 +191,7 @@ if ($data = $mform->get_data()) { // Check if we want to preview this custom certificate. if (!empty($data->previewbtn)) { - customcert_generate_pdf($customcert); + customcert_generate_pdf($customcert, true); } // Redirect to the editing page to show form with recent updates. diff --git a/element/code/lib.php b/element/code/lib.php index fd99dc1..f8db4a3 100644 --- a/element/code/lib.php +++ b/element/code/lib.php @@ -32,8 +32,9 @@ class customcert_element_code extends customcert_element_base { * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { global $DB, $USER; // Get the page. diff --git a/element/code/version.php b/element/code/version.php index 7461983..89e80bb 100644 --- a/element/code/version.php +++ b/element/code/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2013061200; +$plugin->version = 2013062800; $plugin->requires = 2013040500; // Requires this Moodle version. $plugin->component = 'customcertelement_code'; diff --git a/element/date/lib.php b/element/date/lib.php index fa44bf8..63f9a4b 100644 --- a/element/date/lib.php +++ b/element/date/lib.php @@ -82,8 +82,9 @@ class customcert_element_date extends customcert_element_base { * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { global $COURSE, $DB, $USER; // If there is no element data, we have nothing to display. diff --git a/element/date/version.php b/element/date/version.php index 6c0bcd2..c516be2 100644 --- a/element/date/version.php +++ b/element/date/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2013062500; +$plugin->version = 2013062800; $plugin->requires = 2013040500; // Requires this Moodle version. $plugin->component = 'customcertelement_date'; diff --git a/element/element.class.php b/element/element.class.php index 79d6cc6..45e8793 100644 --- a/element/element.class.php +++ b/element/element.class.php @@ -172,8 +172,9 @@ abstract class customcert_element_base { * Must be overridden. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { // Must be overridden. } diff --git a/element/grade/lib.php b/element/grade/lib.php index 0867f41..245843e 100644 --- a/element/grade/lib.php +++ b/element/grade/lib.php @@ -83,8 +83,9 @@ class customcert_element_grade extends customcert_element_base { * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { global $USER; // If there is no element data, we have nothing to display. diff --git a/element/grade/version.php b/element/grade/version.php index e91b0d4..583a8e7 100644 --- a/element/grade/version.php +++ b/element/grade/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2013062500; +$plugin->version = 2013062800; $plugin->requires = 2013040500; // Requires this Moodle version. $plugin->component = 'customcertelement_grade'; diff --git a/element/image/lib.php b/element/image/lib.php index 3f7cc9c..fb86a39 100644 --- a/element/image/lib.php +++ b/element/image/lib.php @@ -96,8 +96,9 @@ class customcert_element_image extends customcert_element_base { * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { global $CFG; // If there is no element data, we have nothing to display. diff --git a/element/image/version.php b/element/image/version.php index 9fd5b24..d007173 100644 --- a/element/image/version.php +++ b/element/image/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2013062500; +$plugin->version = 2013062800; $plugin->requires = 2013040500; // Requires this Moodle version. $plugin->component = 'customcertelement_image'; diff --git a/element/studentname/lib.php b/element/studentname/lib.php index ae34d08..c8e93e0 100644 --- a/element/studentname/lib.php +++ b/element/studentname/lib.php @@ -32,8 +32,9 @@ class customcert_element_studentname extends customcert_element_base { * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { global $USER; parent::render_content($pdf, fullname($USER)); diff --git a/element/studentname/version.php b/element/studentname/version.php index 926038f..28dade5 100644 --- a/element/studentname/version.php +++ b/element/studentname/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2013061200; +$plugin->version = 2013062800; $plugin->requires = 2013040500; // Requires this Moodle version. $plugin->component = 'customcertelement_studentname'; diff --git a/element/text/lib.php b/element/text/lib.php index 442584b..2e38eef 100644 --- a/element/text/lib.php +++ b/element/text/lib.php @@ -56,8 +56,9 @@ class customcert_element_text extends customcert_element_base { * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { parent::render_content($pdf, $this->element->data); } diff --git a/element/text/version.php b/element/text/version.php index 6c5f5f4..0bd9fcd 100644 --- a/element/text/version.php +++ b/element/text/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2013062500; +$plugin->version = 2013062800; $plugin->requires = 2013040500; // Requires this Moodle version. $plugin->component = 'customcertelement_text'; diff --git a/element/userfield/lib.php b/element/userfield/lib.php index 687b1b7..1fb9295 100644 --- a/element/userfield/lib.php +++ b/element/userfield/lib.php @@ -62,8 +62,9 @@ class customcert_element_userfield extends customcert_element_base { * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object + * @param bool $preview true if it is a preview, false otherwise */ - public function render($pdf) { + public function render($pdf, $preview) { global $DB, $USER; // The user field to display. diff --git a/element/userfield/version.php b/element/userfield/version.php index 8f5980b..30e2cf3 100644 --- a/element/userfield/version.php +++ b/element/userfield/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2013062500; +$plugin->version = 2013062800; $plugin->requires = 2013040500; // Requires this Moodle version. $plugin->component = 'customcertelement_userfield'; diff --git a/lib.php b/lib.php index f072b3b..95d31a9 100644 --- a/lib.php +++ b/lib.php @@ -787,8 +787,9 @@ function customcert_generate_code() { * Generate the PDF for the specified customcert and user. * * @param stdClass $customcert + * @param bool $preview true if it is a preview, false otherwise */ -function customcert_generate_pdf($customcert) { +function customcert_generate_pdf($customcert, $preview = false) { global $CFG, $DB; require_once($CFG->libdir . '/pdflib.php'); @@ -817,7 +818,7 @@ function customcert_generate_pdf($customcert) { foreach ($elements as $element) { // Get an instance of the element class. if ($e = customcert_get_element_instance($element)) { - $e->render($pdf); + $e->render($pdf, $preview); } } }