Merge branch 'develop' of bitbucket.org:colosa/processmaker into feature/PMCORE-3871
This commit is contained in:
@@ -7,6 +7,7 @@ use ProcessMaker\BusinessModel\Process as BmProcess;
|
|||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
use ProcessMaker\ChangeLog\ChangeLog;
|
use ProcessMaker\ChangeLog\ChangeLog;
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
use ProcessMaker\BusinessModel\TaskSchedulerBM;
|
||||||
use ProcessMaker\BusinessModel\WebEntry;
|
use ProcessMaker\BusinessModel\WebEntry;
|
||||||
use ProcessMaker\Core\Installer;
|
use ProcessMaker\Core\Installer;
|
||||||
use ProcessMaker\Core\ProcessesManager;
|
use ProcessMaker\Core\ProcessesManager;
|
||||||
@@ -1125,6 +1126,7 @@ class WorkspaceTools
|
|||||||
$this->upgradeSchema($systemSchemaRbac, false, true); // Perform upgrade to RBAC
|
$this->upgradeSchema($systemSchemaRbac, false, true); // Perform upgrade to RBAC
|
||||||
$this->upgradeData();
|
$this->upgradeData();
|
||||||
$this->checkRbacPermissions(); //check or add new permissions
|
$this->checkRbacPermissions(); //check or add new permissions
|
||||||
|
$this->checkSchedulerTable();
|
||||||
$this->checkSequenceNumber();
|
$this->checkSequenceNumber();
|
||||||
$this->migrateIteeToDummytask($this->name);
|
$this->migrateIteeToDummytask($this->name);
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
@@ -3352,7 +3354,7 @@ class WorkspaceTools
|
|||||||
*/
|
*/
|
||||||
public function checkRbacPermissions()
|
public function checkRbacPermissions()
|
||||||
{
|
{
|
||||||
CLI::logging("-> Remove the permissions depreacated in RBAC \n");
|
CLI::logging("-> Remove the permissions deprecated in RBAC \n");
|
||||||
$this->removePermission();
|
$this->removePermission();
|
||||||
CLI::logging("-> Verifying roles permissions in RBAC \n");
|
CLI::logging("-> Verifying roles permissions in RBAC \n");
|
||||||
//Update table RBAC permissions
|
//Update table RBAC permissions
|
||||||
@@ -3368,6 +3370,17 @@ class WorkspaceTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check SCHEDULER table integrity.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function checkSchedulerTable(): void
|
||||||
|
{
|
||||||
|
CLI::logging("-> Check SCHEDULER table integrity.\n");
|
||||||
|
TaskSchedulerBM::checkDataIntegrity();
|
||||||
|
CLI::logging(" SCHEDULER table integrity was checked.\n");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add sequence numbers
|
* Add sequence numbers
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6137,6 +6137,12 @@ msgstr "Delegation Date"
|
|||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Delete"
|
msgstr "Delete"
|
||||||
|
|
||||||
|
# TRANSLATION
|
||||||
|
# LABEL/ID_DELETE_EMAIL_SETTINGS
|
||||||
|
#: LABEL/ID_DELETE_EMAIL_SETTINGS
|
||||||
|
msgid "Delete Email Settings"
|
||||||
|
msgstr "Delete Email Settings"
|
||||||
|
|
||||||
# TRANSLATION
|
# TRANSLATION
|
||||||
# LABEL/ID_DELETED
|
# LABEL/ID_DELETED
|
||||||
#: LABEL/ID_DELETED
|
#: LABEL/ID_DELETED
|
||||||
|
|||||||
@@ -57850,6 +57850,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
|||||||
( 'LABEL','ID_DELEGATE_USER','en','Delegated User','2014-01-15') ,
|
( 'LABEL','ID_DELEGATE_USER','en','Delegated User','2014-01-15') ,
|
||||||
( 'LABEL','ID_DELEGATION_DATE','en','Delegation Date','2014-01-15') ,
|
( 'LABEL','ID_DELEGATION_DATE','en','Delegation Date','2014-01-15') ,
|
||||||
( 'LABEL','ID_DELETE','en','Delete','2014-01-15') ,
|
( 'LABEL','ID_DELETE','en','Delete','2014-01-15') ,
|
||||||
|
( 'LABEL','ID_DELETE_EMAIL_SETTINGS','en','Delete Email Settings','2022-06-29') ,
|
||||||
( 'LABEL','ID_DELETED','en','Deleted','2014-01-15') ,
|
( 'LABEL','ID_DELETED','en','Deleted','2014-01-15') ,
|
||||||
( 'LABEL','ID_DELETED_SUCCESSFULLY','en','Deleted Successfully','2014-01-15') ,
|
( 'LABEL','ID_DELETED_SUCCESSFULLY','en','Deleted Successfully','2014-01-15') ,
|
||||||
( 'LABEL','ID_DELETE_ACTION','en','Delete case','2020-01-15') ,
|
( 'LABEL','ID_DELETE_ACTION','en','Delete case','2020-01-15') ,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use ProcessMaker\BusinessModel\EmailServer;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\GmailOAuth\GmailOAuth;
|
use ProcessMaker\GmailOAuth\GmailOAuth;
|
||||||
use ProcessMaker\Office365OAuth\Office365OAuth;
|
use ProcessMaker\Office365OAuth\Office365OAuth;
|
||||||
@@ -11,7 +12,6 @@ $RBAC->allows(basename(__FILE__), $option);
|
|||||||
switch ($option) {
|
switch ($option) {
|
||||||
case "INS":
|
case "INS":
|
||||||
$arrayData = [];
|
$arrayData = [];
|
||||||
|
|
||||||
$server = "";
|
$server = "";
|
||||||
$port = "";
|
$port = "";
|
||||||
$incomingServer = "";
|
$incomingServer = "";
|
||||||
@@ -19,7 +19,6 @@ switch ($option) {
|
|||||||
$reqAuthentication = 0;
|
$reqAuthentication = 0;
|
||||||
$password = "";
|
$password = "";
|
||||||
$smtpSecure = "";
|
$smtpSecure = "";
|
||||||
|
|
||||||
$cboEmailEngine = $_POST["cboEmailEngine"];
|
$cboEmailEngine = $_POST["cboEmailEngine"];
|
||||||
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
||||||
$fromName = $_POST["fromName"];
|
$fromName = $_POST["fromName"];
|
||||||
@@ -45,7 +44,7 @@ switch ($option) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$arrayData = array(
|
$arrayData = [
|
||||||
"MESS_ENGINE" => $cboEmailEngine,
|
"MESS_ENGINE" => $cboEmailEngine,
|
||||||
"MESS_SERVER" => $server,
|
"MESS_SERVER" => $server,
|
||||||
"MESS_PORT" => $port,
|
"MESS_PORT" => $port,
|
||||||
@@ -60,11 +59,22 @@ switch ($option) {
|
|||||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||||
"MAIL_TO" => $mailTo,
|
"MAIL_TO" => $mailTo,
|
||||||
"MESS_DEFAULT" => $emailServerDefault
|
"MESS_DEFAULT" => $emailServerDefault
|
||||||
);
|
];
|
||||||
|
|
||||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
|
||||||
|
|
||||||
|
$emailSever = new EmailServer();
|
||||||
$arrayEmailServerData = $emailSever->create($arrayData);
|
$arrayEmailServerData = $emailSever->create($arrayData);
|
||||||
|
// Register the log
|
||||||
|
G::auditLog(
|
||||||
|
"CreateEmailSettings",
|
||||||
|
"SetDefaultConfiguration-> " . $emailServerDefault .
|
||||||
|
", EmailEngine-> " . $cboEmailEngine .
|
||||||
|
", Server-> " . $server .
|
||||||
|
", Port-> " . $port .
|
||||||
|
", RequireAuthentication-> " . $reqAuthentication .
|
||||||
|
", FromMail-> " . $fromMail .
|
||||||
|
", FromName-> " . $fromName .
|
||||||
|
", UseSecureConnection-> " . $smtpSecure
|
||||||
|
);
|
||||||
|
|
||||||
$response["status"] = "OK";
|
$response["status"] = "OK";
|
||||||
$response["data"] = $arrayEmailServerData;
|
$response["data"] = $arrayEmailServerData;
|
||||||
@@ -75,9 +85,7 @@ switch ($option) {
|
|||||||
break;
|
break;
|
||||||
case "UPD":
|
case "UPD":
|
||||||
$arrayData = [];
|
$arrayData = [];
|
||||||
|
|
||||||
$emailServerUid = $_POST["emailServerUid"];
|
$emailServerUid = $_POST["emailServerUid"];
|
||||||
|
|
||||||
$server = "";
|
$server = "";
|
||||||
$port = "";
|
$port = "";
|
||||||
$incomingServer = "";
|
$incomingServer = "";
|
||||||
@@ -85,7 +93,6 @@ switch ($option) {
|
|||||||
$reqAuthentication = 0;
|
$reqAuthentication = 0;
|
||||||
$password = "";
|
$password = "";
|
||||||
$smtpSecure = "";
|
$smtpSecure = "";
|
||||||
|
|
||||||
$cboEmailEngine = $_POST["cboEmailEngine"];
|
$cboEmailEngine = $_POST["cboEmailEngine"];
|
||||||
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
||||||
$fromName = $_POST["fromName"];
|
$fromName = $_POST["fromName"];
|
||||||
@@ -111,7 +118,7 @@ switch ($option) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$arrayData = array(
|
$arrayData = [
|
||||||
"MESS_ENGINE" => $cboEmailEngine,
|
"MESS_ENGINE" => $cboEmailEngine,
|
||||||
"MESS_SERVER" => $server,
|
"MESS_SERVER" => $server,
|
||||||
"MESS_PORT" => $port,
|
"MESS_PORT" => $port,
|
||||||
@@ -126,11 +133,23 @@ switch ($option) {
|
|||||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||||
"MAIL_TO" => $mailTo,
|
"MAIL_TO" => $mailTo,
|
||||||
"MESS_DEFAULT" => $emailServerDefault
|
"MESS_DEFAULT" => $emailServerDefault
|
||||||
);
|
];
|
||||||
|
|
||||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
|
||||||
|
|
||||||
|
$emailSever = new EmailServer();
|
||||||
$arrayEmailServerData = $emailSever->update($emailServerUid, $arrayData);
|
$arrayEmailServerData = $emailSever->update($emailServerUid, $arrayData);
|
||||||
|
// Register the log
|
||||||
|
G::auditLog(
|
||||||
|
"UpdateEmailSettings",
|
||||||
|
"EmailServer-> " . $emailServerUid .
|
||||||
|
", SetDefaultConfiguration-> " . $emailServerDefault .
|
||||||
|
", EmailEngine-> " . $cboEmailEngine .
|
||||||
|
", Server-> " . $server .
|
||||||
|
", Port-> " . $port .
|
||||||
|
", RequireAuthentication-> " . $reqAuthentication .
|
||||||
|
", FromMail-> " . $fromMail .
|
||||||
|
", FromName-> " . $fromName .
|
||||||
|
", UseSecureConnection-> " . $smtpSecure
|
||||||
|
);
|
||||||
|
|
||||||
$response["status"] = "OK";
|
$response["status"] = "OK";
|
||||||
$response["data"] = $arrayEmailServerData;
|
$response["data"] = $arrayEmailServerData;
|
||||||
@@ -144,9 +163,13 @@ switch ($option) {
|
|||||||
$emailServerUid = $_POST["emailServerUid"];
|
$emailServerUid = $_POST["emailServerUid"];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
$emailSever = new EmailServer();
|
||||||
|
|
||||||
$result = $emailSever->delete($emailServerUid);
|
$result = $emailSever->delete($emailServerUid);
|
||||||
|
// Register the log
|
||||||
|
G::auditLog(
|
||||||
|
"DeleteEmailSettings",
|
||||||
|
"EmailServer-> " . $emailServerUid
|
||||||
|
);
|
||||||
|
|
||||||
$response["status"] = "OK";
|
$response["status"] = "OK";
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -157,16 +180,14 @@ switch ($option) {
|
|||||||
case "LST":
|
case "LST":
|
||||||
$pageSize = $_POST["pageSize"];
|
$pageSize = $_POST["pageSize"];
|
||||||
$search = $_POST["search"];
|
$search = $_POST["search"];
|
||||||
|
|
||||||
$sortField = (isset($_POST["sort"])) ? $_POST["sort"] : "";
|
$sortField = (isset($_POST["sort"])) ? $_POST["sort"] : "";
|
||||||
$sortDir = (isset($_POST["dir"])) ? $_POST["dir"] : "";
|
$sortDir = (isset($_POST["dir"])) ? $_POST["dir"] : "";
|
||||||
$start = (isset($_POST["start"])) ? $_POST["start"] : 0;
|
$start = (isset($_POST["start"])) ? $_POST["start"] : 0;
|
||||||
$limit = (isset($_POST["limit"])) ? $_POST["limit"] : $pageSize;
|
$limit = (isset($_POST["limit"])) ? $_POST["limit"] : $pageSize;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
$emailSever = new EmailServer();
|
||||||
|
$result = $emailSever->getEmailServers(["filter" => $search], $sortField, $sortDir, $start, $limit);
|
||||||
$result = $emailSever->getEmailServers(array("filter" => $search), $sortField, $sortDir, $start, $limit);
|
|
||||||
|
|
||||||
$response["status"] = "OK";
|
$response["status"] = "OK";
|
||||||
$response["success"] = true;
|
$response["success"] = true;
|
||||||
@@ -205,7 +226,7 @@ switch ($option) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$arrayData = array(
|
$arrayData = [
|
||||||
"MESS_ENGINE" => $cboEmailEngine,
|
"MESS_ENGINE" => $cboEmailEngine,
|
||||||
"MESS_SERVER" => $server,
|
"MESS_SERVER" => $server,
|
||||||
"MESS_PORT" => $port,
|
"MESS_PORT" => $port,
|
||||||
@@ -218,10 +239,9 @@ switch ($option) {
|
|||||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||||
"MAIL_TO" => $mailTo,
|
"MAIL_TO" => $mailTo,
|
||||||
"MESS_DEFAULT" => $emailServerDefault
|
"MESS_DEFAULT" => $emailServerDefault
|
||||||
);
|
];
|
||||||
|
|
||||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
|
||||||
|
|
||||||
|
$emailSever = new EmailServer();
|
||||||
$arrayEmailServerData = $emailSever->testConnection($arrayData);
|
$arrayEmailServerData = $emailSever->testConnection($arrayData);
|
||||||
|
|
||||||
$response["data"] = $arrayEmailServerData;
|
$response["data"] = $arrayEmailServerData;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace ProcessMaker\BusinessModel;
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
|
||||||
|
use Bootstrap;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\Model\TaskScheduler;
|
use ProcessMaker\Model\TaskScheduler;
|
||||||
|
|
||||||
@@ -223,13 +225,14 @@ class TaskSchedulerBM
|
|||||||
]
|
]
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the records in Schedule Table by category
|
* Return the records in Schedule Table by category
|
||||||
*/
|
*/
|
||||||
public static function getSchedule($category)
|
public static function getSchedule($category)
|
||||||
{
|
{
|
||||||
$tasks = TaskScheduler::all();
|
$tasks = TaskScheduler::all();
|
||||||
$count = $tasks->count();
|
$count = $tasks->count();
|
||||||
if ($count == 0) {
|
if ($count == 0) {
|
||||||
TaskSchedulerBM::generateInitialData();
|
TaskSchedulerBM::generateInitialData();
|
||||||
$tasks = TaskScheduler::all();
|
$tasks = TaskScheduler::all();
|
||||||
@@ -244,6 +247,7 @@ class TaskSchedulerBM
|
|||||||
return $tasks;
|
return $tasks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the record Schedule in Schedule Table
|
* Save the record Schedule in Schedule Table
|
||||||
*/
|
*/
|
||||||
@@ -251,55 +255,122 @@ class TaskSchedulerBM
|
|||||||
{
|
{
|
||||||
$task = TaskScheduler::find($request['id']);
|
$task = TaskScheduler::find($request['id']);
|
||||||
if (isset($request['enable'])) {
|
if (isset($request['enable'])) {
|
||||||
$task->enable = $request['enable'];
|
$task->enable = $request['enable'];
|
||||||
}
|
}
|
||||||
if (isset($request['expression'])) {
|
if (isset($request['expression'])) {
|
||||||
$task->expression = $request['expression'];
|
$task->expression = $request['expression'];
|
||||||
$task->startingTime = $request['startingTime'];
|
$task->startingTime = $request['startingTime'];
|
||||||
$task->endingTime = $request['endingTime'];
|
$task->endingTime = $request['endingTime'];
|
||||||
$task->timezone = $request['timezone'];
|
$task->timezone = $request['timezone'];
|
||||||
$task->everyOn = $request['everyOn'];
|
$task->everyOn = $request['everyOn'];
|
||||||
$task->interval = $request['interval'];
|
$task->interval = $request['interval'];
|
||||||
}
|
}
|
||||||
$task->save();
|
$task->save();
|
||||||
return $task;
|
return $task;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial data for Schedule Table, with default values
|
* Initial data for Schedule Table, with default values
|
||||||
*/
|
*/
|
||||||
public static function generateInitialData()
|
public static function generateInitialData()
|
||||||
{
|
{
|
||||||
$arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
|
|
||||||
$toSave = [];
|
|
||||||
$win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
|
||||||
foreach (TaskSchedulerBM::$services as $service) {
|
foreach (TaskSchedulerBM::$services as $service) {
|
||||||
$task = new TaskScheduler;
|
self::registerScheduledTask($service);
|
||||||
$task->title = $service["title"];
|
|
||||||
$task->category = $service["category"];
|
|
||||||
$task->description = $service["description"];
|
|
||||||
$task->startingTime = $service["startingTime"];
|
|
||||||
$task->endingTime = $service["endingTime"];
|
|
||||||
if ($win) {
|
|
||||||
$task->body = 'php "' . PATH_TRUNK . $service["filew"] . '" ' . $service["service"] . ' +w' . config("system.workspace") . ' +force +async';
|
|
||||||
} else {
|
|
||||||
$task->body = 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $service["service"] . ' +w' . config("system.workspace") . ' +force +async"';
|
|
||||||
}
|
|
||||||
$task->expression = $service["expression"];
|
|
||||||
$task->type = "shell";
|
|
||||||
$task->system = 1;
|
|
||||||
$task->enable = $service["enable"];
|
|
||||||
$task->everyOn = $service["everyOn"];
|
|
||||||
$task->interval = $service["interval"];
|
|
||||||
$task->timezone = $service["timezone"] == "default" ? date_default_timezone_get() : null;
|
|
||||||
$task->default_value = json_encode([
|
|
||||||
"startingTime" => $service["startingTime"],
|
|
||||||
"endingTime" => $service["endingTime"],
|
|
||||||
"everyOn" => $service["everyOn"],
|
|
||||||
"interval" => $service["interval"],
|
|
||||||
"expression" => $service["expression"],
|
|
||||||
"timezone" => $task->timezone
|
|
||||||
]);
|
|
||||||
$task->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register scheduled task.
|
||||||
|
* @param array $service
|
||||||
|
* @return TaskScheduler
|
||||||
|
*/
|
||||||
|
private static function registerScheduledTask(array $service)
|
||||||
|
{
|
||||||
|
$task = new TaskScheduler;
|
||||||
|
$task->title = $service["title"];
|
||||||
|
$task->category = $service["category"];
|
||||||
|
$task->description = $service["description"];
|
||||||
|
$task->startingTime = $service["startingTime"];
|
||||||
|
$task->endingTime = $service["endingTime"];
|
||||||
|
$task->body = self::buildBody($service);
|
||||||
|
$task->expression = $service["expression"];
|
||||||
|
$task->type = "shell";
|
||||||
|
$task->system = 1;
|
||||||
|
$task->enable = $service["enable"];
|
||||||
|
$task->everyOn = $service["everyOn"];
|
||||||
|
$task->interval = $service["interval"];
|
||||||
|
$task->timezone = $service["timezone"] == "default" ? date_default_timezone_get() : null;
|
||||||
|
$task->default_value = json_encode([
|
||||||
|
"startingTime" => $service["startingTime"],
|
||||||
|
"endingTime" => $service["endingTime"],
|
||||||
|
"everyOn" => $service["everyOn"],
|
||||||
|
"interval" => $service["interval"],
|
||||||
|
"expression" => $service["expression"],
|
||||||
|
"timezone" => $task->timezone
|
||||||
|
]);
|
||||||
|
$task->save();
|
||||||
|
return $task;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build body parameter.
|
||||||
|
* @param array $service
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function buildBody(array $service): string
|
||||||
|
{
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
|
return 'php "' . PATH_TRUNK . $service["filew"] . '" ' . $service["service"] . ' +w' . config("system.workspace") . ' +force +async';
|
||||||
|
} else {
|
||||||
|
return 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $service["service"] . ' +w' . config("system.workspace") . ' +force +async"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check data integrity.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function checkDataIntegrity(): array
|
||||||
|
{
|
||||||
|
$beforeChanges = TaskScheduler::select()->get();
|
||||||
|
|
||||||
|
//remove missing register
|
||||||
|
$titleCondition = [];
|
||||||
|
$descriptionCondition = [];
|
||||||
|
foreach (self::$services as $service) {
|
||||||
|
$titleCondition[] = $service['title'];
|
||||||
|
$descriptionCondition[] = $service['description'];
|
||||||
|
}
|
||||||
|
TaskScheduler::whereNotIn('title', $titleCondition)
|
||||||
|
->whereNotIn('description', $descriptionCondition)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
//update register or create new register
|
||||||
|
foreach (self::$services as $service) {
|
||||||
|
$scheduler = TaskScheduler::select()
|
||||||
|
->where('title', '=', $service['title'])
|
||||||
|
->where('description', '=', $service['description'])
|
||||||
|
->get()
|
||||||
|
->first();
|
||||||
|
if (is_null($scheduler)) {
|
||||||
|
self::registerScheduledTask($service);
|
||||||
|
} else {
|
||||||
|
$scheduler->body = self::buildBody($service);
|
||||||
|
$scheduler->type = 'shell';
|
||||||
|
$scheduler->category = $service['category'];
|
||||||
|
$scheduler->system = 1;
|
||||||
|
$scheduler->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//log changes
|
||||||
|
$afterChanges = TaskScheduler::select()->get();
|
||||||
|
$result = [
|
||||||
|
'beforeChanges' => $beforeChanges,
|
||||||
|
'afterChanges' => $afterChanges
|
||||||
|
];
|
||||||
|
$message = 'Check SCHEDULER table integrity';
|
||||||
|
Log::channel(':taskSchedulerCheckDataIntegrity')->info($message, Bootstrap::context($result));
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,10 @@ class AuditLog
|
|||||||
"ExportLanguage" => G::LoadTranslation("ID_EXPORT_LANGUAGE"),
|
"ExportLanguage" => G::LoadTranslation("ID_EXPORT_LANGUAGE"),
|
||||||
"DeleteLanguage" => G::LoadTranslation("ID_DELETE_LAGUAGE"),
|
"DeleteLanguage" => G::LoadTranslation("ID_DELETE_LAGUAGE"),
|
||||||
// Settings
|
// Settings
|
||||||
"UploadSystemSettings" => G::LoadTranslation("ID_UPLOAD_SYSTEM_SETTINGS"),
|
|
||||||
"UpdateEmailSettings" => G::LoadTranslation("ID_UPDATE_EMAIL_SETTINGS"),
|
|
||||||
"CreateEmailSettings" => G::LoadTranslation("ID_CREATE_EMAIL_SETTINGS"),
|
"CreateEmailSettings" => G::LoadTranslation("ID_CREATE_EMAIL_SETTINGS"),
|
||||||
|
"DeleteEmailSettings" => G::LoadTranslation("ID_DELETE_EMAIL_SETTINGS"),
|
||||||
|
"UpdateEmailSettings" => G::LoadTranslation("ID_UPDATE_EMAIL_SETTINGS"),
|
||||||
|
"UploadSystemSettings" => G::LoadTranslation("ID_UPLOAD_SYSTEM_SETTINGS"),
|
||||||
// Logo
|
// Logo
|
||||||
"UploadLogo" => G::LoadTranslation("ID_UPLOAD_LOGO"),
|
"UploadLogo" => G::LoadTranslation("ID_UPLOAD_LOGO"),
|
||||||
"DeleteLogo" => G::LoadTranslation("ID_DELETE_LOGO"),
|
"DeleteLogo" => G::LoadTranslation("ID_DELETE_LOGO"),
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Group extends Api
|
|||||||
$user = new User();
|
$user = new User();
|
||||||
$usrUid = $this->getUserId();
|
$usrUid = $this->getUserId();
|
||||||
// Review the permissions roles to access the API
|
// Review the permissions roles to access the API
|
||||||
if (!$user->checkPermission($usrUid, "PM_USERS") || !$user->checkPermission($usrUid, "PM_FACTORY")) {
|
if (!$user->checkPermission($usrUid, "PM_USERS") && !$user->checkPermission($usrUid, "PM_FACTORY")) {
|
||||||
throw new Exception(G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION", [$usrUid]));
|
throw new Exception(G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION", [$usrUid]));
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user