MDL-53716 competency: Do not restore competencies when disabled
authorFrederic Massart <fred@moodle.com>
Thu, 28 Apr 2016 04:02:12 +0000 (12:02 +0800)
committerFrederic Massart <fred@moodle.com>
Thu, 28 Apr 2016 10:41:30 +0000 (18:41 +0800)
backup/moodle2/restore_stepslib.php

index b6733e4..861dcae 100644 (file)
@@ -3186,6 +3186,11 @@ class restore_course_competencies_structure_step extends restore_structure_step
      */
     protected function execute_condition() {
 
+        // Do not restore when competencies are disabled.
+        if (!\core_competency\api::is_enabled()) {
+            return false;
+        }
+
         // Do not execute if the competencies XML file is not found.
         $fullpath = $this->task->get_taskbasepath();
         $fullpath = rtrim($fullpath, '/') . '/' . $this->filename;
@@ -3256,6 +3261,11 @@ class restore_activity_competencies_structure_step extends restore_structure_ste
      */
     protected function execute_condition() {
 
+        // Do not restore when competencies are disabled.
+        if (!\core_competency\api::is_enabled()) {
+            return false;
+        }
+
         // Do not execute if the competencies XML file is not found.
         $fullpath = $this->task->get_taskbasepath();
         $fullpath = rtrim($fullpath, '/') . '/' . $this->filename;