PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / trunk
JetBackup – Backup, Restore & Migrate vtrunk
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 / Settings / Automation.php
backup / src / JetBackup / Settings Last commit date
.htaccess 1 year ago Automation.php 10 months ago General.php 3 months ago Integrations.php 4 months ago Logging.php 4 months ago Maintenance.php 4 months ago Notifications.php 4 months ago Performance.php 3 months ago Restore.php 1 year ago Security.php 1 day ago Settings.php 4 months ago Updates.php 4 months ago index.html 1 year ago web.config 1 year ago
Automation.php
136 lines
1 <?php
2
3 namespace JetBackup\Settings;
4
5 use JetBackup\Crontab\Crontab;
6 use JetBackup\Exception\AjaxException;
7 use JetBackup\Exception\DBException;
8 use JetBackup\Exception\IOException;
9 use JetBackup\Wordpress\Wordpress;
10 use ReflectionException;
11 use SleekDB\Exceptions\InvalidArgumentException;
12
13 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
14
15 class Automation extends Settings {
16
17 const SECTION = 'automation';
18
19 const CRON_PUBLIC = 'AUTOMATION_CRON_PUBLIC';
20 const CRON_COMMAND = 'AUTOMATION_CRON_COMMAND';
21 const CRON_CONTENT = 'AUTOMATION_CRON_CONTENT';
22 const WP_CRON = 'WP_CRON';
23
24 const HEARTBEAT = 'HEARTBEAT';
25 const HEARTBEAT_TTL = 'HEARTBEAT_TTL';
26 const HEARTBEAT_TTL_VALUES = 'HEARTBEAT_TTL_VALUES';
27 const CRONS = 'CRONS';
28 const CRON_STATUS = 'CRON_STATUS';
29
30 /**
31 * @throws DBException
32 * @throws \SleekDB\Exceptions\IOException
33 * @throws InvalidArgumentException
34 */
35 public function __construct() {
36 parent::__construct(self::SECTION);
37 }
38
39 public function isWPCronEnabled():bool { return (bool) $this->get(self::WP_CRON, true); }
40 public function setWPCron(bool $value):void { $this->set(self::WP_CRON, $value); }
41
42 /**
43 * @return bool
44 */
45 public function isHeartbeatEnabled():bool { return (bool) $this->get(self::HEARTBEAT, true); }
46
47 /**
48 * @param bool $value
49 *
50 * @return void
51 */
52 public function setHeartbeatEnabled(bool $value):void { $this->set(self::HEARTBEAT, $value); }
53
54 /**
55 * @return int
56 */
57 public function getHeartbeatTTL():int { return (int) $this->get(self::HEARTBEAT_TTL, 10000); }
58
59 /**
60 * @param int $value
61 *
62 * @return void
63 */
64 public function setHeartbeatTTL(int $value):void { $this->set(self::HEARTBEAT_TTL, $value); }
65
66 /**
67 * @return bool
68 */
69 public function isCronsEnabled():bool { return (bool) $this->get(self::CRONS, true); }
70
71 /**
72 * @param bool $value
73 *
74 * @return void
75 */
76 public function setCronsEnabled(bool $value):void { $this->set(self::CRONS, $value); }
77
78 /**
79 * @return bool
80 */
81 public function isCronStatusEnabled():bool { return (bool) $this->get(self::CRON_STATUS, false); }
82
83 /**
84 * @param bool $value
85 *
86 * @return void
87 */
88 public function setCronStatusEnabled(bool $value):void { $this->set(self::CRON_STATUS, $value); }
89
90 /**
91 * @return array
92 */
93 public function getDisplay():array {
94
95 $cron = new Crontab();
96
97 return [
98 self::CRON_PUBLIC => Crontab::getPublicCron(),
99 self::CRON_COMMAND => Crontab::getCommand(),
100 self::CRON_CONTENT => implode(PHP_EOL, $cron->getCrontab()),
101 self::WP_CRON => $this->isWPCronEnabled() ? 1 : 0,
102 self::HEARTBEAT => $this->isHeartbeatEnabled() ? 1 : 0,
103 self::CRONS => $this->isCronsEnabled() ? 1 : 0,
104 self::CRON_STATUS => $this->isCronStatusEnabled() ? 1 : 0,
105 self::HEARTBEAT_TTL => $this->getHeartbeatTTL(),
106 self::HEARTBEAT_TTL_VALUES => [
107 5 => 5000,
108 10 => 10000,
109 20 => 20000,
110 30 => 30000,
111 40 => 40000,
112 50 => 50000,
113 60 => 60000,
114 ]
115 ];
116 }
117
118 /**
119 * @return array
120 */
121 public function getDisplayCLI():array {
122
123 return [
124 'Wordpress Cron' => $this->isWPCronEnabled() ? "Yes" : "No",
125 'Heartbeat' => $this->isHeartbeatEnabled() ? "Yes" : "No",
126 'Cron Jobs' => $this->isCronsEnabled() ? "Yes" : "No",
127 'Cron Job Status' => $this->isCronStatusEnabled() ? "Yes" : "No",
128 ];
129 }
130
131 /**
132 * @return void
133 */
134 public function validateFields():void {}
135
136 }