Permalink
Browse files

MDL-9251 backup/restore *all* users - is now forbidden for users

lacking backup/restore permission at system level. Backported from 19_STABLE
  • Loading branch information...
1 parent 368498d commit 7e4a6aa4a13aebee401204869bac9db04b4cdb6e @stronk7 stronk7 committed Nov 21, 2009
Showing with 15 additions and 3 deletions.
  1. +5 −0 backup/backup_check.html
  2. +3 −1 backup/backup_form.html
  3. +5 −0 backup/restore_check.html
  4. +2 −2 backup/restore_form.html
View
5 backup/backup_check.html
@@ -64,6 +64,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
View
4 backup/backup_form.html
@@ -224,7 +224,9 @@
echo "<td align=\"right\" colspan=\"2\"><b>";
echo get_string("users").":";
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");
choose_from_menu($user_options, "backup_users", $backup_users, "");
View
5 backup/restore_check.html
@@ -282,6 +282,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;
View
4 backup/restore_form.html
@@ -399,8 +399,8 @@
//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");

0 comments on commit 7e4a6aa

Please sign in to comment.