fwrite ($bf,full_tag("ENROLENDDATE",3,false,$course->enrolenddate));
fwrite ($bf,full_tag("ENROLPERIOD",3,false,$course->enrolperiod));
fwrite ($bf,full_tag("ENABLECOMPLETION",3,false,$course->enablecompletion));
-
- /// write local course overrides here?
- write_role_overrides_xml($bf, $context, 3);
- /// write role_assign code here
- write_role_assignments_xml($bf, $preferences, $context, 3);
- //Print header end
+
+ // Write role assigns, overrides, etc.
+ write_per_context_data($bf, $preferences, $context, 3);
+
+ // Print header end
fwrite ($bf,end_tag("HEADER",2,true));
} else {
$status = false;
$status = $blockobj->instance_backup($bf, $preferences);
fwrite ($bf,end_tag('INSTANCEDATA',4,true));
}
+
+ // Write role assigns, overrides, etc.
$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, $preferences, $context, 4);
+ write_per_context_data($bf, $preferences, $context, 4);
+
//End Block
fwrite ($bf,end_tag('BLOCK',3,true));
}
fwrite ($bf,full_tag("AVAILABLEUNTIL",6,false,$course_module->availableuntil));
fwrite ($bf,full_tag("SHOWAVAILABILITY",6,false,$course_module->showavailability));
- // 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, $preferences, $context, 6);
+ // Write role assigns, overrides, etc.
+ write_per_context_data($bf, $preferences, $context, 6);
+
// write completion data if enabled and user data enabled
require_once($CFG->libdir.'/completionlib.php');
$completion=new completion_info($course);
fwrite ($bf,end_tag("USER_PREFERENCES",4,true));
}
+ // Write role assigns, overrides, etc.
$context = get_context_instance(CONTEXT_USER, $user->old_id);
+ write_per_context_data($bf, $preferences, $context, 4);
- write_role_overrides_xml($bf, $context, 4);
- /// write role_assign code here
- write_role_assignments_xml($bf, $preferences, $context, 4);
//End User tag
fwrite ($bf,end_tag("USER",3,true));
//Do some output
return $roles;
}
+ /**
+ * Writes out all of the data that should appear for every context.
+ */
+ function write_per_context_data($bf, $preferences, $context, $startlevel) {
+ write_role_overrides_xml($bf, $context, $startlevel);
+ write_role_assignments_xml($bf, $preferences, $context, $startlevel);
+ }
+
/**
* function to print xml for overrides
*/
// try to restore roles even when restore is going to fail - teachers might have
// at least some role assigned - this is not correct though
$status = restore_create_roles($restore, $xml_file) && $status;
- $status = restore_roles_settings($restore, $xml_file) && $status;
+ $status = restore_roles_and_filter_settings($restore, $xml_file) && $status;
//Now if all is OK, update:
// - course modinfo field
$course = $DB->get_record("course", array("id"=>$restore->course_id));
fix_course_sortorder();
// Check if the user has course update capability in the newly restored course
- // there is no need to load his capabilities again, because restore_roles_settings
+ // there is no need to load his capabilities again, because restore_roles_and_filter_settings
// would have loaded it anyway, if there is any assignments.
// fix for MDL-6831
$newcontext = get_context_instance(CONTEXT_COURSE, $restore->course_id);
* in course/user/block/mod level, it passed through
* the xml file again
*/
- function restore_roles_settings($restore, $xmlfile) {
+ function restore_roles_and_filter_settings($restore, $xmlfile) {
// data pulls from course, mod, user, and blocks
/*******************************************************