Merged in bugfix/PMC-32 (pull request #6829)

PMC-32

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Israel Bernabe
2019-04-02 15:32:49 +00:00
committed by Julio Cesar Laura Avendaño
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,

View File

@@ -574,8 +574,10 @@ class adminProxy extends HttpProxyController
}
/**
* for send email configuration
* @autor Alvaro <alvaro@colosa.com>
* For test email configuration
* @return stdClass()
*
* @see adminProxy->testConnection()
*/
public function sendTestMail()
{
@@ -624,7 +626,7 @@ class adminProxy extends HttpProxyController
'',
'',
'',
'TEST',
WsBase::MESSAGE_TYPE_TEST_EMAIL,
$subject,
$from,
$_POST['TO'],

View File

@@ -68,7 +68,7 @@ if ($userExists === true && $userData['USR_EMAIL'] != '' && $userData['USR_EMAIL
'',
'',
0,
'TEST',
WsBase::MESSAGE_TYPE_RETRIEVE_PASSWORD,
$subject,
$from,
$data['USR_EMAIL'],

View File

@@ -378,6 +378,13 @@ function removeDocument($params)
return $res;
}
/**
* Send Message
*
* @param object $params
* @return array
*
*/
function SendMessage($params)
{
$vsResult = isValidSession($params->sessionId);
@@ -393,7 +400,22 @@ function SendMessage($params)
}
$ws = new WsBase();
$res = $ws->sendMessage($params->caseId, $params->from, $params->to, $params->cc, $params->bcc, $params->subject, $params->template);
$res = $ws->sendMessage(
$params->caseId,
$params->from,
$params->to,
$params->cc,
$params->bcc,
$params->subject,
$params->template,
null,
null,
true,
0,
[],
0,
WsBase::MESSAGE_TYPE_SOAP
);
return $res->getPayloadArray();
}

View File

@@ -24,6 +24,7 @@ use ResultSet;
use SpoolRun;
use stdClass;
use Users as ClassUsers;
use WsBase;
/**
* Description of ActionsByEmailService
@@ -366,6 +367,9 @@ class ActionsByEmail
*
* @return string $message
* @throws Exception
*
* @see workflow/engine/methods/actionsByEmail/actionsByEmailAjax.php
* @see \ProcessMaker\Services\Api\ActionsByEmail::forwardMail()
*/
public function forwardMail(array $arrayData)
{
@@ -397,7 +401,7 @@ class ActionsByEmail
'',
$dataRes['APP_UID'],
$dataRes['DEL_INDEX'],
'TEST',
WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL,
$dataRes['ABE_REQ_SUBJECT'],
$aSetup['MESS_ACCOUNT'],
$dataRes['ABE_REQ_SENT_TO'],

View File

@@ -14,6 +14,7 @@ use ProcessMaker\Util\Common;
use Propel;
use ResultSet;
use UsersPeer;
use WsBase;
class EmailEvent
{
@@ -455,11 +456,13 @@ class EmailEvent
* @param string $prj_uid Unique id of Project
* @param string $eventUid Unique id of event
* @param array $arrayApplicationData Case data
* @param int $tasId id of task
*
* @return void
* @throws Exception
* @see \Derivation::executeEvent()
*/
public function sendEmail($appUID, $prj_uid, $eventUid, $arrayApplicationData)
public function sendEmail($appUID, $prj_uid, $eventUid, $arrayApplicationData, $tasId = 0)
{
if (!$this->existsEvent($prj_uid, $eventUid)) {
throw new Exception(G::LoadTranslation('ID_EMAIL_EVENT_DEFINITION_DOES_NOT_EXIST'));
@@ -511,7 +514,9 @@ class EmailEvent
}
}
if (!empty($emailTo)) {
PMFSendMessage(
$ws = new WsBase();
$ws->setTaskId($tasId);
$ws->sendMessage(
$appUID,
G::buildFrom($configEmailData),
$emailTo,
@@ -523,7 +528,9 @@ class EmailEvent
[],
true,
0,
$configEmailData
$configEmailData,
0,
WsBase::MESSAGE_TYPE_EMAIL_EVENT
);
} else {
Bootstrap::registerMonolog(

View File

@@ -8,6 +8,7 @@ use G;
use ProcessMaker\Core\System;
use SpoolRun;
use TemplatePower;
use WsBase;
class EmailServer
{
@@ -156,6 +157,7 @@ class EmailServer
*
* @return array, return array with result of send test mail
* @throws Exception
* @see EmailServer->testConnectionByStep()
*/
public function sendTestMail(array $arrayData)
{
@@ -203,7 +205,7 @@ class EmailServer
'',
'',
0,
'TEST',
WsBase::MESSAGE_TYPE_TEST_EMAIL,
G::LoadTranslation("ID_MESS_TEST_SUBJECT"),
G::buildFrom($configuration),
$arrayData["TO"],

View File

@@ -33,20 +33,39 @@ Ext.onReady(function(){
'<span> {APP_PRO_TITLE}</span>',
'</div></tpl>'
);
var columnRenderer = function(data, metadata, record, rowIndex,columnIndex, store) {
var new_text = metadata.style.split(';');
var style = '';
for (var i = 0; i < new_text.length -1 ; i++) {
var chain = new_text[i] +";";
if (chain.indexOf('width') == -1) {
style = style + chain;
}
}
metadata.attr = 'ext:qtip="' + data + '" style="'+ style +' white-space: normal; "';
if(metadata.id == PMExt.emailConst.taskColumn.name){
if((PMExt.emailConst.appMsgTypeWithoutTask.includes(record.data.APP_MSG_TYPE)) || (PMExt.emailConst.appMsgTypeWithConditionalTask.includes(record.data.APP_MSG_TYPE) && record.data.DEL_INDEX == 0)){
data = PMExt.emailConst.taskColumn.defaultValue;
}
}
if(metadata.id == PMExt.emailConst.caseColumn.name){
if(PMExt.emailConst.appMsgTypeWithoutCase.includes(record.data.APP_MSG_TYPE)){
data = PMExt.emailConst.caseColumn.defaultValue;
}
}
if(metadata.id == PMExt.emailConst.processColumn.name){
if(PMExt.emailConst.appMsgTypeWithoutProcess.includes(record.data.APP_MSG_TYPE)){
data = PMExt.emailConst.processColumn.defaultValue;
}
}
if(metadata.id == PMExt.emailConst.numberColumn.name){
if(PMExt.emailConst.appMsgTypeWithoutNumber.includes(record.data.APP_MSG_TYPE)){
data = PMExt.emailConst.numberColumn.defaultValue;
}
}
var new_text = metadata.style.split(';');
var style = '';
for (var i = 0; i < new_text.length -1 ; i++) {
var chain = new_text[i] +";";
if (chain.indexOf('width') == -1) {
style = style + chain;
}
}
metadata.attr = 'ext:qtip="' + data + '" style="'+ style +' white-space: normal; "';
return PMExt.escapeHtml(data);
};
return PMExt.escapeHtml(data);
};
var dateFrom = new Ext.form.DateField({
id:'dateFrom',