Permalink
Browse files

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

lacking backup/restore permission at system level.
  • Loading branch information...
1 parent 32409b6 commit b270b641f66d0a3dce0fa0512eaee54e073c6252 @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
@@ -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
View
@@ -224,7 +224,9 @@
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");
choose_from_menu($user_options, "backup_users", $backup_users, "");
@@ -322,6 +322,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
@@ -444,8 +444,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 b270b64

Please sign in to comment.