backup MDL-23437 Backup and restore now check moodle/backup|restore:configure capabil...
authorSam Hemelryk <sam@moodle.com>
Fri, 10 Sep 2010 07:38:13 +0000 (07:38 +0000)
committerSam Hemelryk <sam@moodle.com>
Fri, 10 Sep 2010 07:38:13 +0000 (07:38 +0000)
backup/util/checks/backup_check.class.php
backup/util/checks/restore_check.class.php

index e66c230..6dbd359 100644 (file)
@@ -218,6 +218,19 @@ abstract class backup_check {
             }
         }
 
+        // Check the user has the ability to configure the backup. If not then we need
+        // to lock all settings by permission so that no changes can be made.
+        $hasconfigcap = has_capability('moodle/backup:configure', $coursectx, $userid);
+        if (!$hasconfigcap) {
+            $settings = $backup_controller->get_plan()->get_settings();
+            foreach ($settings as $setting) {
+                if ($setting->get_name()=='filename') {
+                    continue;
+                }
+                $setting->set_status(base_setting::LOCKED_BY_PERMISSION);
+            }
+        }
+
         return true;
     }
 }
index 3e6252e..c799837 100644 (file)
@@ -157,6 +157,16 @@ abstract class restore_check {
             }
         }
 
+        // Check the user has the ability to configure the restore. If not then we need
+        // to lock all settings by permission so that no changes can be made.
+        $hasconfigcap = has_capability('moodle/restore:configure', $coursectx, $userid);
+        if (!$hasconfigcap) {
+            $settings = $restore_controller->get_plan()->get_settings();
+            foreach ($settings as $setting) {
+                $setting->set_status(base_setting::LOCKED_BY_PERMISSION);
+            }
+        }
+
         return true;
     }
 }