diff --git a/mod/chat/backuplib.php b/mod/chat/backuplib.php index 12d559328b4..af7dc77a16f 100644 --- a/mod/chat/backuplib.php +++ b/mod/chat/backuplib.php @@ -74,6 +74,7 @@ //Print message contents fwrite ($bf,full_tag("ID",6,false,$cha_mes->id)); fwrite ($bf,full_tag("USERID",6,false,$cha_mes->userid)); + fwrite ($bf,full_tag("GROUPID",6,false,$cha_mes->groupid)); fwrite ($bf,full_tag("SYSTEM",6,false,$cha_mes->system)); fwrite ($bf,full_tag("MESSAGE_TEXT",6,false,$cha_mes->message)); fwrite ($bf,full_tag("TIMESTAMP",6,false,$cha_mes->timestamp)); diff --git a/mod/chat/restorelib.php b/mod/chat/restorelib.php index 85c3ff67e5d..ea4088d8086 100644 --- a/mod/chat/restorelib.php +++ b/mod/chat/restorelib.php @@ -102,6 +102,7 @@ //Now, build the CHAT_MESSAGES record structure $message->chatid = $new_chat_id; $message->userid = backup_todb($mes_info['#']['USERID']['0']['#']); + $message->groupid = backup_todb($mes_info['#']['GROUPID']['0']['#']); $message->system = backup_todb($mes_info['#']['SYSTEM']['0']['#']); $message->message = backup_todb($mes_info['#']['MESSAGE_TEXT']['0']['#']); $message->timestamp = backup_todb($mes_info['#']['TIMESTAMP']['0']['#']); @@ -112,6 +113,12 @@ $message->userid = $user->new_id; } + //We have to recode the groupid field + $group = backup_getid($restore->backup_unique_code,"group",$message->groupid); + if ($group) { + $message->groupid = $group->new_id; + } + //The structure is equal to the db, so insert the chat_message $newid = insert_record ("chat_messages",$message);