}
}
}
- $backupprefs->backup_user_files = 0;
- $backupprefs->backup_logs = 0;
- $backupprefs->backup_messages = 0;
+ $backupprefs->backup_user_files = 0;
+ $backupprefs->backup_logs = 0;
+ $backupprefs->backup_messages = 0;
+ $backupprefs->backuproleassignments = array();
}
print_simple_box("<font color=\"red\">".get_string("backupnoneusersinfo")."</font>","center", "70%", '', "20", "noticebox");
echo "<hr />";
}
//Now print the Course Files tr conditionally
- if ($backupprefs->backup_course_files) {
+ if ($backupprefs->backup_course_files) {
echo "<tr>";
echo "<td colspan=\"2\"><b>";
echo get_string("includecoursefiles").'</b>';
print_table($table);
echo "</td></tr>";
}
- //Now print the site Files tr conditionally
- if ($backupprefs->backup_site_files) {
+
+ //Now print the site Files tr conditionally
+ if ($backupprefs->backup_site_files) {
echo "<tr>";
echo "<td colspan=\"2\"><b>";
echo get_string("includesitefiles").'</b>';
print_table($table);
echo "</td></tr>";
}
+
+ //Now print the role assignments information conditionally
+ if (!empty($backupprefs->backuproleassignments)) {
+ echo "<tr>";
+ echo "<td colspan=\"2\"><b>";
+ echo get_string("includeroleassignments").'</b>';
+ //Print info
+ $table->data = array(array(get_string('roles'), count($backupprefs->backuproleassignments)));
+ print_table($table);
+ echo "</td></tr>";
+ }
}
// now keep it for next time.
$var = 'exists_one_'.$modname;
if (!empty($$var)) {
echo '<tr><td></td><td colspan="3"><table class="backup-form-instances">';
- $instances = get_all_instances_in_course($modname,$course);
+ $instances = get_all_instances_in_course($modname, $course, NULL, true);
foreach ($instances as $instance) {
echo '<tr><td>';
$var = 'backup_'.$modname.'_instance_'.$instance->id;
}
}
+ //Now print a place to select which role assignments to back up.
+ if (empty($to)) {
+ //Line
+ echo "<tr><td colspan=\"4\"><hr /></td></tr>\n";
+
+ echo "<tr>";
+ echo "<td align=\"right\" valign=\"top\" colspan=\"2\"><b>";
+ echo get_string("backuproleassignments").":";
+ echo "</b></td><td colspan=\"2\">";
+ $roles = get_records('role', '', '', 'sortorder');
+ foreach ($roles as $role) {
+ print_checkbox('backupassignments_' . $role->shortname, 1, true, strip_tags(format_string($role->name, true)));
+ echo "<br />";
+ }
+ echo "<a href=\"#\" onclick=\"selectItemInCheckboxByName('form1', 'backupassignments_', true); return false;\">". get_string("all")."</a>/";
+ echo "<a href=\"#\" onclick=\"selectItemInCheckboxByName('form1', 'backupassignments_', false); return false;\">". get_string("none")."</a>";
+ echo "</td></tr>";
+ }
+
$backup_unique_code = time();
//Calculate the backup string
/// 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, $context, 3, $preferences);
//Print header end
fwrite ($bf,end_tag("HEADER",2,true));
} else {
$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, $context, 4, $preferences);
//End Block
fwrite ($bf,end_tag('BLOCK',3,true));
}
fwrite ($bf,full_tag("GROUPMEMBERSONLY",6,false,$course_module[$tok]->groupmembersonly));
// 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_assign code here
+ /// write role_assign code here
+ write_role_assignments_xml($bf, $context, 6, $preferences);
+ /// write role_assign code here
fwrite ($bf,end_tag("MOD",5,true));
}
write_role_overrides_xml($bf, $context, 4);
/// write role_assign code here
- write_role_assignments_xml($bf, $context, 4);
- //End User tag
+ write_role_assignments_xml($bf, $context, 4, $preferences);
+ //End User tag
fwrite ($bf,end_tag("USER",3,true));
//Do some output
$counter++;
$var = 'exists_one_'.$modname;
$preferences->$var = true;
$varname = $modname.'_instances';
- $preferences->$varname = get_all_instances_in_course($modname,$course);
+ $preferences->$varname = get_all_instances_in_course($modname, $course, NULL, true);
foreach ($preferences->$varname as $instance) {
$preferences->mods[$modname]->instances[$instance->id]->name = $instance->name;
$var = 'backup_'.$modname.'_instance_'.$instance->id;
$preferences->backup_name = required_param('backup_name',PARAM_FILE);
$preferences->backup_unique_code = required_param('backup_unique_code');
+ $roles = get_records('role', '', '', 'sortorder');
+ $preferences->backuproleassignments = array();
+ foreach ($roles as $role) {
+ if (optional_param('backupassignments_' . $role->shortname, 0, PARAM_INT)) {
+ $preferences->backuproleassignments[$role->id] = $role;
+ }
+ }
+
// put it (back) in the session
$SESSION->backupprefs[$course->id] = $preferences;
}
}
/* function to print xml for assignment */
- function write_role_assignments_xml($bf, $context, $startlevel) {
- /// write role_assign code here
+ function write_role_assignments_xml($bf, $context, $startlevel, $preferences) {
+ /// 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) {
+ if (!isset($preferences->backuproleassignments[$role->id])) {
+ continue;
+ }
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));
$string['backupnoneusersinfo'] = 'Notice: You have selected to backup no users (\"none\"), so all the modules backup have been switched to \"without user data\" mode. Please note that the \"exercise\" and \"workshop\" modules aren\'t compatible with this type of backup, so they have been deactivated completely.';
$string['backupnonisowarning'] = 'Warning: this backup is from a non-Unicode version of Moodle (pre 1.6). If this backup contains any non-ISO-8859-1 texts then they may be CORRUPTED if you try to restore them to this Unicode version of Moodle. See the <a href=\"http://docs.moodle.org/en/Backup_FAQ\">Backup FAQ</a> for more information about how to recover this backup correctly.';
$string['backuporiginalname'] = 'Backup Name';
+$string['backuproleassignments'] = 'Backup role assignments for these roles';
$string['backupsavetohelp'] = 'Full path to the directory where you want to save the backup files<br />(leave blank to save in its course default dir)';
$string['backupschedulehelp'] = 'Choose which days of the week to perform automated backups.';
$string['backupsitefileshelp'] = 'If enabled then site files used in courses will be included in automated backups';
$string['includemoduleuserdata'] = 'Include module user data';
$string['includeneededusers'] = 'Include Needed Users';
$string['includenoneusers'] = 'Include No Users';
+$string['includeroleassignments'] = 'Include role assignments';
$string['includesitefiles'] = 'Include Site Files Used in This Course';
$string['includeuserfiles'] = 'Include User Files';
$string['info'] = 'Information';