Refactor checking settings change into separate method
[MAILPOET-2079]
This commit is contained in:
@ -40,17 +40,15 @@ class Settings extends APIEndpoint {
|
|||||||
WPFunctions::get()->__('You have not specified any settings to be saved.', 'mailpoet'),
|
WPFunctions::get()->__('You have not specified any settings to be saved.', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$original_inactivation_interval = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
|
$old_settings = $this->settings->getAll();
|
||||||
// Will be uncommented on task [MAILPOET-1998]
|
// Will be uncommented on task [MAILPOET-1998]
|
||||||
// $signup_confirmation = $this->settings->get('signup_confirmation.enabled');
|
// $signup_confirmation = $this->settings->get('signup_confirmation.enabled');
|
||||||
foreach ($settings as $name => $value) {
|
foreach ($settings as $name => $value) {
|
||||||
$this->settings->set($name, $value);
|
$this->settings->set($name, $value);
|
||||||
}
|
}
|
||||||
if (isset($settings['deactivate_subscriber_after_inactive_days'])
|
|
||||||
&& $original_inactivation_interval !== (int)$settings['deactivate_subscriber_after_inactive_days']
|
$this->onSettingsChange($old_settings, $this->settings->getAll());
|
||||||
) {
|
|
||||||
$this->onInactiveSubscribersIntervalChange();
|
|
||||||
}
|
|
||||||
$bridge = new Bridge();
|
$bridge = new Bridge();
|
||||||
$bridge->onSettingsSave($settings);
|
$bridge->onSettingsSave($settings);
|
||||||
// Will be uncommented on task [MAILPOET-1998]
|
// Will be uncommented on task [MAILPOET-1998]
|
||||||
@ -61,6 +59,15 @@ class Settings extends APIEndpoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function onSettingsChange($old_settings, $new_settings) {
|
||||||
|
// Recalculate inactive subscribers
|
||||||
|
$old_inactivation_interval = $old_settings['deactivate_subscriber_after_inactive_days'];
|
||||||
|
$new_inactivation_interval = $new_settings['deactivate_subscriber_after_inactive_days'];
|
||||||
|
if ($old_inactivation_interval !== $new_inactivation_interval) {
|
||||||
|
$this->onInactiveSubscribersIntervalChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function onInactiveSubscribersIntervalChange() {
|
private function onInactiveSubscribersIntervalChange() {
|
||||||
$task = ScheduledTask::where('type', InactiveSubscribers::TASK_TYPE)
|
$task = ScheduledTask::where('type', InactiveSubscribers::TASK_TYPE)
|
||||||
->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
|
->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
|
||||||
|
Reference in New Issue
Block a user