From a89fcd7a2cc3b50343ce8e895802652bbbca86f6 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Sat, 21 Nov 2009 11:56:27 +0000 Subject: [PATCH] MDL-9251 backup/restore *all* users - is now forbidden for users lacking backup/restore permission at system level. Merged from 19_STABLE --- backup/backup_check.html | 5 +++++ backup/backup_form.html | 4 +++- backup/restore_check.html | 5 +++++ backup/restore_form.html | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/backup/backup_check.html b/backup/backup_check.html index 853a099280..86350b6bc6 100644 --- a/backup/backup_check.html +++ b/backup/backup_check.html @@ -71,6 +71,11 @@ } + // 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 diff --git a/backup/backup_form.html b/backup/backup_form.html index 87025650f9..1b21f6c3b0 100644 --- a/backup/backup_form.html +++ b/backup/backup_form.html @@ -223,7 +223,9 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { echo ""; echo ''; echo ""; - $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)); diff --git a/backup/restore_check.html b/backup/restore_check.html index 1be9cff6d7..a97933def7 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -326,6 +326,11 @@ } } + // 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; diff --git a/backup/restore_form.html b/backup/restore_form.html index 3976a6ebb8..ed0c9eda25 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -446,8 +446,8 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { //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"); -- 2.39.5