-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mod. Refactoring. Tasks saving, and loading refactored. Disable and a…
…pprove actions implemented. #1
- Loading branch information
1 parent
a30b65e
commit 6c99e7d
Showing
12 changed files
with
605 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
lib/CleantalkSP/SpbctWP/Scanner/OSCron/OSCronController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace CleantalkSP\SpbctWP\Scanner\OSCron; | ||
|
||
class OSCronController | ||
{ | ||
/** | ||
* @param $uid | ||
* @param $status | ||
* @return bool | ||
* @throws \Exception | ||
*/ | ||
private static function updateLine($uid, $status) | ||
{ | ||
$line_to_change = OSCronModel::getTaskById($uid); | ||
$line_to_change->setStatus($status); | ||
$result = OSCronModel::updateTaskById($uid, $line_to_change); | ||
if (false === $result) { | ||
return $result; | ||
} | ||
return OSCronModel::rewriteCronTabFile(); | ||
} | ||
/** | ||
* @param $uid | ||
* @return bool | ||
* @throws \Exception | ||
*/ | ||
public static function approveLine($uid) | ||
{ | ||
return static::updateLine($uid, 'approved'); | ||
} | ||
/** | ||
* @param $uid | ||
* @return false|int | ||
* @throws \Exception | ||
*/ | ||
public static function disableLine($uid) | ||
{ | ||
return static::updateLine($uid, 'disabled'); | ||
} | ||
/** | ||
* @param $uid | ||
* @return false|int | ||
* @throws \Exception | ||
*/ | ||
public static function dangerLine($uid) | ||
{ | ||
$line_to_change = OSCronModel::getTaskById($uid); | ||
$line_to_change->setStatus('dangerous'); | ||
return OSCronModel::updateTaskById($uid, $line_to_change); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
lib/CleantalkSP/SpbctWP/Scanner/OSCron/OSCronGetEnvCron.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace CleantalkSP\SpbctWP\Scanner\OSCron; | ||
|
||
class OSCronGetEnvCron | ||
{ | ||
private static $read_command = 'crontab -l'; | ||
|
||
/** | ||
* @return string | ||
* @psalm-suppress ForbiddenCode | ||
*/ | ||
public static function get() | ||
{ | ||
return (string)@shell_exec(static::$read_command); | ||
} | ||
} |
Oops, something went wrong.