.htaccess
1 year ago
AbortQueueItem.php
1 year ago
AddToQueue.php
3 months ago
ClearAlerts.php
1 year ago
ClearCompletedQueueItems.php
1 year ago
CreateSupportUser.php
1 year ago
DeleteBackupJob.php
1 year ago
DeleteDestination.php
1 year ago
DeleteDownload.php
1 year ago
DeleteSchedule.php
1 year ago
DeleteSnapshot.php
1 year ago
DestinationSetExportConfig.php
1 year ago
DuplicateBackupJob.php
1 year ago
EditBackupNotes.php
1 year ago
EnableBackupJob.php
1 year ago
EnableDestination.php
1 year ago
ExecuteCron.php
1 year ago
FileManager.php
10 months ago
GetBackup.php
1 year ago
GetBackupJob.php
1 year ago
GetDashboard.php
1 year ago
GetDatabaseTables.php
1 year ago
GetDestination.php
1 year ago
GetLog.php
1 year ago
GetQRCode.php
1 year ago
GetQueueItem.php
1 year ago
GetSchedule.php
1 year ago
GetSettingsAutomation.php
1 year ago
GetSettingsGeneral.php
1 year ago
GetSettingsIntegrations.php
1 year ago
GetSettingsLogging.php
1 year ago
GetSettingsMaintenance.php
1 year ago
GetSettingsNotifications.php
1 year ago
GetSettingsPerformance.php
1 year ago
GetSettingsRestore.php
1 year ago
GetSettingsSecurity.php
1 year ago
GetSettingsUpdates.php
1 year ago
GetSystemInfo.php
11 months ago
ListAlerts.php
1 year ago
ListBackupJobs.php
1 year ago
ListBackups.php
1 year ago
ListDatabaseTables.php
1 year ago
ListDestinations.php
1 year ago
ListDownloads.php
1 year ago
ListQueueItems.php
4 months ago
ListSchedules.php
1 year ago
LockSnapshot.php
1 year ago
ManageBackupJob.php
1 year ago
ManageDestination.php
1 year ago
ManageSchedule.php
3 months ago
ManageSettingsAutomation.php
10 months ago
ManageSettingsGeneral.php
4 months ago
ManageSettingsIntegrations.php
1 year ago
ManageSettingsLogging.php
1 year ago
ManageSettingsMaintenance.php
1 year ago
ManageSettingsNotifications.php
1 year ago
ManageSettingsPerformance.php
1 year ago
ManageSettingsRestore.php
1 year ago
ManageSettingsSecurity.php
2 weeks ago
ManageSettingsUpdates.php
1 year ago
ManageShowcase.php
1 year ago
PanelPreload.php
1 year ago
SendTestEmail.php
1 year ago
StartOverQueueItem.php
1 year ago
ValidateDestination.php
1 year ago
ValidateMFA.php
1 year ago
index.html
1 year ago
web.config
1 year ago
ManageSettingsAutomation.php
80 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Ajax\Calls; |
| 4 | |
| 5 | use JetBackup\Ajax\aAjax; |
| 6 | use JetBackup\Crontab\Crontab; |
| 7 | use JetBackup\Exception\AjaxException; |
| 8 | use JetBackup\Factory; |
| 9 | use JetBackup\Settings\Automation; |
| 10 | use JetBackup\UserInput\UserInput; |
| 11 | use SleekDB\Exceptions\InvalidArgumentException; |
| 12 | use SleekDB\Exceptions\IOException; |
| 13 | |
| 14 | class ManageSettingsAutomation extends aAjax { |
| 15 | |
| 16 | /** |
| 17 | * @return bool |
| 18 | * @throws AjaxException |
| 19 | */ |
| 20 | private function _getHeartbeat(): bool { return $this->getUserInput(Automation::HEARTBEAT, false, UserInput::BOOL); } |
| 21 | |
| 22 | /** |
| 23 | * @return bool |
| 24 | * @throws AjaxException |
| 25 | */ |
| 26 | private function _getWPCron(): bool { return $this->getUserInput(Automation::WP_CRON, false, UserInput::BOOL); } |
| 27 | |
| 28 | /** |
| 29 | * @return int |
| 30 | * @throws AjaxException |
| 31 | */ |
| 32 | private function _getHeartbeatTTL(): int { return $this->getUserInput(Automation::HEARTBEAT_TTL, 10000, UserInput::UINT); } |
| 33 | |
| 34 | /** |
| 35 | * @return bool |
| 36 | * @throws AjaxException |
| 37 | */ |
| 38 | private function _getCrons(): bool { return $this->getUserInput(Automation::CRONS, true, UserInput::BOOL); } |
| 39 | |
| 40 | /** |
| 41 | * @return bool |
| 42 | * @throws AjaxException |
| 43 | */ |
| 44 | private function _getCronStatus(): bool { return $this->getUserInput(Automation::CRON_STATUS, false, UserInput::BOOL); } |
| 45 | |
| 46 | |
| 47 | /** |
| 48 | * @return void |
| 49 | * @throws AjaxException |
| 50 | * @throws IOException |
| 51 | * @throws InvalidArgumentException |
| 52 | */ |
| 53 | public function execute(): void { |
| 54 | |
| 55 | $settings = Factory::getSettingsAutomation(); |
| 56 | |
| 57 | $jb_cron_status_set = $this->isset(Automation::CRON_STATUS); |
| 58 | $jb_cron_status_value = $jb_cron_status_set ? $settings->isCronStatusEnabled() : null; |
| 59 | |
| 60 | if($this->isset(Automation::WP_CRON)) $settings->setWPCron($this->_getWPCron()); |
| 61 | if($this->isset(Automation::HEARTBEAT)) $settings->setHeartbeatEnabled($this->_getHeartbeat()); |
| 62 | if($this->isset(Automation::HEARTBEAT_TTL)) $settings->setHeartbeatTTL($this->_getHeartbeatTTL()); |
| 63 | if($this->isset(Automation::CRONS)) $settings->setCronsEnabled($this->_getCrons()); |
| 64 | if($this->isset(Automation::CRON_STATUS)) $settings->setCronStatusEnabled($this->_getCronStatus()); |
| 65 | |
| 66 | $settings->validateFields(); |
| 67 | $settings->save(); |
| 68 | |
| 69 | if($jb_cron_status_set) { |
| 70 | if ($jb_cron_status_value != $settings->isCronStatusEnabled()) { |
| 71 | $crontab = new Crontab(); |
| 72 | if($settings->isCronStatusEnabled() == 0) $crontab->removeCrontab(); |
| 73 | if($settings->isCronStatusEnabled() == 1) $crontab->addCrontab(); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | $this->setResponseMessage('Saved Successfully'); |
| 78 | $this->setResponseData($this->isCLI() ? $settings->getDisplayCLI() : $settings->getDisplay()); |
| 79 | } |
| 80 | } |