Permalink
Browse files

role_assignments are only exported for target users. MDL-13115

  • Loading branch information...
stronk7
stronk7 committed Jan 24, 2008
1 parent e3d41ef commit 3dcb2cda3667a812a6f43d8b9d60fc87ed2cb504
Showing with 30 additions and 27 deletions.
  1. +30 −27 backup/backuplib.php
@@ -667,7 +667,7 @@ function backup_course_start ($bf,$preferences) {
/// write local course overrides here?
write_role_overrides_xml($bf, $context, 3);
/// write role_assign code here
write_role_assignments_xml($bf, $context, 3);
write_role_assignments_xml($bf, $preferences, $context, 3);
//Print header end
fwrite ($bf,end_tag("HEADER",2,true));
} else {
@@ -918,7 +918,7 @@ function backup_course_blocks ($bf,$preferences) {
$context = get_context_instance(CONTEXT_BLOCK, $instance->id);
write_role_overrides_xml($bf, $context, 4);
/// write role_assign code here
write_role_assignments_xml($bf, $context, 4);
write_role_assignments_xml($bf, $preferences, $context, 4);
//End Block
fwrite ($bf,end_tag('BLOCK',3,true));
}
@@ -1054,9 +1054,9 @@ function backup_course_modules ($bf,$preferences,$section) {
// get all the role_capabilities overrides in this mod
write_role_overrides_xml($bf, $context, 6);
/// write role_assign code here
write_role_assignments_xml($bf, $context, 6);
write_role_assignments_xml($bf, $preferences, $context, 6);
/// write role_assign code here
fwrite ($bf,end_tag("MOD",5,true));
}
//check for next
@@ -1270,7 +1270,7 @@ function backup_user_info ($bf,$preferences) {
write_role_overrides_xml($bf, $context, 4);
/// write role_assign code here
write_role_assignments_xml($bf, $context, 4);
write_role_assignments_xml($bf, $preferences, $context, 4);
//End User tag
fwrite ($bf,end_tag("USER",3,true));
//Do some output
@@ -2303,40 +2303,43 @@ function write_role_overrides_xml($bf, $context, $startlevel) {
}
fwrite ($bf, end_tag("ROLES_OVERRIDES", $startlevel, true));
}
/* function to print xml for assignment */
function write_role_assignments_xml($bf, $context, $startlevel) {
function write_role_assignments_xml($bf, $preferences, $context, $startlevel) {
/// write role_assign code here
fwrite ($bf, start_tag("ROLES_ASSIGNMENTS", $startlevel, true));
if ($roles = get_roles_with_assignment_on_context($context)) {
foreach ($roles as $role) {
foreach ($roles as $role) {
fwrite ($bf, start_tag("ROLE", $startlevel+1, true));
fwrite ($bf, full_tag("ID", $startlevel+2, false, $role->id));
fwrite ($bf, full_tag("NAME", $startlevel+2, false, $role->name));
fwrite ($bf, full_tag("SHORTNAME", $startlevel+2, false, $role->shortname));
fwrite ($bf, full_tag("SHORTNAME", $startlevel+2, false, $role->shortname));
fwrite ($bf, start_tag("ASSIGNMENTS", $startlevel+2, true));
if ($assignments = get_users_from_role_on_context($role, $context)) {
foreach ($assignments as $assignment) {
fwrite ($bf, start_tag("ASSIGNMENT", $startlevel+3, true));
fwrite ($bf, full_tag("USERID", $startlevel+4, false, $assignment->userid));
fwrite ($bf, full_tag("HIDDEN", $startlevel+4, false, $assignment->hidden));
fwrite ($bf, full_tag("TIMESTART", $startlevel+4, false, $assignment->timestart));
fwrite ($bf, full_tag("TIMEEND", $startlevel+4, false, $assignment->timeend));
fwrite ($bf, full_tag("TIMEMODIFIED", $startlevel+4, false, $assignment->timemodified));
if (!isset($assignment->modifierid)) {
$assignment->modifierid = 0;
/// Role assignments are only sent to backup if the user is one target user
if (backup_getid($preferences->backup_unique_code, 'user', $assignment->userid)) {
fwrite ($bf, start_tag("ASSIGNMENT", $startlevel+3, true));
fwrite ($bf, full_tag("USERID", $startlevel+4, false, $assignment->userid));
fwrite ($bf, full_tag("HIDDEN", $startlevel+4, false, $assignment->hidden));
fwrite ($bf, full_tag("TIMESTART", $startlevel+4, false, $assignment->timestart));
fwrite ($bf, full_tag("TIMEEND", $startlevel+4, false, $assignment->timeend));
fwrite ($bf, full_tag("TIMEMODIFIED", $startlevel+4, false, $assignment->timemodified));
if (!isset($assignment->modifierid)) {
$assignment->modifierid = 0;
}
fwrite ($bf, full_tag("MODIFIERID", $startlevel+4, false, $assignment->modifierid));
fwrite ($bf, full_tag("ENROL", $startlevel+4, false, $assignment->enrol));
fwrite ($bf, full_tag("SORTORDER", $startlevel+4, false, $assignment->sortorder));
fwrite ($bf, end_tag("ASSIGNMENT", $startlevel+3, true));
}
fwrite ($bf, full_tag("MODIFIERID", $startlevel+4, false, $assignment->modifierid));
fwrite ($bf, full_tag("ENROL", $startlevel+4, false, $assignment->enrol));
fwrite ($bf, full_tag("SORTORDER", $startlevel+4, false, $assignment->sortorder));
fwrite ($bf, end_tag("ASSIGNMENT", $startlevel+3, true));
}
}
}
fwrite ($bf, end_tag("ASSIGNMENTS", $startlevel+2, true));
fwrite ($bf, end_tag("ROLE", $startlevel+1, true));
}
}
fwrite ($bf, end_tag("ROLES_ASSIGNMENTS", $startlevel, true));
fwrite ($bf, end_tag("ROLE", $startlevel+1, true));
}
}
fwrite ($bf, end_tag("ROLES_ASSIGNMENTS", $startlevel, true));
}
?>

0 comments on commit 3dcb2cd

Please sign in to comment.