Certificate Plugin: backup image files

Certificate Plugin: backup image files

by feida kila -
Number of replies: 0

I've developed a certificate plugin from certificate and simplecertificate plugins, mixing their funcionality. Now I'm trying to modify the backup restore funcionality of the plugin, but I'm not able to store certificate image files. 

 

Image files are stored in several folder within the following path (these images are certificate seals, signatures, watermarks, etc..): /webserverroot/moodle/moodledata/mod/certificate/pix/

 

I've modified backup_certificate_stepslib.php in order to store those files but I'm not getting the expected results.

 

Anyone knows what I'm doing wrong, or where to find some docs about it? Thanks

 

protected function define_structure() {
// To know if we are including userinfo
$userinfo = $this->get_setting_value('userinfo');

// Define each element separated
$certificate = new backup_nested_element('certificate', array('id'), array(
'coursealtname', 'name', 'intro', 'introformat', 'emailteachers',
'delivery', 'certificatetype', 'timecreated', 'timemodified', 'deleted',
'metadata'
));
$issues = new backup_nested_element('issues');
$issue = new backup_nested_element('issue', array('id'), array(
'userid', 'courseid', 'certificateid', 'trackingid', 'coursename',
'timecreated', 'grade', 'serialnumber'));
$trackings = new backup_nested_element('trackings');
$tracking = new backup_nested_element('tracking', array('id'), array(
'userid', 'courseid', 'coursename', 'enroldate', 'unenroldate',
'grade', 'time'
));

// Build the tree
$certificate->add_child($issues);
$issues->add_child($issue);
$certificate->add_child($trackings);
$trackings->add_child($tracking);

// Define sources
$certificate->set_source_table('certificate', array('id' => backup::VAR_ACTIVITYID));

// All the rest of elements only happen if we are including user info
if ($userinfo) {
$issue->set_source_table('certificate_issues', array('certificateid' => backup::VAR_PARENTID));
$tracking->set_source_table('certificate_tracking', array('courseid' => backup::VAR_COURSEID));
}

// Annotate the user id's where required.
$issue->annotate_ids('user', 'userid');
$tracking->annotate_ids('user', 'userid');

// Define file annotations
$certificate->annotate_files('mod_certificate', 'intro', null); // This file area hasn't itemid
$certificate->annotate_files('mod_certificate', 'pix', null); // This file area hasn't itemid
$issue->annotate_files('mod_certificate', 'issues', 'id');

// Return the root element (certificate), wrapped into standard activity structure
return $this->prepare_activity_structure($certificate);
}
Average of ratings: -