From 56a1642c5bff53a35adbdb86acfa90099286e1ce Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 11 Sep 2011 19:09:59 +0200 Subject: [PATCH] MDL-28488 backup - '[backup|restore]:configure cap does not control import mode anymore --- backup/util/checks/backup_check.class.php | 20 ++++++++++++-------- backup/util/checks/restore_check.class.php | 16 ++++++++++------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/backup/util/checks/backup_check.class.php b/backup/util/checks/backup_check.class.php index 63ec0cd16a8..881c73c3ae2 100644 --- a/backup/util/checks/backup_check.class.php +++ b/backup/util/checks/backup_check.class.php @@ -217,15 +217,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; + // to lock all settings by permission so that no changes can be made. This does + // not apply to the import facility, where the activities must be always enabled + // to be able to pick them + if ($mode != backup::MODE_IMPORT) { + $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); } - $setting->set_status(base_setting::LOCKED_BY_PERMISSION); } } diff --git a/backup/util/checks/restore_check.class.php b/backup/util/checks/restore_check.class.php index 0617732b8b9..915112cf230 100644 --- a/backup/util/checks/restore_check.class.php +++ b/backup/util/checks/restore_check.class.php @@ -156,12 +156,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); + // to lock all settings by permission so that no changes can be made. This does + // not apply to the import facility, where all the activities (picked on backup) + // are restored automatically without restore UI + if ($mode != backup::MODE_IMPORT) { + $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); + } } } -- 2.11.4.GIT