// | |
// | |
// glossary_entries -------------- glossary_entries_categories
- // (UL,pk->id, fk->glossaryid, files) (UL, [pk->categoryid,entryid]
- // |
- // |
- // |
- // glossary_comments
- // (UL,pk->id, fk->entryid)
+ // (UL,pk->id, fk->glossaryid, files) (UL, pk->categoryid,entryid]
+ // | \
+ // | \
+ // | \
+ // glossary_comments --------- glossary_alias
+ // (UL,pk->id, fk->entryid) (UL, pk->id, pk->entryid)
//
//
// Meaning: pk->primary key field of the table
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$glo_ent->timemodified));
fwrite ($bf,full_tag("TEACHERENTRY",6,false,$glo_ent->teacherentry));
+ $status = backup_glossary_aliases ($bf,$preferences,$glo_ent->id);
+
if ( $userinfo ) {
$status = backup_glossary_comments ($bf,$preferences,$glo_ent->id);
}
return $status;
}
+ //Backup glossary_alias contents (executed from backup_glossary_entries)
+ function backup_glossary_aliases ($bf,$preferences,$entryid) {
+
+ global $CFG;
+
+ $status = true;
+
+ $aliases = get_records("glossary_alias","entryid",$entryid);
+ if ($aliases) {
+ $status =fwrite ($bf,start_tag("ALIASES",6,true));
+ foreach ($aliases as $alias) {
+ $status =fwrite ($bf,start_tag("ALIAS",7,true));
+
+ fwrite ($bf,full_tag("NAME",8,false,$comment->id));
+
+ $status =fwrite ($bf,end_tag("ALIAS",7,true));
+ }
+ $status =fwrite ($bf,end_tag("ALIASES",6,true));
+ }
+ return $status;
+ }
+
//Backup glossary files because we've selected to backup user info
//or current entry is a teacher entry
function backup_glossary_files($bf,$preferences,$glossary,$entry) {
if ( $newentry->id = insert_record("glossary_entries",$newentry) ) {
$importedentries++;
+
+ $xmlaliases = $xmlentry['#']['ALIASES'][0]['#']['ALIAS'];
+ for($k = 0; $k < sizeof($xmlaliases); $k++) {
+ /// Importing aliases
+ $xmlalias = $xmlaliases[$k];
+ unset($newalias);
+
+ $newalias->entryid = $newentry->id;
+ $newalias->alias = $xmlalias['#']['NAME'][0]['#'];
+ $newalias->id = insert_record("glossary_alias",$newalias));
+ }
+
if ( $catsincl ) {
// If the categories must be imported...
$xmlcats = $xmlentry['#']['CATEGORIES'][0]['#']['CATEGORY'];
fwrite($h,glossary_full_tag("FULLMATCH",4,false,$entry->fullmatch));
fwrite($h,glossary_full_tag("TEACHERENTRY",4,false,$entry->teacherentry));
+ if ( $aliases = get_records("glossary_alias","entryid",$entry->id) ) {
+ $status = fwrite ($h,glossary_start_tag("ALIASES",4,true));
+ foreach ($aliases as $alias) {
+ $status = fwrite ($h,glossary_start_tag("ALIAS",5,true));
+ fwrite($h,glossary_full_tag("NAME",6,false,$alias->alias));
+ $status = fwrite($h,glossary_end_tag("ALIAS",5,true));
+ }
+ $status = fwrite($h,glossary_end_tag("CATEGORIES",4,true));
+ }
if ( $catentries = get_records("glossary_entries_categories","entryid",$entry->id) ) {
$status = fwrite ($h,glossary_start_tag("CATEGORIES",4,true));
foreach ($catentries as $catentry) {
// | |
// glossary_entries -------------- glossary_entries_categories
// (UL,pk->id, fk->glossaryid, files) (UL, [pk->categoryid,entryid]
- // |
- // |
- // |
- // glossary_comments
- // (UL,pk->id, fk->entryid)
+ // | \
+ // | \
+ // | \
+ // glossary_comments ------ glossary_alias
+ // (UL,pk->id, fk->entryid) (UL, pk->id, pk->entryid)
//
//
// Meaning: pk->primary key field of the table
}
if ($newid) {
//We have the newid, update backup_ids
- backup_putid($restore->backup_unique_code,"glossary_entries",$oldid,$newid);
+ backup_putid($restore->backup_unique_code,"glossary_entries",$oldid,$newid);
+ //Restore glossary_alias
+ $status = glossary_alias_restore_mods($oldid,$newid,$ent_info,$restore);
//Now restore glossary_comments
$status = glossary_comments_restore_mods($oldid,$newid,$ent_info,$restore);
//Now copy moddata associated files if needed
return $status;
}
+ //This function restores the glossary_alias table
+ function glossary_alias_restore_mods($old_entry_id,$new_entry_id,$info,$restore) {
+
+ global $CFG;
+
+ $status = true;
+
+ //Get the comments array
+ $aliases = $info['#']['ALIASES']['0']['#']['ALIAS'];
+
+ //Iterate over comments
+ for($i = 0; $i < sizeof($aliases); $i++) {
+ $alias_info = $aliases[$i];
+
+ //Now, build the GLOSSARY_ALIAS record structure
+ $alias->entryid = $new_entry_id;
+ $alias->name = backup_todb($alias_info['#']['NAME']['0']['#']);
+
+ //The structure is equal to the db, so insert the glossary_comments
+ $newid = insert_record ("glossary_alias",$alias);
+
+ //Do some output
+ if (($i+1) % 50 == 0) {
+ echo ".";
+ if (($i+1) % 1000 == 0) {
+ echo "<br>";
+ }
+ backup_flush(300);
+ }
+
+ if (!$newid) {
+ $status = false;
+ }
+ }
+
+ return $status;
+ }
+
//This function restores the glossary_categories
function glossary_categories_restore_mods($old_glossary_id,$new_glossary_id,$info,$restore) {