function certificate_restore_mods($mod, $restore) { global $CFG; $status = true; //Get record from backup_ids $data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id); if ($data) { //Now get completed xmlized object $info = $data->info; //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug //Now, build the certificate record structure $certificate->course = $restore->course_id; $certificate->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); $certificate->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']); $certificate->emailteachers = backup_todb($info['MOD']['#']['EMAILTEACHERS']['0']['#']); $certificate->emailothers = backup_todb($info['MOD']['#']['EMAILOTHERS']['0']['#']); $certificate->savecert = backup_todb($info['MOD']['#']['SAVECERT']['0']['#']); $certificate->reportcert = backup_todb($info['MOD']['#']['REPORTCERT']['0']['#']); $certificate->delivery = backup_todb($info['MOD']['#']['DELIVERY']['0']['#']); $certificate->certificatetype = backup_todb($info['MOD']['#']['TYPE']['0']['#']); $certificate->borderstyle = backup_todb($info['MOD']['#']['BORDERSTYLE']['0']['#']); $certificate->bordercolor = backup_todb($info['MOD']['#']['BORDERCOLOR']['0']['#']); $certificate->printwmark = backup_todb($info['MOD']['#']['PRINTWMARK']['0']['#']); $certificate->printdate = backup_todb($info['MOD']['#']['PRINTDATE']['0']['#']); $certificate->datefmt = backup_todb($info['MOD']['#']['DATEFMT']['0']['#']); $certificate->printhours = backup_todb($info['MOD']['#']['PRINTHOURS']['0']['#']); $certificate->printnumber = backup_todb($info['MOD']['#']['PRINTNUMBER']['0']['#']); $certificate->printgrade = backup_todb($info['MOD']['#']['PRINTGRADE']['0']['#']); $certificate->gradefmt = backup_todb($info['MOD']['#']['GRADEFMT']['0']['#']); $certificate->printoutcome = backup_todb($info['MOD']['#']['PRINTOUTCOME']['0']['#']); $certificate->lockgrade = backup_todb($info['MOD']['#']['LOCKGRADE']['0']['#']); $certificate->requiredgrade = backup_todb($info['MOD']['#']['REQUIREDGRADE']['0']['#']); $certificate->printteacher = backup_todb($info['MOD']['#']['PRINTTEACHER']['0']['#']); $certificate->customtext = backup_todb($info['MOD']['#']['CUSTOMTEXT']['0']['#']); $certificate->printsignature = backup_todb($info['MOD']['#']['PRINTSIGNATURE']['0']['#']); $certificate->printseal = backup_todb($info['MOD']['#']['PRINTSEAL']['0']['#']); $certificate->printteacher = backup_todb($info['MOD']['#']['PRINTTEACHER']['0']['#']); $certificate->printsignature = backup_todb($info['MOD']['#']['PRINTSIGNATURE']['0']['#']); $certificate->printseal = backup_todb($info['MOD']['#']['PRINTSEAL']['0']['#']); $certificate->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); if (!empty($info['MOD']['#']['SETCERTIFICATION']['0']['#'])) { $certificate->setcertification = backup_todb($info['MOD']['#']['SETCERTIFICATION']['0']['#']); } else { $certificate->setcertification = 0; } if (!empty($info['MOD']['#']['REQUIREDCERTIFICATION']['0']['#'])) { $certificate->requiredcertification = backup_todb($info['MOD']['#']['REQUIREDCERTIFICATION']['0']['#']); } else { $certificate->requiredcertification = 0; } //The structure is equal to the db, so insert the assignment $newid = insert_record("certificate", $certificate); //Do some output if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string('modulename', 'certificate') . " \"" . format_string(stripslashes($certificate->name), true) . "\"</li>"; } if ($newid) { //We have the newid, update backup_ids backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid); //Now check if want to restore user data and do it. if (restore_userdata_selected($restore, 'certificate', $mod->id)) { //Restore assignmet_submissions $status = certificate_issues_restore_mods($mod->id, $newid, $info, $restore) && $status; } //now restore the linked Modules if (!empty($info['MOD']['#']['LINKS']['0']['#']['LINK'])) { $links = $info['MOD']['#']['LINKS']['0']['#']['LINK']; //Iterate over issueds for ($i = 0; $i < sizeof($links); $i++) { $insertlink = true; $link_info = $links[$i]; $cert_link = new stdClass(); $linkid = backup_todb($link_info['#']['LINKID']['0']['#']); if ($linkid > 0) { $linkid = backup_getid($restore->backup_unique_code, "course_modules", $linkid)->new_id; if (!$linkid) { //if no linkid returned - mark this as a failure. $insertlink = false; if (!defined('RESTORE_SILENTLY')) { notify(get_string('errorrestoringlink', 'certificate')); } } } if ($insertlink) { $cert_link->certificate_id = $newid; $cert_link->linkid = $linkid; $cert_link->linkgrade = backup_todb($link_info['#']['LINKGRADE']['0']['#']); $cert_link->timemodified = backup_todb($link_info['#']['TIMEMODIFIED']['0']['#']); insert_record("certificate_linked_modules", $cert_link); } } } } else { $status = false; } } else { $status = false; } return $status; }
function certificate_restore_mods($mod, $restore) { global $CFG; $status = true; //Get record from backup_ids $data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id); if ($data) { //Now get completed xmlized object $info = $data->info; //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug //Now, build the certificate record structure $certificate->course = $restore->course_id; $certificate->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); $certificate->emailteachers = backup_todb($info['MOD']['#']['EMAILTEACHERS']['0']['#']); $certificate->savecert = backup_todb($info['MOD']['#']['SAVECERT']['0']['#']); $certificate->delivery = backup_todb($info['MOD']['#']['DELIVERY']['0']['#']); $certificate->certificatetype = backup_todb($info['MOD']['#']['CERTIFICATETYPE']['0']['#']); $certificate->borderstyle = backup_todb($info['MOD']['#']['BORDERSTYLE']['0']['#']); $certificate->bordercolor = backup_todb($info['MOD']['#']['BORDERCOLOR']['0']['#']); $certificate->printwmark = backup_todb($info['MOD']['#']['PRINTWMARK']['0']['#']); $certificate->printdate = backup_todb($info['MOD']['#']['PRINTDATE']['0']['#']); $certificate->datefmt = backup_todb($info['MOD']['#']['DATEFMT']['0']['#']); $certificate->printnumber = backup_todb($info['MOD']['#']['PRINTNUMBER']['0']['#']); $certificate->printgrade = backup_todb($info['MOD']['#']['PRINTGRADE']['0']['#']); $certificate->gradefmt = backup_todb($info['MOD']['#']['GRADEFMT']['0']['#']); $certificate->printteacher = backup_todb($info['MOD']['#']['PRINTTEACHER']['0']['#']); $certificate->printsignature = backup_todb($info['MOD']['#']['PRINTSIGNATURE']['0']['#']); $certificate->printseal = backup_todb($info['MOD']['#']['PRINTSEAL']['0']['#']); $certificate->gradecondition = backup_todb($info['MOD']['#']['GRADECONDITION']['0']['#']); $certificate->printcredithours = backup_todb($info['MOD']['#']['PRINTCREDITHOURS']['0']['#']); $certificate->credithours = backup_todb($info['MOD']['#']['CREDITHOURS']['0']['#']); $certificate->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); $certificate->unenrol = backup_todb($info['MOD']['#']['UNENROL']['0']['#']); $certificate->activecondition = backup_todb($info['MOD']['#']['ACTIVECONDITION']['0']['#']); $certificate->printgradestd = backup_todb($info['MOD']['#']['PRINTGRADESTD']['0']['#']); //The structure is equal to the db, so insert the assignment $newid = insert_record("certificate", $certificate); //Do some output if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string('modulename', 'certificate') . " \"" . format_string(stripslashes($certificate->name), true) . "\"</li>"; } if ($newid) { //We have the newid, update backup_ids backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid); //Now check if want to restore user data and do it. if (function_exists('restore_userdata_selected')) { $restore_userdata_selected = restore_userdata_selected($restore, 'certificate', $mod->id); } if (restore_userdata_selected) { //Restore assignmet_issues $status = certificate_issues_restore_mods($mod->id, $newid, $info, $restore); } } else { $status = false; } } else { $status = false; } return $status; }