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\BusinessModel\TaskSchedulerBM;
|
||||
use ProcessMaker\BusinessModel\WebEntry;
|
||||
use ProcessMaker\Core\Installer;
|
||||
use ProcessMaker\Core\ProcessesManager;
|
||||
@@ -1125,6 +1126,7 @@ class WorkspaceTools
|
||||
$this->upgradeSchema($systemSchemaRbac, false, true); // Perform upgrade to RBAC
|
||||
$this->upgradeData();
|
||||
$this->checkRbacPermissions(); //check or add new permissions
|
||||
$this->checkSchedulerTable();
|
||||
$this->checkSequenceNumber();
|
||||
$this->migrateIteeToDummytask($this->name);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
@@ -3352,7 +3354,7 @@ class WorkspaceTools
|
||||
*/
|
||||
public function checkRbacPermissions()
|
||||
{
|
||||
CLI::logging("-> Remove the permissions depreacated in RBAC \n");
|
||||
CLI::logging("-> Remove the permissions deprecated in RBAC \n");
|
||||
$this->removePermission();
|
||||
CLI::logging("-> Verifying roles permissions in RBAC \n");
|
||||
//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
|
||||
*/
|
||||
|
||||
@@ -6137,6 +6137,12 @@ msgstr "Delegation Date"
|
||||
msgid "Delete"
|
||||
msgstr "Delete"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_DELETE_EMAIL_SETTINGS
|
||||
#: LABEL/ID_DELETE_EMAIL_SETTINGS
|
||||
msgid "Delete Email Settings"
|
||||
msgstr "Delete Email Settings"
|
||||
|
||||
# TRANSLATION
|
||||
# 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_DELEGATION_DATE','en','Delegation Date','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_SUCCESSFULLY','en','Deleted Successfully','2014-01-15') ,
|
||||
( 'LABEL','ID_DELETE_ACTION','en','Delete case','2020-01-15') ,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\BusinessModel\EmailServer;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\GmailOAuth\GmailOAuth;
|
||||
use ProcessMaker\Office365OAuth\Office365OAuth;
|
||||
@@ -11,7 +12,6 @@ $RBAC->allows(basename(__FILE__), $option);
|
||||
switch ($option) {
|
||||
case "INS":
|
||||
$arrayData = [];
|
||||
|
||||
$server = "";
|
||||
$port = "";
|
||||
$incomingServer = "";
|
||||
@@ -19,7 +19,6 @@ switch ($option) {
|
||||
$reqAuthentication = 0;
|
||||
$password = "";
|
||||
$smtpSecure = "";
|
||||
|
||||
$cboEmailEngine = $_POST["cboEmailEngine"];
|
||||
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
||||
$fromName = $_POST["fromName"];
|
||||
@@ -45,7 +44,7 @@ switch ($option) {
|
||||
}
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
$arrayData = [
|
||||
"MESS_ENGINE" => $cboEmailEngine,
|
||||
"MESS_SERVER" => $server,
|
||||
"MESS_PORT" => $port,
|
||||
@@ -60,11 +59,22 @@ switch ($option) {
|
||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||
"MAIL_TO" => $mailTo,
|
||||
"MESS_DEFAULT" => $emailServerDefault
|
||||
);
|
||||
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
];
|
||||
|
||||
$emailSever = new EmailServer();
|
||||
$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["data"] = $arrayEmailServerData;
|
||||
@@ -75,9 +85,7 @@ switch ($option) {
|
||||
break;
|
||||
case "UPD":
|
||||
$arrayData = [];
|
||||
|
||||
$emailServerUid = $_POST["emailServerUid"];
|
||||
|
||||
$server = "";
|
||||
$port = "";
|
||||
$incomingServer = "";
|
||||
@@ -85,7 +93,6 @@ switch ($option) {
|
||||
$reqAuthentication = 0;
|
||||
$password = "";
|
||||
$smtpSecure = "";
|
||||
|
||||
$cboEmailEngine = $_POST["cboEmailEngine"];
|
||||
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
||||
$fromName = $_POST["fromName"];
|
||||
@@ -111,7 +118,7 @@ switch ($option) {
|
||||
}
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
$arrayData = [
|
||||
"MESS_ENGINE" => $cboEmailEngine,
|
||||
"MESS_SERVER" => $server,
|
||||
"MESS_PORT" => $port,
|
||||
@@ -126,11 +133,23 @@ switch ($option) {
|
||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||
"MAIL_TO" => $mailTo,
|
||||
"MESS_DEFAULT" => $emailServerDefault
|
||||
);
|
||||
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
];
|
||||
|
||||
$emailSever = new EmailServer();
|
||||
$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["data"] = $arrayEmailServerData;
|
||||
@@ -144,9 +163,13 @@ switch ($option) {
|
||||
$emailServerUid = $_POST["emailServerUid"];
|
||||
|
||||
try {
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
|
||||
$emailSever = new EmailServer();
|
||||
$result = $emailSever->delete($emailServerUid);
|
||||
// Register the log
|
||||
G::auditLog(
|
||||
"DeleteEmailSettings",
|
||||
"EmailServer-> " . $emailServerUid
|
||||
);
|
||||
|
||||
$response["status"] = "OK";
|
||||
} catch (Exception $e) {
|
||||
@@ -157,16 +180,14 @@ switch ($option) {
|
||||
case "LST":
|
||||
$pageSize = $_POST["pageSize"];
|
||||
$search = $_POST["search"];
|
||||
|
||||
$sortField = (isset($_POST["sort"])) ? $_POST["sort"] : "";
|
||||
$sortDir = (isset($_POST["dir"])) ? $_POST["dir"] : "";
|
||||
$start = (isset($_POST["start"])) ? $_POST["start"] : 0;
|
||||
$limit = (isset($_POST["limit"])) ? $_POST["limit"] : $pageSize;
|
||||
|
||||
try {
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
|
||||
$result = $emailSever->getEmailServers(array("filter" => $search), $sortField, $sortDir, $start, $limit);
|
||||
$emailSever = new EmailServer();
|
||||
$result = $emailSever->getEmailServers(["filter" => $search], $sortField, $sortDir, $start, $limit);
|
||||
|
||||
$response["status"] = "OK";
|
||||
$response["success"] = true;
|
||||
@@ -205,7 +226,7 @@ switch ($option) {
|
||||
}
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
$arrayData = [
|
||||
"MESS_ENGINE" => $cboEmailEngine,
|
||||
"MESS_SERVER" => $server,
|
||||
"MESS_PORT" => $port,
|
||||
@@ -218,10 +239,9 @@ switch ($option) {
|
||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||
"MAIL_TO" => $mailTo,
|
||||
"MESS_DEFAULT" => $emailServerDefault
|
||||
);
|
||||
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
];
|
||||
|
||||
$emailSever = new EmailServer();
|
||||
$arrayEmailServerData = $emailSever->testConnection($arrayData);
|
||||
|
||||
$response["data"] = $arrayEmailServerData;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use Bootstrap;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Model\TaskScheduler;
|
||||
|
||||
@@ -223,6 +225,7 @@ class TaskSchedulerBM
|
||||
]
|
||||
/*----------------------------------********---------------------------------*/
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the records in Schedule Table by category
|
||||
*/
|
||||
@@ -244,6 +247,7 @@ class TaskSchedulerBM
|
||||
return $tasks;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the record Schedule in Schedule Table
|
||||
*/
|
||||
@@ -264,26 +268,31 @@ class TaskSchedulerBM
|
||||
$task->save();
|
||||
return $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial data for Schedule Table, with default values
|
||||
*/
|
||||
public static function generateInitialData()
|
||||
{
|
||||
$arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||
$toSave = [];
|
||||
$win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
||||
foreach (TaskSchedulerBM::$services as $service) {
|
||||
self::registerScheduledTask($service);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"];
|
||||
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->body = self::buildBody($service);
|
||||
$task->expression = $service["expression"];
|
||||
$task->type = "shell";
|
||||
$task->system = 1;
|
||||
@@ -300,6 +309,68 @@ class TaskSchedulerBM
|
||||
"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"),
|
||||
"DeleteLanguage" => G::LoadTranslation("ID_DELETE_LAGUAGE"),
|
||||
// Settings
|
||||
"UploadSystemSettings" => G::LoadTranslation("ID_UPLOAD_SYSTEM_SETTINGS"),
|
||||
"UpdateEmailSettings" => G::LoadTranslation("ID_UPDATE_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
|
||||
"UploadLogo" => G::LoadTranslation("ID_UPLOAD_LOGO"),
|
||||
"DeleteLogo" => G::LoadTranslation("ID_DELETE_LOGO"),
|
||||
|
||||
@@ -26,7 +26,7 @@ class Group extends Api
|
||||
$user = new User();
|
||||
$usrUid = $this->getUserId();
|
||||
// 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]));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user