backup MDL-23437 Restore now locks the course_startdate setting if the user doesn...
authorSam Hemelryk <sam@moodle.com>
Fri, 10 Sep 2010 07:54:15 +0000 (07:54 +0000)
committerSam Hemelryk <sam@moodle.com>
Fri, 10 Sep 2010 07:54:15 +0000 (07:54 +0000)
backup/util/checks/restore_check.class.php

index c799837..20e1f94 100644 (file)
@@ -167,6 +167,16 @@ abstract class restore_check {
             }
         }
 
+        // Ensure the user has the rolldates capability. If not we want to lock this
+        // settings so that they cannot change it.
+        $hasrolldatescap = has_capability('moodle/restore:rolldates', $coursectx, $userid);
+        if ($type == backup::TYPE_1COURSE && !$hasrolldatescap) {
+            $datesetting = $restore_controller->get_plan()->get_setting('course_startdate');
+            if ($datesetting) {
+                $datesetting->set_status(base_setting::LOCKED_BY_PERMISSION);
+            }
+        }
+
         return true;
     }
 }