Skip to content

Commit

Permalink
MDL-28488 backup - '[backup|restore]:configure cap does not control i…
Browse files Browse the repository at this point in the history
…mport mode anymore
  • Loading branch information
stronk7 committed Sep 11, 2011
1 parent 9d74bab commit 56a1642
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
20 changes: 12 additions & 8 deletions backup/util/checks/backup_check.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -217,15 +217,19 @@ public static function check_security($backup_controller, $apply) {
} }


// Check the user has the ability to configure the backup. If not then we need // 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. // to lock all settings by permission so that no changes can be made. This does
$hasconfigcap = has_capability('moodle/backup:configure', $coursectx, $userid); // not apply to the import facility, where the activities must be always enabled
if (!$hasconfigcap) { // to be able to pick them
$settings = $backup_controller->get_plan()->get_settings(); if ($mode != backup::MODE_IMPORT) {
foreach ($settings as $setting) { $hasconfigcap = has_capability('moodle/backup:configure', $coursectx, $userid);
if ($setting->get_name()=='filename') { if (!$hasconfigcap) {
continue; $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);
} }
} }


Expand Down
16 changes: 10 additions & 6 deletions backup/util/checks/restore_check.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@ public static function check_security($restore_controller, $apply) {
} }


// Check the user has the ability to configure the restore. If not then we need // 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. // to lock all settings by permission so that no changes can be made. This does
$hasconfigcap = has_capability('moodle/restore:configure', $coursectx, $userid); // not apply to the import facility, where all the activities (picked on backup)
if (!$hasconfigcap) { // are restored automatically without restore UI
$settings = $restore_controller->get_plan()->get_settings(); if ($mode != backup::MODE_IMPORT) {
foreach ($settings as $setting) { $hasconfigcap = has_capability('moodle/restore:configure', $coursectx, $userid);
$setting->set_status(base_setting::LOCKED_BY_PERMISSION); if (!$hasconfigcap) {
$settings = $restore_controller->get_plan()->get_settings();
foreach ($settings as $setting) {
$setting->set_status(base_setting::LOCKED_BY_PERMISSION);
}
} }
} }


Expand Down

0 comments on commit 56a1642

Please sign in to comment.