Merged in bugfix/HOR-4525 (pull request #6680)
HOR-4525 Approved-by: Paula Quispe <paula.quispe@processmaker.com> Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -792,6 +792,7 @@ function executeCaseSelfService()
|
||||
$oPMScript->setDataTrigger($row);
|
||||
$oPMScript->setFields($appFields["APP_DATA"]);
|
||||
$oPMScript->setScript($row["TRI_WEBBOT"]);
|
||||
$oPMScript->setExecutedOn(PMScript::SELF_SERVICE_TIMEOUT);
|
||||
$oPMScript->execute();
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
@@ -1138,6 +1138,7 @@ class Applications
|
||||
// if it has a condition
|
||||
if (trim($caseStep->getStepCondition()) != '') {
|
||||
$pmScript->setScript($caseStep->getStepCondition());
|
||||
$pmScript->setExecutedOn(PMScript::CONDITION);
|
||||
|
||||
if (! $pmScript->evaluate()) {
|
||||
//evaluated false, jump & continue with the others steps
|
||||
|
||||
@@ -2344,6 +2344,7 @@ class Cases
|
||||
if ($oStep) {
|
||||
if (trim($oStep->getStepCondition()) !== '') {
|
||||
$oPMScript->setScript($oStep->getStepCondition());
|
||||
$oPMScript->setExecutedOn(PMScript::CONDITION);
|
||||
$bAccessStep = $oPMScript->evaluate();
|
||||
} else {
|
||||
$bAccessStep = true;
|
||||
@@ -2474,6 +2475,7 @@ class Cases
|
||||
if ($oStep) {
|
||||
if (trim($oStep->getStepCondition()) !== '') {
|
||||
$oPMScript->setScript($oStep->getStepCondition());
|
||||
$oPMScript->setExecutedOn(PMScript::CONDITION);
|
||||
$bAccessStep = $oPMScript->evaluate();
|
||||
} else {
|
||||
$bAccessStep = true;
|
||||
@@ -3480,12 +3482,15 @@ class Cases
|
||||
if ($aTrigger['ST_CONDITION'] !== '') {
|
||||
$oPMScript->setDataTrigger($aTrigger);
|
||||
$oPMScript->setScript($aTrigger['ST_CONDITION']);
|
||||
$oPMScript->setExecutedOn(PMScript::CONDITION);
|
||||
$bExecute = $oPMScript->evaluate();
|
||||
}
|
||||
|
||||
if ($bExecute) {
|
||||
$oPMScript->setDataTrigger($aTrigger);
|
||||
$oPMScript->setScript($aTrigger['TRI_WEBBOT']);
|
||||
$executedOn = $oPMScript->getExecutionOriginForAStep($sStepType, $sStepUidObj, $sTriggerType);
|
||||
$oPMScript->setExecutedOn($executedOn);
|
||||
$oPMScript->execute();
|
||||
|
||||
$this->arrayTriggerExecutionTime[$aTrigger['TRI_UID']] = $oPMScript->scriptExecutionTime;
|
||||
@@ -7142,6 +7147,7 @@ class Cases
|
||||
$oPMScript->setDataTrigger($arrayWebBotTrigger);
|
||||
$oPMScript->setFields($aFields['APP_DATA']);
|
||||
$oPMScript->setScript($arrayWebBotTrigger['TRI_WEBBOT']);
|
||||
$oPMScript->setExecutedOn(PMScript::PROCESS_ACTION);
|
||||
$oPMScript->execute();
|
||||
|
||||
$aFields['APP_DATA'] = array_merge($aFields['APP_DATA'], $oPMScript->aFields);
|
||||
|
||||
@@ -179,6 +179,7 @@ class Derivation
|
||||
$pmScript = new PMScript();
|
||||
$pmScript->setFields($arrayApplicationData["APP_DATA"]);
|
||||
$pmScript->setScript($arrayRouteData["ROU_CONDITION"]);
|
||||
$pmScript->setExecutedOn(PMScript::CONDITION);
|
||||
$flagAddDelegation = $pmScript->evaluate();
|
||||
}
|
||||
|
||||
|
||||
@@ -1719,27 +1719,27 @@ class WsBase
|
||||
*
|
||||
* @param string $caseId
|
||||
* @param string $variables
|
||||
* @param bool $forceToSave
|
||||
*
|
||||
* @return $result will return an object
|
||||
*/
|
||||
public function sendVariables($caseId, $variables)
|
||||
public function sendVariables($caseId, $variables, $forceToSave = false)
|
||||
{
|
||||
//delegation where app uid (caseId) y usruid(session) ordenar delindes descendente y agaarr el primero
|
||||
//delfinishdate != null error
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
$oCriteria->add(AppDelegationPeer::APP_UID, $caseId);
|
||||
$oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
if (!$forceToSave) {
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
|
||||
$criteria->add(AppDelegationPeer::APP_UID, $caseId);
|
||||
$criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
|
||||
$oCriteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$dataset = AppDelegationPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$cnt = 0;
|
||||
|
||||
while ($oDataset->next()) {
|
||||
$aRow = $oDataset->getRow();
|
||||
while ($dataset->next()) {
|
||||
$row = $dataset->getRow();
|
||||
$cnt++;
|
||||
}
|
||||
|
||||
@@ -1748,6 +1748,7 @@ class WsBase
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($variables)) {
|
||||
$cant = count($variables);
|
||||
@@ -2197,7 +2198,11 @@ class WsBase
|
||||
if (count($aTriggers) > 0) {
|
||||
$varTriggers = $varTriggers . "<br /><b>" . $labelAssignment . "</b><br />";
|
||||
|
||||
global $oPMScript;
|
||||
|
||||
if (!isset($oPMScript)) {
|
||||
$oPMScript = new PMScript();
|
||||
}
|
||||
|
||||
foreach ($aTriggers as $aTrigger) {
|
||||
//Set variables
|
||||
@@ -2218,12 +2223,15 @@ class WsBase
|
||||
|
||||
if ($aTrigger['ST_CONDITION'] !== '') {
|
||||
$oPMScript->setScript($aTrigger['ST_CONDITION']);
|
||||
$oPMScript->setExecutedOn(PMScript::CONDITION);
|
||||
$bExecute = $oPMScript->evaluate();
|
||||
}
|
||||
|
||||
if ($bExecute) {
|
||||
$oPMScript->setDataTrigger($aTrigger);
|
||||
$oPMScript->setScript($aTrigger['TRI_WEBBOT']);
|
||||
$executedOn = $oPMScript->getExecutionOriginForAStep($stepType, $stepUidObj, $triggerType);
|
||||
$oPMScript->setExecutedOn($executedOn);
|
||||
$oPMScript->execute();
|
||||
|
||||
$trigger = TriggersPeer::retrieveByPk($aTrigger["TRI_UID"]);
|
||||
@@ -2687,6 +2695,7 @@ class WsBase
|
||||
$oPMScript->setDataTrigger($row);
|
||||
$oPMScript->setFields($appFields['APP_DATA']);
|
||||
$oPMScript->setScript($row['TRI_WEBBOT']);
|
||||
$oPMScript->setExecutedOn(PMScript::ISOLATED_TRIGGER);
|
||||
$oPMScript->execute();
|
||||
|
||||
if (isset($oPMScript->aFields["__ERROR__"]) && trim($oPMScript->aFields["__ERROR__"]) != "" && $oPMScript->aFields["__ERROR__"] != "none") {
|
||||
|
||||
@@ -425,6 +425,7 @@ function evaluateFunction ($aGrid, $sExpresion)
|
||||
|
||||
$pmScript = new PMScript();
|
||||
$pmScript->setScript($sExpresion);
|
||||
$pmScript->setExecutedOn(PMScript::EVALUATE_FUNCTION);
|
||||
|
||||
for ($i = 1; $i <= count($aGrid); $i ++) {
|
||||
$aFields = $aGrid[$i];
|
||||
@@ -2030,13 +2031,19 @@ function PMFProcessList () //its test was successfull
|
||||
*/
|
||||
function PMFSendVariables ($caseId, $variables)
|
||||
{
|
||||
$ws = new WsBase();
|
||||
global $oPMScript;
|
||||
|
||||
if (!isset($oPMScript)) {
|
||||
$oPMScript = new PMScript();
|
||||
}
|
||||
|
||||
$ws = new WsBase();
|
||||
$result = $ws->sendVariables($caseId, $variables,
|
||||
$oPMScript->executedOn() === PMScript::AFTER_ROUTING);
|
||||
|
||||
$result = $ws->sendVariables( $caseId, $variables );
|
||||
if ($result->status_code == 0) {
|
||||
if (isset($_SESSION['APPLICATION'])) {
|
||||
if ($caseId == $_SESSION['APPLICATION']) {
|
||||
global $oPMScript;
|
||||
if (isset($oPMScript->aFields) && is_array($oPMScript->aFields)) {
|
||||
if (is_array($variables)) {
|
||||
$oPMScript->aFields = array_merge($oPMScript->aFields, $variables);
|
||||
@@ -2464,6 +2471,7 @@ function PMFRedirectToStep ($sApplicationUID, $iDelegation, $sStepType, $sStepUi
|
||||
$pmScript = new PMScript();
|
||||
$pmScript->setFields($aFields['APP_DATA']);
|
||||
$pmScript->setScript($oTheStep->getStepCondition());
|
||||
$pmScript->setExecutedOn(PMScript::CONDITION);
|
||||
$bContinue = $pmScript->evaluate();
|
||||
}
|
||||
if ($bContinue) {
|
||||
@@ -2980,11 +2988,17 @@ function PMFRemoveMask ($field, $separator = '.', $currency = '')
|
||||
function PMFSaveCurrentData ()
|
||||
{
|
||||
global $oPMScript;
|
||||
|
||||
if (!isset($oPMScript)) {
|
||||
$oPMScript = new PMScript();
|
||||
}
|
||||
|
||||
$response = 0;
|
||||
|
||||
if (isset($_SESSION['APPLICATION']) && isset($oPMScript->aFields)) {
|
||||
$ws = new WsBase();
|
||||
$result = $ws->sendVariables($_SESSION['APPLICATION'], $oPMScript->aFields);
|
||||
$result = $ws->sendVariables($_SESSION['APPLICATION'], $oPMScript->aFields,
|
||||
$oPMScript->executedOn() === PMScript::AFTER_ROUTING);
|
||||
$response = $result->status_code == 0 ? 1 : 0;
|
||||
}
|
||||
return $response;
|
||||
|
||||
@@ -35,11 +35,51 @@ if (file_exists($dir)) {
|
||||
/**
|
||||
* PMScript - PMScript class
|
||||
*
|
||||
* @copyright 2007 COLOSA
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
class PMScript
|
||||
{
|
||||
/**
|
||||
* Constants to identify the execution origin
|
||||
*/
|
||||
const UNDEFINED_ORIGIN = 'executed.undefined.origin';
|
||||
|
||||
const BEFORE_DYNAFORM = 'executed.before.dynaform';
|
||||
|
||||
const AFTER_DYNAFORM = 'executed.after.dynaform';
|
||||
|
||||
const BEFORE_INPUT_DOCUMENT = 'executed.before.input';
|
||||
|
||||
const AFTER_INPUT_DOCUMENT = 'executed.after.input';
|
||||
|
||||
const BEFORE_OUTPUT_DOCUMENT = 'executed.before.output';
|
||||
|
||||
const AFTER_OUTPUT_DOCUMENT = 'executed.after.output';
|
||||
|
||||
const BEFORE_EXTERNAL_STEP = 'executed.before.external';
|
||||
|
||||
const AFTER_EXTERNAL_STEP = 'executed.after.external';
|
||||
|
||||
const BEFORE_ASSIGNMENT = 'executed.before.assignment';
|
||||
|
||||
const BEFORE_ROUTING = 'executed.before.routing';
|
||||
|
||||
const AFTER_ROUTING = 'executed.after.routing';
|
||||
|
||||
const CONDITION = 'executed.condition';
|
||||
|
||||
const SCRIPT_TASK = 'executed.script.task';
|
||||
|
||||
const CLASSIC_PROCESS_EVENTS = 'executed.classic.process.events';
|
||||
|
||||
const SELF_SERVICE_TIMEOUT = 'executed.selfservice.timeout';
|
||||
|
||||
const ISOLATED_TRIGGER = 'executed.isolated.trigger';
|
||||
|
||||
const PROCESS_ACTION = 'executed.process.action';
|
||||
|
||||
const EVALUATE_FUNCTION = 'executed.evaluate.function';
|
||||
|
||||
/**
|
||||
* @var array $dataTrigger
|
||||
*/
|
||||
@@ -72,12 +112,17 @@ class PMScript
|
||||
public $scriptExecutionTime = 0;
|
||||
public $sRegexp = '/\@(?:([\@\%\#\?\$\=\&])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+|\-\>([a-zA-Z\_]\w*))?/';
|
||||
|
||||
/**
|
||||
* Execution origin, by default is undefined
|
||||
*/
|
||||
protected $executedOn = self::UNDEFINED_ORIGIN;
|
||||
|
||||
/**
|
||||
* Constructor of the class PMScript
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function PMScript()
|
||||
public function __construct()
|
||||
{
|
||||
$this->aFields['__ERROR__'] = 'none';
|
||||
}
|
||||
@@ -161,6 +206,70 @@ class PMScript
|
||||
$this->dataTrigger = is_array($dataTrigger) ? $dataTrigger : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the execution origin
|
||||
*
|
||||
* @param string $executedOn
|
||||
*/
|
||||
public function setExecutedOn($executedOn)
|
||||
{
|
||||
$this->executedOn = $executedOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the execution origin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function executedOn() {
|
||||
return $this->executedOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to get the execution origin from an step
|
||||
*
|
||||
* @param string $stepType
|
||||
* @param mixed $stepUidObj
|
||||
* @param string $triggerType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExecutionOriginForAStep($stepType, $stepUidObj, $triggerType)
|
||||
{
|
||||
switch ($stepType) {
|
||||
case 'DYNAFORM':
|
||||
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_DYNAFORM : $triggerType === 'AFTER' ?
|
||||
self::AFTER_DYNAFORM : self::UNDEFINED_ORIGIN;
|
||||
break;
|
||||
case 'INPUT_DOCUMENT':
|
||||
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_INPUT_DOCUMENT : $triggerType === 'AFTER' ?
|
||||
self::AFTER_INPUT_DOCUMENT : self::UNDEFINED_ORIGIN;
|
||||
break;
|
||||
case 'OUTPUT_DOCUMENT':
|
||||
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_OUTPUT_DOCUMENT : $triggerType === 'AFTER' ?
|
||||
self::AFTER_OUTPUT_DOCUMENT : self::UNDEFINED_ORIGIN;
|
||||
break;
|
||||
case 'EXTERNAL':
|
||||
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_EXTERNAL_STEP : $triggerType === 'AFTER' ?
|
||||
self::AFTER_EXTERNAL_STEP : self::UNDEFINED_ORIGIN;
|
||||
break;
|
||||
case 'ASSIGN_TASK':
|
||||
if ($stepUidObj === -1) {
|
||||
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ASSIGNMENT : self::UNDEFINED_ORIGIN;
|
||||
} elseif ($stepUidObj === -2) {
|
||||
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ROUTING : $triggerType === 'AFTER' ?
|
||||
self::AFTER_ROUTING : self::UNDEFINED_ORIGIN;
|
||||
} else {
|
||||
$executedOn = self::UNDEFINED_ORIGIN;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$executedOn = self::UNDEFINED_ORIGIN;
|
||||
break;
|
||||
}
|
||||
return $executedOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sScript
|
||||
* @param $sCode
|
||||
|
||||
@@ -214,7 +214,7 @@ class AppEvent extends BaseAppEvent
|
||||
|
||||
$oCriteria->addJoin(ApplicationPeer::APP_UID, AppEventPeer::APP_UID);
|
||||
|
||||
$oCriteria->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL ); //by me
|
||||
$oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
$oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
|
||||
$oCriteria->add(AppEventPeer::APP_EVN_ACTION_DATE, $sNow, Criteria::LESS_EQUAL);
|
||||
|
||||
@@ -235,9 +235,6 @@ class AppEvent extends BaseAppEvent
|
||||
$aFields = $oCase->loadCase($aRow['APP_UID']);
|
||||
$oAppEvent = AppEventPeer::retrieveByPK($aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID']);
|
||||
|
||||
//g::pr($aRow); //die;
|
||||
|
||||
|
||||
if ($debug) {
|
||||
require_once 'classes/model/Application.php';
|
||||
$oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
|
||||
@@ -286,7 +283,7 @@ class AppEvent extends BaseAppEvent
|
||||
$oPMScript->setDataTrigger($oTrigger->toArray(\BasePeer::TYPE_FIELDNAME));
|
||||
$oPMScript->setFields($aFields['APP_DATA']);
|
||||
$oPMScript->setScript($oTrigger->getTriWebbot());
|
||||
|
||||
$oPMScript->setExecutedOn(PMScript::CLASSIC_PROCESS_EVENTS);
|
||||
$oPMScript->execute();
|
||||
|
||||
$oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
|
||||
@@ -295,7 +292,6 @@ class AppEvent extends BaseAppEvent
|
||||
$log[] = ' - The trigger ' . $oTrigger->getTriTitle() . ' was executed successfully!';
|
||||
if ($debug) {
|
||||
println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
|
||||
//g::pr($aFields);
|
||||
}
|
||||
$aFields['APP_DATA'] = $oPMScript->aFields;
|
||||
$oCase->updateCase($aRow['APP_UID'], $aFields);
|
||||
|
||||
@@ -638,6 +638,7 @@ class ScriptTask
|
||||
$oPMScript->setDataTrigger($trigger->toArray(BasePeer::TYPE_FIELDNAME));
|
||||
$oPMScript->setFields($arrayApplicationData["APP_DATA"]);
|
||||
$oPMScript->setScript($trigger->getTriWebbot());
|
||||
$oPMScript->setExecutedOn(PMScript::SCRIPT_TASK);
|
||||
$oPMScript->execute();
|
||||
|
||||
if (isset($oPMScript->aFields["__ERROR__"])) {
|
||||
|
||||
@@ -49,6 +49,7 @@ foreach ($rs as $key => $aRow) {
|
||||
$bAccessStep = false;
|
||||
if (trim($aRow->getStepCondition()) != '') {
|
||||
$oPMScript->setScript($aRow->getStepCondition());
|
||||
$oPMScript->setExecutedOn(PMScript::CONDITION);
|
||||
$bAccessStep = $oPMScript->evaluate();
|
||||
} else {
|
||||
$bAccessStep = true;
|
||||
|
||||
Reference in New Issue
Block a user