Development:Backup: Difference between revisions
m (→See also) |
Helen Foster (talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{stub}} | {{stub}} | ||
''Please add backup and restore documentation for new developers here...'' | ''Please add backup and restore documentation for new developers here...'' | ||
== Back Up for your Module == | |||
Your backup functions should sit in a file called backuplib.php in your module folder. As a minimum you should write the following functions: | |||
*''' ''MODULENAME''_backup_mods($bf,$preferences) ''' - backs up all instances of your module | |||
*''' ''MODULENAME''_backup_one_mod($bf,$preferences,$scefcentre) ''' - backs up a single instance of your module | |||
*''' ''MODULENAME''_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) ''' - generates an array of course and user data information used to select which instances to backup (and whether to include user data or not). This includes details at [0][0] and [0][1] about the course module name and number of instances for the course and at [1][0] and [1][1] with the module name and count of user information. | |||
*''' ''MODULENAME''_check_backup_mods_instances($instance,$backup_unique_code) ''' - generates an array of course and user data information for a specific instance. | |||
*''' ''MODULENAME''__encode_content_links ($content,$preferences) ''' - recode links to ensure they work when reimported. | |||
''MODULENAME''_backup_one_mod should generate XML output by calling the fwrite() function. This XML should cover all fields in the database: | |||
<code php> | |||
//Start mod | |||
fwrite ($bf,start_tag("MOD",3,true)); | |||
//generate XML representing the DB | |||
fwrite ($bf,full_tag("ID",4,false, 'VALUE_GOES_HERE')); | |||
fwrite ($bf,full_tag("TEXT",4,false, 'VALUE_GOES_HERE')); | |||
//End mod | |||
$status =fwrite ($bf,end_tag("MOD",3,true)); | |||
</code> | |||
==See also== | ==See also== | ||
*[[Development:Backup 2.0 for developers]] | |||
*[[Backup and restore FAQ]] | *[[Backup and restore FAQ]] | ||
*Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum] | *Using Moodle [http://moodle.org/mod/forum/view.php?f=128 Backup and Restore forum] |
Latest revision as of 11:54, 2 December 2010
Please add backup and restore documentation for new developers here...
Back Up for your Module
Your backup functions should sit in a file called backuplib.php in your module folder. As a minimum you should write the following functions:
- MODULENAME_backup_mods($bf,$preferences) - backs up all instances of your module
- MODULENAME_backup_one_mod($bf,$preferences,$scefcentre) - backs up a single instance of your module
- MODULENAME_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) - generates an array of course and user data information used to select which instances to backup (and whether to include user data or not). This includes details at [0][0] and [0][1] about the course module name and number of instances for the course and at [1][0] and [1][1] with the module name and count of user information.
- MODULENAME_check_backup_mods_instances($instance,$backup_unique_code) - generates an array of course and user data information for a specific instance.
- MODULENAME__encode_content_links ($content,$preferences) - recode links to ensure they work when reimported.
MODULENAME_backup_one_mod should generate XML output by calling the fwrite() function. This XML should cover all fields in the database:
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//generate XML representing the DB
fwrite ($bf,full_tag("ID",4,false, 'VALUE_GOES_HERE'));
fwrite ($bf,full_tag("TEXT",4,false, 'VALUE_GOES_HERE'));
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
See also
Using Moodle forum discussions: