Added functionality to preview the custom certificate

This commit is contained in:
Mark Nelson 2013-05-17 11:05:42 +08:00
parent 4962b72938
commit a513ba8038
6 changed files with 11 additions and 2 deletions

View file

@ -181,6 +181,11 @@ if ($data = $mform->get_data()) {
}
}
// Check if we want to preview this custom certificate.
if (!empty($data->previewbtn)) {
customcert_generate_pdf($customcert, $USER->id);
}
// Redirect to the editing page to show form with recent updates.
$url = new moodle_url('/mod/customcert/edit.php', array('cmid' => $cmid));
redirect($url);

View file

@ -83,6 +83,7 @@ class mod_customcert_edit_form extends moodleform {
// Add the submit buttons.
$group = array();
$group[] = $mform->createElement('submit', 'submitbtn', get_string('savechanges'));
$group[] = $mform->createElement('submit', 'previewbtn', get_string('savechangespreview', 'customcert'));
$mform->addElement('group', 'submitbtngroup', '', $group, '', false);
$mform->addElement('hidden', 'id');

View file

@ -15,6 +15,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
require_once($CFG->dirroot . '/mod/customcert/includes/tcpdf_colors.php');
/**
* The base class for the customcert elements.
*

View file

@ -75,6 +75,7 @@ $string['posx_help'] = 'This is the position in pixels from the top left corner
$string['posy'] = 'Postion Y';
$string['posy_help'] = 'This is the position in pixels from the top left corner you wish the element to display in the y direction.';
$string['save'] = 'Save';
$string['savechangespreview'] = 'Save changes and preview';
$string['savetemplate'] = 'Save template';
$string['setprotection'] = 'Set protection';
$string['setprotection_help'] = 'Choose the actions you wish to prevent users from performing on this certificate.';

View file

@ -802,6 +802,8 @@ function customcert_generate_code() {
function customcert_generate_pdf($customcert, $userid) {
global $CFG, $DB;
require_once($CFG->libdir . '/pdflib.php');
// Get the pages for the customcert, there should always be at least one page for each customcert.
if ($pages = $DB->get_records('customcert_pages', array('customcertid' => $customcert->id), 'pagenumber ASC')) {
// Create the pdf object.

View file

@ -25,8 +25,6 @@
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/customcert/lib.php');
require_once($CFG->libdir . '/pdflib.php');
require_once($CFG->dirroot . '/mod/customcert/includes/tcpdf_colors.php');
$id = required_param('id', PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);