This commit is contained in:
Israel Bernabe
2019-03-29 10:00:39 -04:00
committed by Paula Quispe
parent bddc2906a6
commit ef84cd1523
15 changed files with 242 additions and 75 deletions

View File

@@ -292,7 +292,8 @@ class ActionsByEmailCoreClass extends PMPlugin
true,
$data->DEL_INDEX,
$emailSetup,
0
0,
WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL
);
$abeRequest['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR');

View File

@@ -5615,9 +5615,14 @@ class Cases
}
/**
* This function send an email for each task in $arrayTask if $to is definded
*
* @param $dataLastEmail
* @param $arrayData
* @param $arrayTask
* @return void
*
* @see \Cases->sendNotifications()
*/
public function sendMessage($dataLastEmail, $arrayData, $arrayTask)
{
@@ -5701,7 +5706,7 @@ class Cases
'',
$dataLastEmail['applicationUid'],
$dataLastEmail['delIndex'],
'DERIVATION',
WsBase::MESSAGE_TYPE_TASK_NOTIFICATION,
$dataLastEmail['subject'],
$dataLastEmail['from'],
$to,

View File

@@ -663,14 +663,19 @@ class Derivation
/**
* Execute Event
*
* @param string $dummyTaskUid Unique id of Element Origin (unique id of Task) This is the nextTask
* @param array $applicationData Case data
* @param bool $flagEventExecuteBeforeGateway Execute event before gateway
* @param bool $flagEventExecuteAfterGateway Execute event after gateway
* @param string $dummyTaskUid Unique id of Element Origin (unique id of Task) This is the nextTask
* @param array $applicationData Case data
* @param bool $flagEventExecuteBeforeGateway Execute event before gateway
* @param bool $flagEventExecuteAfterGateway Execute event after gateway
* @param int $taskId
*
* @return void
* @see Derivation->derivate()
* @see Derivation->doRouteWithoutThread()
* @see Derivation->finishProcess()
* @see Derivation->finishTask()
*/
private function executeEvent($dummyTaskUid, array $applicationData, $flagEventExecuteBeforeGateway = true, $flagEventExecuteAfterGateway = true, $elementOriUid='')
private function executeEvent($dummyTaskUid, array $applicationData, $flagEventExecuteBeforeGateway = true, $flagEventExecuteAfterGateway = true, $elementOriUid='',$tasId = 0)
{
try {
//Verify if the Project is BPMN
@@ -743,7 +748,7 @@ class Derivation
if (preg_match("/^(?:END|INTERMEDIATE)$/", $event->getEvnType()) && $event->getEvnMarker() === 'EMAIL') {
//Email-Event throw
$result = $emailEvent->sendEmail($applicationData["APP_UID"], $applicationData["PRO_UID"], $value['uid'], $applicationData);
$result = $emailEvent->sendEmail($applicationData["APP_UID"], $applicationData["PRO_UID"], $value['uid'], $applicationData, $tasId);
$aContext['envUid'] = $value['uid'];
$aContext['envType'] = $event->getEvnType();
@@ -1031,7 +1036,8 @@ class Derivation
$appFields,
true,
true,
$currentDelegation["TAS_UID"]
$currentDelegation["TAS_UID"],
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
//Route the case
@@ -1877,7 +1883,15 @@ class Derivation
if (preg_match("/^(?:END-MESSAGE-EVENT|END-EMAIL-EVENT)$/", $taskDummy->getTasType())
&& $multiInstanceCompleted && $executeEvent
) {
$this->executeEvent($nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true);
$nextDel["TAS_ID"] = $taskDummy->getTasId();
$this->executeEvent(
$nextDel["TAS_UID_DUMMY"],
$appFields,
$flagFirstIteration,
true,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
}
}
$aContext['action'] = 'finish-task';
@@ -1904,12 +1918,27 @@ class Derivation
$nextDel['ROU_CONDITION'] = '';
}
//Execute the Intermediate Event After the End of Process
$this->executeEvent($nextDel["TAS_UID"], $appFields, true, true);
$this->executeEvent(
$nextDel["TAS_UID"],
$appFields,
true,
true,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
if (isset($nextDel["TAS_UID_DUMMY"]) ) {
$taskDummy = TaskPeer::retrieveByPK($nextDel["TAS_UID_DUMMY"]);
if (preg_match("/^(?:END-MESSAGE-EVENT|END-EMAIL-EVENT)$/", $taskDummy->getTasType())) {
$nextDel["TAS_ID"] = $taskDummy->getTasId();
//Throw Events
$this->executeEvent($nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true);
$this->executeEvent(
$nextDel["TAS_UID_DUMMY"],
$appFields,
$flagFirstIteration,
true,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
}
}
$aContext['action'] = 'end-process';
@@ -2231,7 +2260,14 @@ class Derivation
//If the all Siblings are done execute the events
if (sizeof($arraySiblings) === 0 && !$flagTypeMultipleInstance) {
//Throw Events
$this->executeEvent($nextDel["TAS_UID"], $appFields, $flagFirstIteration, false);
$this->executeEvent(
$nextDel["TAS_UID"],
$appFields,
$flagFirstIteration,
false,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
}
//Close thread
$this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

View File

@@ -8,8 +8,18 @@ use ProcessMaker\Core\System;
class WsBase
{
const MESSAGE_TYPE_ACTIONS_BY_EMAIL = 'ACTIONS_BY_EMAIL';
const MESSAGE_TYPE_CASE_NOTE = 'CASE_NOTE';
const MESSAGE_TYPE_EMAIL_EVENT = 'EVENT';
const MESSAGE_TYPE_EXTERNAL_REGISTRATION = 'EXTERNAL_REGISTRATION';
const MESSAGE_TYPE_PM_FUNCTION = 'PM_FUNCTION';
const MESSAGE_TYPE_RETRIEVE_PASSWORD = 'RETRIEVE_PASSWORD';
const MESSAGE_TYPE_SOAP = 'SOAP';
const MESSAGE_TYPE_TASK_NOTIFICATION = 'ROUTING';
const MESSAGE_TYPE_TEST_EMAIL = 'TEST';
public $stored_system_variables; //boolean
public $wsSessionId; //web service session id, if the wsbase function is used from a WS request
private $taskId;
private $flagSameCase = true;
public function __construct($params = null)
@@ -45,6 +55,28 @@ class WsBase
$this->flagSameCase = $var;
}
/**
* Get the taskId
*
* @return int
*/
public function getTaskId()
{
return $this->taskId;
}
/**
* Set the taskId
*
* @param int $taskId
*
* @return void
*/
public function setTaskId($taskId)
{
$this->taskId = $taskId;
}
/**
* function to start a web services session in ProcessMaker
*
@@ -854,6 +886,13 @@ class WsBase
* @param array $config
*
* @return $result will return an object
*
* @see ActionsByEmailCoreClass->sendActionsByEmail()
* @see workflow\engine\classes\class.pmFunctions::PMFSendMessage()
* @see workflow\engine\methods\services\soap2::sendMessage()
* @see \ProcessMaker\BusinessModel\EmailEvent->sendEmail()
* @see \ProcessMaker\BusinessModel\Pmgmail->sendEmailWithApplicationData()
*
*/
public function sendMessage(
$appUid,
@@ -868,7 +907,8 @@ class WsBase
$showMessage = true,
$delIndex = 0,
$config = [],
$gmail = 0
$gmail = 0,
$appMsgType = WsBase::MESSAGE_TYPE_PM_FUNCTION
)
{
try {
@@ -920,7 +960,7 @@ class WsBase
$spool->setConfig($setup);
$case = new Cases();
$oldFields = $case->loadCase($appUid);
$oldFields = $case->loadCase($appUid, $delIndex);
if ($gmail == 1) {
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP;
} else {
@@ -946,7 +986,7 @@ class WsBase
'',
$appUid,
$delIndex,
'TRIGGER',
$appMsgType,
$subject,
G::buildFrom($setup, $from),
$to,
@@ -961,7 +1001,7 @@ class WsBase
(preg_match("/^.+\.html?$/i", $fileTemplate)) ? true : false,
isset($fieldsCase['APP_NUMBER']) ? $fieldsCase['APP_NUMBER'] : 0,
isset($fieldsCase['PRO_ID']) ? $fieldsCase['PRO_ID'] : 0,
isset($fieldsCase['TAS_ID']) ? $fieldsCase['TAS_ID'] : 0
$this->getTaskId() ?$this->getTaskId():(isset($oldFields['TAS_ID'])? $oldFields['TAS_ID'] : 0)
);
$spool->create($messageArray);

View File

@@ -920,34 +920,34 @@ function getEmailConfiguration ()
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFSendMessage.28.29
*
* @param string(32) | $caseId | UID for case | The UID (unique identification) for a case, which is a string of 32 hexadecimal characters to identify the case.
* @param string(32) | $sFrom | Sender | The email address of the person who sends out the email.
* @param string(100) | $sTo | Recipient | The email address(es) to whom the email is sent. If multiple recipients, separate each email address with a comma.
* @param string(100) | $sCc = '' | Carbon copy recipient | The email address(es) of people who will receive carbon copies of the email.
* @param string(100) | $sBcc = ''| Carbon copy recipient | The email address(es) of people who will receive blind carbon copies of the email.
* @param string(50) | $sSubject | Subject of the email | The subject (title) of the email.
* @param string(50) | $sTemplate | Name of the template | The name of the template file in plain text or HTML format which will produce the body of the email.
* @param array | $aFields = array() | Variables for email template | Optional parameter. An associative array where the keys are the variable names and the values are the variables' values.
* @param array | $aAttachment = array() | Attachment | An Optional arrray. An array of files (full paths) to be attached to the email.
* @param string(32) | $from | Sender | The email address of the person who sends out the email.
* @param string(100) | $to | Recipient | The email address(es) to whom the email is sent. If multiple recipients, separate each email address with a comma.
* @param string(100) | $cc = '' | Carbon copy recipient | The email address(es) of people who will receive carbon copies of the email.
* @param string(100) | $bcc = ''| Carbon copy recipient | The email address(es) of people who will receive blind carbon copies of the email.
* @param string(50) | $subject | Subject of the email | The subject (title) of the email.
* @param string(50) | $template | Name of the template | The name of the template file in plain text or HTML format which will produce the body of the email.
* @param array | $emailTemplateVariables = [] | Variables for email template | Optional parameter. An associative array where the keys are the variable names and the values are the variables' values.
* @param array | $attachments = [] | Attachment | An Optional arrray. An array of files (full paths) to be attached to the email.
* @param boolean | $showMessage = true | Show message | Optional parameter. Set to TRUE to show the message in the case's message history.
* @param int | $delIndex = 0 | Delegation index of the case | Optional parameter. The delegation index of the current task in the case.
* @param string(100) | $config = '' | Email server configuration | An optional array: An array of parameters to be used in the Email sent (MESS_ENGINE, MESS_SERVER, MESS_PORT, MESS_FROM_MAIL, MESS_RAUTH, MESS_ACCOUNT, MESS_PASSWORD, and SMTPSecure) Or String: UID of Email server .
* @param array | $config = [] | Email server configuration | An optional array: An array of parameters to be used in the Email sent (MESS_ENGINE, MESS_SERVER, MESS_PORT, MESS_FROM_MAIL, MESS_RAUTH, MESS_ACCOUNT, MESS_PASSWORD, and SMTPSecure) Or String: UID of Email server .
* @return int | | result | Result of sending email
*
* @see class.pmFunctions::PMFSendMessageToGroup()
*/
//@param array | $aFields=array() | An associative array optional | Optional parameter. An associative array where the keys are the variable name and the values are the variable's value.
function PMFSendMessage(
$caseId,
$sFrom,
$sTo,
$sCc,
$sBcc,
$sSubject,
$sTemplate,
$aFields = array(),
$aAttachment = array(),
$from,
$to,
$cc,
$bcc,
$subject,
$template,
$emailTemplateVariables = [],
$attachments = [],
$showMessage = true,
$delIndex = 0,
$config = array()
$config = []
) {
ini_set ( "pcre.backtrack_limit", 1000000 );
ini_set ( 'memory_limit', '-1' );
@@ -955,28 +955,30 @@ function PMFSendMessage(
global $oPMScript;
if (isset( $oPMScript->aFields ) && is_array( $oPMScript->aFields )) {
if (is_array( $aFields )) {
$aFields = array_merge( $oPMScript->aFields, $aFields );
if (isset($oPMScript->aFields) && is_array($oPMScript->aFields)) {
if (is_array($emailTemplateVariables)) {
$emailTemplateVariables = array_merge($oPMScript->aFields, $emailTemplateVariables);
} else {
$aFields = $oPMScript->aFields;
$emailTemplateVariables = $oPMScript->aFields;
}
}
$ws = new WsBase();
$result = $ws->sendMessage(
$caseId,
$sFrom,
$sTo,
$sCc,
$sBcc,
$sSubject,
$sTemplate,
$aFields,
$aAttachment,
$from,
$to,
$cc,
$bcc,
$subject,
$template,
$emailTemplateVariables,
$attachments,
$showMessage,
$delIndex,
$config
$config,
0,
WsBase::MESSAGE_TYPE_PM_FUNCTION
);
if ($result->status_code == 0) {

View File

@@ -180,8 +180,12 @@ class AppNotes extends BaseAppNotes
* @param string $noteRecipients
* @param string $from
* @param integer $delIndex
*
* @return void
* @throws Exception
*
* @see AppNotes->addCaseNote()
* @see AppNotes->postNewNote()
* @see workflow/engine/src/ProcessMaker/Util/helpers.php::postNote()
*/
public function sendNoteNotification ($appUid, $usrUid, $noteContent, $noteRecipients, $from = '', $delIndex = 0)
{
@@ -224,7 +228,7 @@ class AppNotes extends BaseAppNotes
'',
$appUid,
$delIndex,
'DERIVATION',
WsBase::MESSAGE_TYPE_CASE_NOTE,
G::replaceDataField($configNoteNotification['subject'], $fieldCase),
G::buildFrom($configuration, $from),
$to,