PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.22.4
JetBackup – Backup, Restore & Migrate v3.1.22.4
3.1.22.4 3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / Ajax / Calls / DestinationSetExportConfig.php
backup / src / JetBackup / Ajax / Calls Last commit date
.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 1 week 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
DestinationSetExportConfig.php
70 lines
1 <?php
2
3 namespace JetBackup\Ajax\Calls;
4
5 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
6
7 use JetBackup\Ajax\aAjax;
8 use JetBackup\BackupJob\BackupJob;
9 use JetBackup\Destination\Destination;
10 use JetBackup\Exception\AjaxException;
11 use JetBackup\Exception\DBException;
12 use JetBackup\Exception\DestinationException;
13 use JetBackup\Exception\JBException;
14 use JetBackup\JetBackup;
15 use JetBackup\UserInput\UserInput;
16 use SleekDB\Exceptions\InvalidArgumentException;
17 use SleekDB\Exceptions\IOException;
18
19 class DestinationSetExportConfig extends aAjax {
20
21 /**
22 * @throws AjaxException
23 */
24 public function getId():int { return $this->getUserInput(JetBackup::ID_FIELD, 0, UserInput::UINT); }
25
26 /**
27 * @return void
28 * @throws AjaxException
29 * @throws IOException
30 * @throws InvalidArgumentException
31 * @throws DBException
32 * @throws DestinationException
33 * @throws \JetBackup\Exception\IOException
34 * @throws JBException
35 */
36 public function execute(): void {
37
38 if(!$this->getId()) throw new AjaxException("No job id provided");
39
40 $destination = new Destination($this->getId());
41 if(!$destination->getId()) throw new AjaxException("Invalid destination id provided");
42
43 $enabled = !$destination->isExportConfig();
44
45 $backup = BackupJob::getDefaultConfigJob();
46
47 $destinations = $backup->getDestinations();
48
49 if($enabled) $destinations[] = $destination->getId();
50 else {
51 foreach($destinations as $i => $destination_id) {
52 if($destination_id != $destination->getId()) continue;
53 unset($destinations[$i]);
54 break;
55 }
56 }
57
58 $destinations = array_unique($destinations);
59
60 $backup->setEnabled(!!$destinations);
61 $backup->setDestinations($destinations);
62 $backup->calculateNextRun();
63
64 $destination->setExportConfig($enabled); // Opposite status
65 $destination->save();
66 $backup->save();
67
68 $this->setResponseMessage("Destination export config " . ($destination->isExportConfig() ? 'enabled' : 'disabled') . " successfully! Reloading...");
69 }
70 }