Skip to content

Commit

Permalink
MDL-58594 backup: setting locked by permission can not be overriden
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed May 1, 2017
1 parent 06e3b6d commit 0302548
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backup/util/settings/base_setting.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ abstract class base_setting {
protected $visibility; // visibility of the setting (setting_base::VISIBLE/setting_base::HIDDEN)
protected $status; // setting_base::NOT_LOCKED/setting_base::LOCKED_BY_PERMISSION...

/** @var setting_dependency[] */
protected $dependencies = array(); // array of dependent (observer) objects (usually setting_base ones)
protected $dependenton = array();

Expand Down Expand Up @@ -201,6 +202,12 @@ public function set_visibility($visibility) {
public function set_status($status) {
$status = $this->validate_status($status);

if (($this->status == base_setting::LOCKED_BY_PERMISSION || $this->status == base_setting::LOCKED_BY_CONFIG)
&& $status == base_setting::LOCKED_BY_HIERARCHY) {
// Lock by permission or config can not be overriden by lock by hierarchy.
return;
}

// If the setting is being unlocked first check whether an other settings
// this setting is dependent on are locked. If they are then we still don't
// want to lock this setting.
Expand Down
5 changes: 5 additions & 0 deletions backup/util/settings/setting_dependency.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public function is_locked() {
* @return bool
*/
protected function process_value_change($oldvalue) {
if ($this->dependentsetting->get_status() == base_setting::LOCKED_BY_PERMISSION ||
$this->dependentsetting->get_status() == base_setting::LOCKED_BY_CONFIG) {
// When setting is locked by permission or config do not apply dependencies.
return false;
}
$prevalue = $this->dependentsetting->get_value();
// If the setting is the desired value enact the dependency
if ($this->setting->get_value() == $this->value) {
Expand Down

0 comments on commit 0302548

Please sign in to comment.