MDL-69448 backup: fix capability checks when unable to copy user data.

When a given user doesn't have the capability to "Include user data"
during course copying, freeze the form element rather than not adding
it at all.

This caused problems as the element was required before preceding with
the course copy.
This commit is contained in:
Paul Holden
2020-09-04 08:20:04 +01:00
parent 916809d995
commit f2b1242364
4 changed files with 14 additions and 9 deletions
+3 -1
View File
@@ -72,14 +72,16 @@ class asynchronous_copy_task extends adhoc_task {
$keepuserdata = (bool)$copyinfo->userdata;
$keptroles = $copyinfo->keptroles;
$backupplan->get_setting('users')->set_value('1');
$bc->set_kept_roles($keptroles);
// If we are not keeping user data don't include users or data in the backup.
// In this case we'll add the user enrolments at the end.
// Also if we have no roles to keep don't backup users.
if (empty($keptroles) || !$keepuserdata) {
$backupplan->get_setting('users')->set_status(\backup_setting::NOT_LOCKED);
$backupplan->get_setting('users')->set_value('0');
} else {
$backupplan->get_setting('users')->set_value('1');
}
// Do some preflight checks on the backup.