/** * Add customcert instance. * * @param stdClass $data * @param mod_customcert_mod_form $mform * @return int new customcert instance id */ function customcert_add_instance($data, $mform) { global $DB; $data->protection = customcert_set_protection($data); $data->timecreated = time(); $data->timemodified = $data->timecreated; $data->id = $DB->insert_record('customcert', $data); // Add a page to this customcert. customcert_add_page($data); return $data->id; }
$PAGE->set_title($strheading); $PAGE->set_heading($course->fullname); $PAGE->set_url('/mod/customcert/edit.php', array('cmid' => $cmid)); echo $OUTPUT->header(); echo $OUTPUT->heading($strheading); echo $OUTPUT->confirm($message, $yesurl, $nourl); echo $OUTPUT->footer(); exit; } $mform = new mod_customcert_edit_form('', array('customcertid' => $customcert->id, 'cmid' => $cm->id, 'course' => $course)); if ($data = $mform->get_data()) { // Save any page data. customcert_save_page_data($data); // Check if we are adding a page. if (!empty($data->addcertpage)) { customcert_add_page($data); } // Loop through the data. foreach ($data as $key => $value) { // Check if they wanted to download the grid PDF. if (strpos($key, 'downloadgrid_') !== false) { // Get the page id. $pageid = str_replace('downloadgrid_', '', $key); customcert_generate_grid_pdf($pageid); } else { if (strpos($key, 'addelement_') !== false) { // Check if they chose to add an element to a page. // Get the page id. $pageid = str_replace('addelement_', '', $key); // Get the element. $element = "element_" . $pageid;