mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Messages backup improvement. MDL-13473 ; merged from 19_STABLE
This commit is contained in:
parent
75d46e24ab
commit
42af26a396
@ -802,19 +802,21 @@
|
|||||||
|
|
||||||
$status = true;
|
$status = true;
|
||||||
|
|
||||||
//Get info from messages
|
/// Check we have something to backup
|
||||||
$unreads = get_records ('message');
|
$unreads = count_records ('message');
|
||||||
$reads = get_records ('message_read');
|
$reads = count_records ('message_read');
|
||||||
$contacts= get_records ('message_contacts');
|
$contacts= count_records ('message_contacts');
|
||||||
|
|
||||||
if ($unreads || $reads || $contacts) {
|
if ($unreads || $reads || $contacts) {
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
//message open tag
|
/// message open tag
|
||||||
fwrite ($bf,start_tag("MESSAGES",2,true));
|
fwrite ($bf,start_tag("MESSAGES",2,true));
|
||||||
|
|
||||||
if ($unreads) {
|
if ($unreads) {
|
||||||
//Iterate over every unread
|
$rs_unreads = get_recordset('message');
|
||||||
foreach ($unreads as $unread) {
|
/// Iterate over every unread
|
||||||
//start message
|
while ($unread = rs_fetch_next_record($rs_unreads)) {
|
||||||
|
/// start message
|
||||||
fwrite($bf, start_tag("MESSAGE",3,true));
|
fwrite($bf, start_tag("MESSAGE",3,true));
|
||||||
fwrite ($bf,full_tag("ID",4,false,$unread->id));
|
fwrite ($bf,full_tag("ID",4,false,$unread->id));
|
||||||
fwrite ($bf,full_tag("STATUS",4,false,"UNREAD"));
|
fwrite ($bf,full_tag("STATUS",4,false,"UNREAD"));
|
||||||
@ -824,10 +826,10 @@
|
|||||||
fwrite ($bf,full_tag("FORMAT",4,false,$unread->format));
|
fwrite ($bf,full_tag("FORMAT",4,false,$unread->format));
|
||||||
fwrite ($bf,full_tag("TIMECREATED",4,false,$unread->timecreated));
|
fwrite ($bf,full_tag("TIMECREATED",4,false,$unread->timecreated));
|
||||||
fwrite ($bf,full_tag("MESSAGETYPE",4,false,$unread->messagetype));
|
fwrite ($bf,full_tag("MESSAGETYPE",4,false,$unread->messagetype));
|
||||||
//end message
|
/// end message
|
||||||
fwrite ($bf,end_tag("MESSAGE",3,true));
|
fwrite ($bf,end_tag("MESSAGE",3,true));
|
||||||
|
|
||||||
//Do some output
|
/// Do some output
|
||||||
$counter++;
|
$counter++;
|
||||||
if ($counter % 20 == 0) {
|
if ($counter % 20 == 0) {
|
||||||
echo ".";
|
echo ".";
|
||||||
@ -837,12 +839,14 @@
|
|||||||
backup_flush(300);
|
backup_flush(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rs_close($rs_unreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reads) {
|
if ($reads) {
|
||||||
//Iterate over every read
|
$rs_reads = get_recordset('message_read');
|
||||||
foreach ($reads as $read) {
|
/// Iterate over every unread
|
||||||
//start message
|
while ($read = rs_fetch_next_record($rs_reads)) {
|
||||||
|
/// start message
|
||||||
fwrite($bf, start_tag("MESSAGE",3,true));
|
fwrite($bf, start_tag("MESSAGE",3,true));
|
||||||
fwrite ($bf,full_tag("ID",4,false,$read->id));
|
fwrite ($bf,full_tag("ID",4,false,$read->id));
|
||||||
fwrite ($bf,full_tag("STATUS",4,false,"READ"));
|
fwrite ($bf,full_tag("STATUS",4,false,"READ"));
|
||||||
@ -854,10 +858,10 @@
|
|||||||
fwrite ($bf,full_tag("MESSAGETYPE",4,false,$read->messagetype));
|
fwrite ($bf,full_tag("MESSAGETYPE",4,false,$read->messagetype));
|
||||||
fwrite ($bf,full_tag("TIMEREAD",4,false,$read->timeread));
|
fwrite ($bf,full_tag("TIMEREAD",4,false,$read->timeread));
|
||||||
fwrite ($bf,full_tag("MAILED",4,false,$read->mailed));
|
fwrite ($bf,full_tag("MAILED",4,false,$read->mailed));
|
||||||
//end message
|
/// end message
|
||||||
fwrite ($bf,end_tag("MESSAGE",3,true));
|
fwrite ($bf,end_tag("MESSAGE",3,true));
|
||||||
|
|
||||||
//Do some output
|
/// Do some output
|
||||||
$counter++;
|
$counter++;
|
||||||
if ($counter % 20 == 0) {
|
if ($counter % 20 == 0) {
|
||||||
echo ".";
|
echo ".";
|
||||||
@ -867,22 +871,24 @@
|
|||||||
backup_flush(300);
|
backup_flush(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rs_close($rs_reads);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contacts) {
|
if ($contacts) {
|
||||||
fwrite($bf, start_tag("CONTACTS",3,true));
|
fwrite($bf, start_tag("CONTACTS",3,true));
|
||||||
//Iterate over every contact
|
$rs_contacts = get_recordset('message_contacts');
|
||||||
foreach ($contacts as $contact) {
|
/// Iterate over every contact
|
||||||
//start contact
|
while ($contact = rs_fetch_next_record($rs_contacts)) {
|
||||||
|
/// start contact
|
||||||
fwrite($bf, start_tag("CONTACT",4,true));
|
fwrite($bf, start_tag("CONTACT",4,true));
|
||||||
fwrite ($bf,full_tag("ID",5,false,$contact->id));
|
fwrite ($bf,full_tag("ID",5,false,$contact->id));
|
||||||
fwrite ($bf,full_tag("USERID",5,false,$contact->userid));
|
fwrite ($bf,full_tag("USERID",5,false,$contact->userid));
|
||||||
fwrite ($bf,full_tag("CONTACTID",5,false,$contact->contactid));
|
fwrite ($bf,full_tag("CONTACTID",5,false,$contact->contactid));
|
||||||
fwrite ($bf,full_tag("BLOCKED",5,false,$contact->blocked));
|
fwrite ($bf,full_tag("BLOCKED",5,false,$contact->blocked));
|
||||||
//end contact
|
/// end contact
|
||||||
fwrite ($bf,end_tag("CONTACT",4,true));
|
fwrite ($bf,end_tag("CONTACT",4,true));
|
||||||
|
|
||||||
//Do some output
|
/// Do some output
|
||||||
$counter++;
|
$counter++;
|
||||||
if ($counter % 20 == 0) {
|
if ($counter % 20 == 0) {
|
||||||
echo ".";
|
echo ".";
|
||||||
@ -892,9 +898,11 @@
|
|||||||
backup_flush(300);
|
backup_flush(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rs_close($rs_contacts);
|
||||||
fwrite($bf, end_tag("CONTACTS",3,true));
|
fwrite($bf, end_tag("CONTACTS",3,true));
|
||||||
}
|
}
|
||||||
//messages close tag
|
|
||||||
|
/// messages close tag
|
||||||
$status = fwrite ($bf,end_tag("MESSAGES",2,true));
|
$status = fwrite ($bf,end_tag("MESSAGES",2,true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user