fix: [settings] purge previous setting, push new one

pull/5526/head
iglocska 2020-01-20 10:07:11 +01:00
parent 3d473ca29f
commit 43079f6dc1
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 6 additions and 6 deletions

View File

@ -21,19 +21,19 @@ class AdminSetting extends AppModel
$setting_object = $this->find('first', array(
'conditions' => array('setting' => $setting)
));
if (!empty($setting_object)) {
$setting_object['AdminSetting']['value'] = $value;
} else {
$this->create();
$setting_object['AdminSetting'] = array('setting' => $setting, 'value' => $value);
}
$this->deleteAll('setting' => $setting);
$this->create();
$setting_object['AdminSetting'] = array('setting' => $setting, 'value' => $value);
if ($this->save($setting_object)) {
return true;
} else {
$this->create();
$this->save($setting_object);
return $this->validationErrors;
}
}
public function getSetting($setting)
{
$setting_object = $this->find('first', array(