]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9251 backup/restore *all* users - is now forbidden for users
authorEloy Lafuente <stronk7@moodle.org>
Sat, 21 Nov 2009 11:56:27 +0000 (11:56 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Sat, 21 Nov 2009 11:56:27 +0000 (11:56 +0000)
lacking backup/restore permission at system level. Merged from 19_STABLE

backup/backup_check.html
backup/backup_form.html
backup/restore_check.html
backup/restore_form.html

index 853a099280a0d810fc63c8e70f450f0f4c04f88b..86350b6bc6d698049bdfdbc3d1dbde0e83eb63de 100644 (file)
 
     }
 
+    // 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
index 87025650f9ea83af51d766e47f832c3fc88a4c6c..1b21f6c3b0ef3a737ddcc8373d50333478d8688d 100644 (file)
@@ -223,7 +223,9 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
             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));
index 1be9cff6d70cc9c8d673bdd836c54d55f0c37e41..a97933def719466e5f2ef27daeeda5b509213490 100644 (file)
             }
         }
 
+        // 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;
index 3976a6ebb81034b5b4586888aca3e34c6ffef95d..ed0c9eda2559641dd6e90b6a360e8efb911f13b6 100644 (file)
@@ -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");