}
+ // Re-enforce 'moodle/site:backup' at system context to be able to backup all users
+ if ($backupprefs->backup_users == 0 and !has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
+ $backupprefs->backup_users = 1; // users => course
+ }
+
// Re-enforce moodle/backup:userinfo capability
if (!$backupuserinfo) {
$backupprefs->backup_users = 2; // users => none
echo "<td align=\"right\" colspan=\"2\"><b>";
echo '<label for="menubackup_users">'.get_string ("users").'</label>';
echo "</b></td><td colspan=\"2\">";
- $user_options[0] = get_string("all");
+ if (has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
+ $user_options[0] = get_string("all");
+ }
$user_options[1] = get_string("course");
$user_options[2] = get_string("none");
echo $OUTPUT->select(html_select::make($user_options, "backup_users", $backup_users, false));
}
}
+ // Re-enforce 'moodle/site:restore' at system context to be able to restore all users
+ if ($restore->users == 0 and !has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
+ $restore->users = 1; // users => course
+ }
+
// Re-enforce moodle/restore:userinfo capability
if (!$restoreuserinfo) {
$userinfocheck = true;
//If some user is present in the backup file
if (($info->backup_users == "all" or $info->backup_users == "course") and $restoreuserinfo) {
$user_options = array();
- //If all users are in the backup file
- if ($info->backup_users == "all") {
+ //If all users are in the backup file and user has 'moodle/site:restore' at system level
+ if ($info->backup_users == "all" and has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
$user_options[0] = get_string("all");
}
$user_options[1] = get_string("course");