// |
// |
// glossary_entries
- // (UL,pk->id, fk->glossaryid, files)
+ // (UL,pk->id, fk->glossaryid, files)
//
// Meaning: pk->primary key field of the table
// fk->foreign key to link with parent
return $status;
}
- //Backup glossary_entries contents made by teachers (executed from glossary_backup_mods)
+ //Backup glossary_entries contents (executed from glossary_backup_mods)
function backup_glossary_entries ($bf,$preferences,$glossary, $userinfo) {
global $CFG;
$glossary_entries = get_records("glossary_entries","glossaryid",$glossary,"id");
//If there is submissions
if ($glossary_entries) {
- $dumped_entries = 0;
+ $dumped_entries = 0;
- //Iterate over each answer
+ //Iterate over each entry
foreach ($glossary_entries as $glo_ent) {
- //Start answer
-
+ //Start entry
//Print submission contents
- if ( $glo_ent->teacherentry or $userinfo) {
- $dumped_entries++;
- if ($dumped_entries == 1) {
- //Write start tag
- $status =fwrite ($bf,start_tag("ENTRIES",4,true));
- }
- $status =fwrite ($bf,start_tag("ENTRY",5,true));
-
- fwrite ($bf,full_tag("ID",6,false,$glo_ent->id));
- fwrite ($bf,full_tag("USERID",6,false,$glo_ent->userid));
- fwrite ($bf,full_tag("CONCEPT",6,false,$glo_ent->concept));
- fwrite ($bf,full_tag("DEFINITION",6,false,$glo_ent->definition));
- fwrite ($bf,full_tag("FORMAT",6,false,$glo_ent->format));
- fwrite ($bf,full_tag("ATTACHMENT",6,false,$glo_ent->attachment));
- fwrite ($bf,full_tag("TEACHERENTRY",6,false,$glo_ent->teacherentry));
-
- $status =fwrite ($bf,end_tag("ENTRY",5,true));
- }
+ if ($glo_ent->teacherentry or $userinfo) {
+ $dumped_entries++;
+ if ($dumped_entries == 1) {
+ //Write start tag
+ $status =fwrite ($bf,start_tag("ENTRIES",4,true));
+ }
+ $status =fwrite ($bf,start_tag("ENTRY",5,true));
+
+ fwrite ($bf,full_tag("ID",6,false,$glo_ent->id));
+ fwrite ($bf,full_tag("USERID",6,false,$glo_ent->userid));
+ fwrite ($bf,full_tag("CONCEPT",6,false,$glo_ent->concept));
+ fwrite ($bf,full_tag("DEFINITION",6,false,$glo_ent->definition));
+ fwrite ($bf,full_tag("FORMAT",6,false,$glo_ent->format));
+ fwrite ($bf,full_tag("ATTACHMENT",6,false,$glo_ent->attachment));
+ fwrite ($bf,full_tag("TEACHERENTRY",6,false,$glo_ent->teacherentry));
+
+ $status =fwrite ($bf,end_tag("ENTRY",5,true));
+
+ //Now include entry attachment in backup (if it exists)
+ if ($glo_ent->attachment) {
+ $status = backup_glossary_files($bf,$preferences,$glossary,$glo_ent->id);
+ }
+ }
+ }
+ if ( $dumped_entries > 0 ) {
+ //Write end tag
+ $status =fwrite ($bf,end_tag("ENTRIES",4,true));
}
- if ( $dumped_entries > 0 ) {
- //Write end tag
- $status =fwrite ($bf,end_tag("ENTRIES",4,true));
- }
}
return $status;
}
//Backup glossary files because we've selected to backup user info
- //and files are user info's level
- function backup_glossary_files($bf,$preferences) {
+ //or current entry is a teacher entry
+ function backup_glossary_files($bf,$preferences,$glossary,$entry) {
global $CFG;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
- //Now copy the forum dir
+
+ //Now we check that moddata/glossary dir exists and create it as necessary
+ //in temp/backup/$backup_code/moddata dir
+ $glo_dir_to = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code.
+ "/".$CFG->moddata."/glossary";
+ //Let's create it as necessary
+ $status = check_dir_exists($glo_dir_to,true);
+
+ //Now we check that the moddata/glossary/$glossary dir exists and create it as necessary
+ //in temp/backup/$backup_code/moddata/glossary
+ $status = check_dir_exists($glo_dir_to."/".$glossary,true);
+
+ //Now copy the moddata/glossary/$glossary/$entry to
+ //temp/backup/$backup_code/moddata/glossary/$glossary/$entry
if ($status) {
- //Only if it exists !! Thanks to Daniel Miksik.
- if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/glossary")) {
- $status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/glossary",
- $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/glossary");
+ //Calculate moddata/glossary dir
+ $glo_dir_from = $CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/glossary";
+ //Only if it exists !!
+ if (is_dir($glo_dir_from."/".$glossary."/".$entry)) {
+ $status = backup_copy_file($glo_dir_from."/".$glossary."/".$entry,
+ $glo_dir_to."/".$glossary."/".$entry);
}
}