PMCORE-1404 Use Jobs in the 'script task' and 'service task' execution

This commit is contained in:
Roly Rudy Gutierrez Pinto
2020-05-19 12:15:46 -04:00
parent 5bd2d6f1ec
commit 5041c9be3d
19 changed files with 711 additions and 309 deletions

View File

@@ -2,6 +2,7 @@
use ProcessMaker\BusinessModel\User as BusinessModelUser;
use ProcessMaker\BusinessModel\WebEntryEvent;
use ProcessMaker\Cases\CasesTrait;
/*----------------------------------********---------------------------------*/
use ProcessMaker\ChangeLog\ChangeLog;
/*----------------------------------********---------------------------------*/
@@ -16,6 +17,7 @@ use ProcessMaker\Util\DateTime;
*/
class Cases
{
use CasesTrait;
private $appSolr = null;
public $dir = 'ASC';
public $sort = 'APP_MSG_DATE';

View File

@@ -888,7 +888,7 @@ class Derivation
define( 'TASK_FINISH_TASK', - 2 );
}
$this->case = new cases();
$this->case = new Cases();
//Get data for this DEL_INDEX current
$appFields = $this->case->loadCase( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );

View File

@@ -2,9 +2,14 @@
use ProcessMaker\Plugins\PluginRegistry;
spl_autoload_register(function($sClassName) {
if (!empty(config("system.workspace"))) {
$sPath = PATH_DB . config("system.workspace") . PATH_SEP . 'classes' . PATH_SEP;
/**
* The helper 'config()' is loaded via 'spl_autoload_register()' in unit testing.
* The helper is pulled out to avoid an infinite loop.
*/
$workspace = config("system.workspace", null);
spl_autoload_register(function($sClassName) use($workspace) {
if (!empty($workspace)) {
$sPath = PATH_DB . $workspace . PATH_SEP . 'classes' . PATH_SEP;
if (file_exists($sPath . $sClassName . '.php')) {
require_once $sPath . $sClassName . '.php';
}

View File

@@ -1,37 +1,40 @@
<?php
use ProcessMaker\Core\JobsManager;
/**
* cases_Derivate.php
*
*/
if (!isset($_SESSION['USER_LOGGED'])) {
G::SendTemporalMessage('ID_LOGIN_AGAIN', 'warning', 'labels');
die('<script type="text/javascript">
var olink = document.location.href;
olink = ( olink.search("gmail") == -1 ) ? parent.document.location.href : olink;
if(olink.search("gmail") == -1){
parent.location = "../cases/casesStartPage?action=startCase";
} else {
var data = olink.split("?");
var odata = data[1].split("&");
var appUid = odata[0].split("=");
$script = '
<script type="text/javascript">
var olink = document.location.href;
olink = ( olink.search("gmail") == -1 ) ? parent.document.location.href : olink;
if(olink.search("gmail") == -1){
parent.location = "../cases/casesStartPage?action=startCase";
} else {
var data = olink.split("?");
var odata = data[1].split("&");
var appUid = odata[0].split("=");
var dataToSend = {
"action": "credentials",
"operation": "refreshPmSession",
"type": "processCall",
"funParams": [
appUid[1],
""
],
"expectReturn": false
};
var x = parent.postMessage(JSON.stringify(dataToSend), "*");
if (x == undefined){
x = parent.parent.postMessage(JSON.stringify(dataToSend), "*");
}
}
</script>');
var dataToSend = {
"action": "credentials",
"operation": "refreshPmSession",
"type": "processCall",
"funParams": [
appUid[1],
""
],
"expectReturn": false
};
var x = parent.postMessage(JSON.stringify(dataToSend), "*");
if (x == undefined){
x = parent.parent.postMessage(JSON.stringify(dataToSend), "*");
}
}
</script>';
die($script);
}
/* Permissions */
@@ -53,6 +56,7 @@ switch ($RBAC->userCanAccess('PM_CASES')) {
if (!isset($_POST['form'])) {
$_POST['form'] = [];
}
$postForm = $_POST['form'];
/* GET , POST & $_SESSION Vars */
/* Process the info */
@@ -61,15 +65,11 @@ $sStatus = 'TO_DO';
try {
//Load Session variables
$processUid = isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : '';
//load data
$oCase = new Cases();
// check if a task was already derivated
if (isset($_SESSION["APPLICATION"])
&& isset($_SESSION["INDEX"])) {
$_SESSION['LAST_DERIVATED_APPLICATION'] = isset($_SESSION['LAST_DERIVATED_APPLICATION'])?$_SESSION['LAST_DERIVATED_APPLICATION']:'';
$_SESSION['LAST_DERIVATED_INDEX'] = isset($_SESSION['LAST_DERIVATED_INDEX'])?$_SESSION['LAST_DERIVATED_INDEX']:'';
if ($_SESSION["APPLICATION"] === $_SESSION['LAST_DERIVATED_APPLICATION']
&& $_SESSION["INDEX"] === $_SESSION['LAST_DERIVATED_INDEX']) {
if (isset($_SESSION["APPLICATION"]) && isset($_SESSION["INDEX"])) {
$_SESSION['LAST_DERIVATED_APPLICATION'] = isset($_SESSION['LAST_DERIVATED_APPLICATION']) ? $_SESSION['LAST_DERIVATED_APPLICATION'] : '';
$_SESSION['LAST_DERIVATED_INDEX'] = isset($_SESSION['LAST_DERIVATED_INDEX']) ? $_SESSION['LAST_DERIVATED_INDEX'] : '';
if ($_SESSION["APPLICATION"] === $_SESSION['LAST_DERIVATED_APPLICATION'] && $_SESSION["INDEX"] === $_SESSION['LAST_DERIVATED_INDEX']) {
throw new Exception(G::LoadTranslation('ID_INVALID_APPLICATION_ID_MSG', [G::LoadTranslation('ID_REOPEN')]));
} else {
$appDel = new AppDelegation();
@@ -84,116 +84,6 @@ try {
throw new Exception(G::LoadTranslation('ID_INVALID_APPLICATION_ID_MSG', [G::LoadTranslation('ID_REOPEN')]));
}
//warning: we are not using the result value of function thisIsTheCurrentUser, so I'm commenting to optimize speed.
//$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'casesListExtJs');
$appFields = $oCase->loadCase($_SESSION['APPLICATION']);
$appFields['APP_DATA'] = array_merge($appFields['APP_DATA'], G::getSystemConstants());
//cleaning debug variables
$_SESSION['TRIGGER_DEBUG']['DATA'] = [];
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = [];
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = [];
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_EXECUTION_TIME'] = [];
$triggers = $oCase->loadTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'BEFORE');
//if there are some triggers to execute
if (sizeof($triggers) > 0) {
//Execute triggers before derivation
$appFields['APP_DATA'] = $oCase->ExecuteTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'BEFORE',
$appFields['APP_DATA']);
//save trigger variables for debugger
$_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof($triggers);
$_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = G::toUpper(G::loadTranslation('ID_BEFORE'));
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE');
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers;
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_EXECUTION_TIME'] = $oCase->arrayTriggerExecutionTime;
}
unset($appFields['APP_STATUS']);
unset($appFields['APP_PROC_STATUS']);
unset($appFields['APP_PROC_CODE']);
unset($appFields['APP_PIN']);
$appFields["DEL_INDEX"] = $_SESSION["INDEX"];
$appFields["TAS_UID"] = $_SESSION["TASK"];
$appFields["USER_UID"] = $_SESSION["USER_LOGGED"];
$appFields["CURRENT_DYNAFORM"] = "-2";
$appFields["OBJECT_TYPE"] = "ASSIGN_TASK";
$oCase->updateCase($_SESSION["APPLICATION"], $appFields); //Save data
//Prepare information for the derivation
$oDerivation = new Derivation();
$aCurrentDerivation = [
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX'],
'APP_STATUS' => $sStatus,
'TAS_UID' => $_SESSION['TASK'],
'ROU_TYPE' => $_POST['form']['ROU_TYPE']
];
$aDataForPrepareInfo = [
'USER_UID' => $_SESSION['USER_LOGGED'],
'APP_UID' => $_SESSION['APPLICATION'],
'DEL_INDEX' => $_SESSION['INDEX']
];
//We define some parameters in the before the derivation
//Then this function will be route the case
$arrayDerivationResult = $oDerivation->beforeDerivate(
$aDataForPrepareInfo,
$_POST['form']['TASKS'],
$_POST['form']['ROU_TYPE'],
$aCurrentDerivation
);
if (!empty($arrayDerivationResult)) {
foreach ($_POST['form']['TASKS'] as $key => $value) {
if (isset($value['TAS_UID'])) {
foreach ($arrayDerivationResult as $value2) {
if ($value2['TAS_UID'] == $value['TAS_UID']) {
$_POST['form']['TASKS'][$key]['DEL_INDEX'] = $value2['DEL_INDEX'];
break;
}
}
}
}
}
$appFields = $oCase->loadCase($_SESSION['APPLICATION']); //refresh appFields, because in derivations should change some values
$triggers = $oCase->loadTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2,
'AFTER'); //load the triggers after derivation
if (sizeof($triggers) > 0) {
$appFields['APP_DATA'] = $oCase->ExecuteTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'AFTER',
$appFields['APP_DATA']); //Execute triggers after derivation
$_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof($triggers);
$_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = G::toUpper(G::loadTranslation('ID_AFTER'));
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE');
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers;
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_EXECUTION_TIME'] = $oCase->arrayTriggerExecutionTime;
}
unset($appFields['APP_STATUS']);
unset($appFields['APP_PROC_STATUS']);
unset($appFields['APP_PROC_CODE']);
unset($appFields['APP_PIN']);
$appFields["DEL_INDEX"] = $_SESSION["INDEX"];
$appFields["TAS_UID"] = $_SESSION["TASK"];
$appFields["USER_UID"] = $_SESSION["USER_LOGGED"];
$appFields["CURRENT_DYNAFORM"] = "-2";
$appFields["OBJECT_TYPE"] = "ASSIGN_TASK";
$oCase->updateCase($_SESSION['APPLICATION'], $appFields);
// Send notifications - Start
$oUser = new Users();
$aUser = $oUser->load($_SESSION['USER_LOGGED']);
$fromName = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'];
$sFromData = $fromName . ($aUser['USR_EMAIL'] != '' ? ' <' . $aUser['USR_EMAIL'] . '>' : '');
$flagGmail = false;
/*----------------------------------********---------------------------------*/
$licensedFeatures = PMLicensedFeatures::getSingleton();
@@ -201,80 +91,29 @@ try {
$pmGoogle = new PmGoogleApi();
if ($pmGoogle->getServiceGmailStatus()) {
$flagGmail = true;
$appDel = new AppDelegation();
$actualThread = $appDel->Load($_SESSION ['APPLICATION'], $_SESSION ['INDEX']);
$appDelPrev = $appDel->LoadParallel($_SESSION ['APPLICATION']);
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
foreach ($appDelPrev as $app) {
if (($app ['DEL_INDEX'] != $_SESSION ['INDEX']) && ($app ['DEL_PREVIOUS'] != $actualThread ['DEL_PREVIOUS'])) {
$Pmgmail->gmailsIfSelfServiceValueBased($_SESSION ['APPLICATION'], $app ['DEL_INDEX'], $_POST ['form'] ['TASKS'], $appFields ['APP_DATA']);
}
}
}
}
/*----------------------------------********---------------------------------*/
try {
$oCase->sendNotifications(
$_SESSION['TASK'],
$_POST['form']['TASKS'],
$appFields['APP_DATA'],
$_SESSION['APPLICATION'],
$_SESSION['INDEX'],
$sFromData
);
} catch (Exception $e) {
G::SendTemporalMessage(G::loadTranslation('ID_NOTIFICATION_ERROR') . ' - ' . $e->getMessage(), 'warning',
'string', null, '100%');
}
// Send notifications - End
// Events - Start
$oEvent = new Event();
$oEvent->closeAppEvents($processUid, $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK']);
$oCurrentAppDel = AppDelegationPeer::retrieveByPk($_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1);
$multipleDelegation = false;
// check if there are multiple derivations
if (count($_POST['form']['TASKS']) > 1) {
$multipleDelegation = true;
}
// If the case has been delegated
if (isset($oCurrentAppDel)) {
// if there is just a single derivation the TASK_UID can be set by the delegation data
if (!$multipleDelegation) {
$aCurrentAppDel = $oCurrentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
$oEvent->createAppEvents($aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'],
$aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID']);
} else {
// else we need to check every task and create the events if it have any
foreach ($_POST['form']['TASKS'] as $taskDelegated) {
$aCurrentAppDel = $oCurrentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
$oEvent->createAppEvents($aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'],
$aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID']);
}
}
}
//Events - End
/*----------------------------------********---------------------------------*/
// Set users drive - start
$licensedFeatures = PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M=')) {
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
//add users email next task
$drive->addUsersDocumentDrive($appFields['APP_UID']);
}
}
// Set users drive - End
/*----------------------------------********---------------------------------*/
$application = $_SESSION['APPLICATION'];
$tasUid = $_SESSION['TASK'];
$index = $_SESSION["INDEX"];
$userLogged = $_SESSION["USER_LOGGED"];
//Now we dispatch the derivation of the case through Jobs Laravel.
$closure = function() use($processUid, $application, $postForm, $sStatus, $flagGmail, $tasUid, $index, $userLogged) {
$cases = new Cases();
$cases->routeCase($processUid, $application, $postForm, $sStatus, $flagGmail, $tasUid, $index, $userLogged);
};
JobsManager::getSingleton()->dispatch("CasesDispatch", $closure);
//We close the related threads.
$cases = new Cases();
$cases->CloseCurrentDelegation($application, $index);
$debuggerAvailable = true;
$casesRedirector = 'casesListExtJsRedirector';
if (isset ($_SESSION ['user_experience']) && $flagGmail === false) {
if (isset($_SESSION ['user_experience']) && $flagGmail === false) {
$aNextStep ['PAGE'] = $casesRedirector . '?ux=' . $_SESSION ['user_experience'];
$debuggerAvailable = false;
} else {
@@ -285,43 +124,24 @@ try {
}
}
if (isset($_SESSION['PMDEBUGGER']) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) {
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
$loc = 'cases_Step?' . 'breakpoint=triggerdebug';
} else {
$loc = $aNextStep['PAGE'];
}
$loc = $aNextStep['PAGE'];
//Triggers After
$isIE = Bootstrap::isIE();
if (isset($_SESSION['TRIGGER_DEBUG']['ISSET']) && !$isIE) {
if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) {
$oTemplatePower = new TemplatePower(PATH_TPL . 'cases/cases_Step.html');
$oTemplatePower->prepare();
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower);
$_POST['NextStep'] = $loc;
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameLoader');
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameBreaker');
$_SESSION['TRIGGER_DEBUG']['ISSET'] == 0;
G::RenderPage('publish', 'blank');
exit();
} else {
unset($_SESSION['TRIGGER_DEBUG']);
}
}
unset($_SESSION['TRIGGER_DEBUG']);
//close tab only if IE11 add a validation was added if the current skin is uxs
if ($isIE && !isset($_SESSION['__OUTLOOK_CONNECTOR__']) && SYS_SKIN !== "uxs") {
$script = "<script type='text/javascript'>
try {
if(top.opener) {
top.opener.location.reload();
}
top.close();
} catch(e) {
}
</script>";
$script = "
<script type='text/javascript'>
try {
if(top.opener) {
top.opener.location.reload();
}
top.close();
} catch(e) {
}
</script>";
die($script);
}

View File

@@ -0,0 +1,205 @@
<?php
namespace ProcessMaker\Cases;
use AppDelegation;
use AppDelegationPeer;
use AppDocumentDrive;
use BasePeer;
use Cases;
use Derivation;
use Event;
use G;
use PMLicensedFeatures;
use ProcessMaker\BusinessModel\Pmgmail;
use Users;
use WebDriver\Exception;
trait CasesTrait
{
/**
* This initiates the routing of the case given the application and the form
* data in the web application interface.
* @param string $processUid
* @param string $application
* @param array $postForm
* @param string $status
* @param boolean $flagGmail
* @param string $tasUid
* @param integer $index
* @param string $userLogged
*/
public function routeCase($processUid, $application, $postForm, $status, $flagGmail, $tasUid, $index, $userLogged)
{
//warning: we are not using the result value of function thisIsTheCurrentUser, so I'm commenting to optimize speed.
$appFields = $this->loadCase($application);
$appFields['APP_DATA'] = array_merge($appFields['APP_DATA'], G::getSystemConstants());
$triggerDebug = [];
$triggers = $this->loadTriggers($tasUid, 'ASSIGN_TASK', -2, 'BEFORE');
//if there are some triggers to execute
if (sizeof($triggers) > 0) {
//Execute triggers before derivation
$appFields['APP_DATA'] = $this->executeTriggers($tasUid, 'ASSIGN_TASK', -2, 'BEFORE', $appFields['APP_DATA']);
//save trigger variables for debugger
$triggerDebug[] = [
'NUM_TRIGGERS' => sizeof($triggers),
'TIME' => G::toUpper(G::loadTranslation('ID_BEFORE')),
'TRIGGERS_NAMES' => array_column($triggers, 'TRI_TITLE'),
'TRIGGERS_VALUES' => $triggers,
'TRIGGERS_EXECUTION_TIME' => $this->arrayTriggerExecutionTime
];
}
unset($appFields['APP_STATUS']);
unset($appFields['APP_PROC_STATUS']);
unset($appFields['APP_PROC_CODE']);
unset($appFields['APP_PIN']);
$appFields["DEL_INDEX"] = $index;
$appFields["TAS_UID"] = $tasUid;
$appFields["USER_UID"] = $userLogged;
$appFields["CURRENT_DYNAFORM"] = "-2";
$appFields["OBJECT_TYPE"] = "ASSIGN_TASK";
//save data
$this->updateCase($application, $appFields);
//prepare information for the derivation
$derivation = new Derivation();
$currentDerivation = [
'APP_UID' => $application,
'DEL_INDEX' => $index,
'APP_STATUS' => $status,
'TAS_UID' => $tasUid,
'ROU_TYPE' => $postForm['ROU_TYPE']
];
$dataForPrepareInfo = [
'USER_UID' => $userLogged,
'APP_UID' => $application,
'DEL_INDEX' => $index
];
//we define some parameters in the before the derivation
//then this function will be route the case
$arrayDerivationResult = $derivation->beforeDerivate(
$dataForPrepareInfo,
$postForm['TASKS'],
$postForm['ROU_TYPE'],
$currentDerivation
);
if (!empty($arrayDerivationResult)) {
foreach ($postForm['TASKS'] as $key => $value) {
if (isset($value['TAS_UID'])) {
foreach ($arrayDerivationResult as $value2) {
if ($value2['TAS_UID'] == $value['TAS_UID']) {
$postForm['TASKS'][$key]['DEL_INDEX'] = $value2['DEL_INDEX'];
break;
}
}
}
}
}
$appFields = $this->loadCase($application); //refresh appFields, because in derivations should change some values
$triggers = $this->loadTriggers($tasUid, 'ASSIGN_TASK', -2, 'AFTER'); //load the triggers after derivation
if (sizeof($triggers) > 0) {
$appFields['APP_DATA'] = $this->ExecuteTriggers($tasUid, 'ASSIGN_TASK', -2, 'AFTER', $appFields['APP_DATA']); //Execute triggers after derivation
$triggerDebug[] = [
'NUM_TRIGGERS' => sizeof($triggers),
'TIME' => G::toUpper(G::loadTranslation('ID_AFTER')),
'TRIGGERS_NAMES' => array_column($triggers, 'TRI_TITLE'),
'TRIGGERS_VALUES' => $triggers,
'TRIGGERS_EXECUTION_TIME' => $this->arrayTriggerExecutionTime
];
}
unset($appFields['APP_STATUS']);
unset($appFields['APP_PROC_STATUS']);
unset($appFields['APP_PROC_CODE']);
unset($appFields['APP_PIN']);
$appFields["DEL_INDEX"] = $index;
$appFields["TAS_UID"] = $tasUid;
$appFields["USER_UID"] = $userLogged;
$appFields["CURRENT_DYNAFORM"] = "-2";
$appFields["OBJECT_TYPE"] = "ASSIGN_TASK";
$this->updateCase($application, $appFields);
// Send notifications - Start
$oUser = new Users();
$aUser = $oUser->load($userLogged);
$fromName = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'];
$sFromData = $fromName . ($aUser['USR_EMAIL'] != '' ? ' <' . $aUser['USR_EMAIL'] . '>' : '');
if ($flagGmail === true) {
$appDel = new AppDelegation();
$actualThread = $appDel->Load($application, $index);
$appDelPrev = $appDel->LoadParallel($application);
$Pmgmail = new Pmgmail();
foreach ($appDelPrev as $app) {
if (($app['DEL_INDEX'] != $index) && ($app['DEL_PREVIOUS'] != $actualThread['DEL_PREVIOUS'])) {
$Pmgmail->gmailsIfSelfServiceValueBased($application, $app['DEL_INDEX'], $postForm['TASKS'], $appFields['APP_DATA']);
}
}
}
try {
$this->sendNotifications($tasUid, $postForm['TASKS'], $appFields['APP_DATA'], $application, $index, $sFromData);
} catch (Exception $e) {
G::SendTemporalMessage(G::loadTranslation('ID_NOTIFICATION_ERROR') . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%');
}
// Send notifications - End
// Events - Start
$event = new Event();
$event->closeAppEvents($processUid, $application, $index, $tasUid);
$currentAppDel = AppDelegationPeer::retrieveByPk($application, $index + 1);
$multipleDelegation = false;
// check if there are multiple derivations
if (count($postForm['TASKS']) > 1) {
$multipleDelegation = true;
}
// If the case has been delegated
if (isset($currentAppDel)) {
// if there is just a single derivation the TASK_UID can be set by the delegation data
if (!$multipleDelegation) {
$arrayResult = $currentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
$event->createAppEvents($arrayResult['PRO_UID'], $arrayResult['APP_UID'], $arrayResult['DEL_INDEX'], $arrayResult['TAS_UID']);
} else {
// else we need to check every task and create the events if it have any
foreach ($postForm['TASKS'] as $taskDelegated) {
$arrayResult = $currentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
$event->createAppEvents($arrayResult['PRO_UID'], $arrayResult['APP_UID'], $arrayResult['DEL_INDEX'], $taskDelegated['TAS_UID']);
}
}
}
//Events - End
/*----------------------------------********---------------------------------*/
// Set users drive - start
$licensedFeatures = PMLicensedFeatures::getSingleton();
if ($licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M=')) {
$drive = new AppDocumentDrive();
if ($drive->getStatusDrive()) {
//add users email next task
$drive->addUsersDocumentDrive($appFields['APP_UID']);
}
}
// Set users drive - End
/*----------------------------------********---------------------------------*/
$result = [
'appFields' => $appFields,
'triggerDebug' => $triggerDebug
];
return (object) $result;
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class StepTrigger extends Model
{
protected $table = 'STEP_TRIGGER';
protected $primaryKey = 'STEP_UID';
public $incrementing = false;
public $timestamps = false;
}

View File

@@ -12,6 +12,8 @@ class Triggers extends Model
public $timestamps = false;
//primary key
protected $primaryKey = 'TRI_UID';
//No incrementing
public $incrementing = false;
/**
* Scope a query to filter an specific process