mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Now user profile fileds and user tags are included in backups. Part of MDL-6856 ; merged from 19_STABLE
This commit is contained in:
parent
0607c0f515
commit
9e56dd25d3
@ -1147,6 +1147,7 @@
|
||||
function backup_user_info ($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
require_once ($CFG->dirroot.'/tag/lib.php');
|
||||
|
||||
$status = true;
|
||||
|
||||
@ -1249,6 +1250,43 @@
|
||||
//End ROLES tag
|
||||
fwrite ($bf,end_tag("ROLES",4,true));
|
||||
|
||||
//Check if we have custom profile fields to backup
|
||||
if ($cpfields = get_records_sql("SELECT uif.shortname, uif.datatype, uid.data
|
||||
FROM {$CFG->prefix}user_info_field uif,
|
||||
{$CFG->prefix}user_info_data uid
|
||||
WHERE uif.id = uid.fieldid
|
||||
AND uid.userid = $user->id")) {
|
||||
//Start USER_CUSTOM_PROFILE_FIELDS tag
|
||||
fwrite ($bf,start_tag("USER_CUSTOM_PROFILE_FIELDS",4,true));
|
||||
//Write custom profile fields
|
||||
foreach ($cpfields as $cpfield) {
|
||||
fwrite ($bf,start_tag("USER_CUSTOM_PROFILE_FIELD",5,true));
|
||||
fwrite ($bf,full_tag("FIELD_NAME",6,false,$cpfield->shortname));
|
||||
fwrite ($bf,full_tag("FIELD_TYPE",6,false,$cpfield->datatype));
|
||||
fwrite ($bf,full_tag("FIELD_DATA",6,false,$cpfield->data));
|
||||
fwrite ($bf,end_tag("USER_CUSTOM_PROFILE_FIELD",5,true));
|
||||
}
|
||||
//End USER_CUSTOM_PROFILE_FIELDS tag
|
||||
fwrite ($bf,end_tag("USER_CUSTOM_PROFILE_FIELDS",4,true));
|
||||
}
|
||||
|
||||
//Check if we have user tags to backup
|
||||
if (!empty($CFG->usetags)) {
|
||||
if ($tags = get_item_tags('user', $user->id)) { //This return them ordered by default
|
||||
//Start USER_TAGS tag
|
||||
fwrite ($bf,start_tag("USER_TAGS",4,true));
|
||||
//Write user tags fields
|
||||
foreach ($tags as $tag) {
|
||||
fwrite ($bf,start_tag("USER_TAG",5,true));
|
||||
fwrite ($bf,full_tag("NAME",6,false,$tag->name));
|
||||
fwrite ($bf,full_tag("RAWNAME",6,false,$tag->rawname));
|
||||
fwrite ($bf,end_tag("USER_TAG",5,true));
|
||||
}
|
||||
//End USER_TAGS tag
|
||||
fwrite ($bf,end_tag("USER_TAGS",4,true));
|
||||
}
|
||||
}
|
||||
|
||||
//Check if we have user_preferences to backup
|
||||
if ($preferences_data = get_records("user_preferences","userid",$user->old_id)) {
|
||||
//Start USER_PREFERENCES tag
|
||||
|
Loading…
x
Reference in New Issue
Block a user