email_event_solved

Conflicts:
	workflow/engine/config/schema.xml
This commit is contained in:
marcelo.cuiza
2015-06-25 16:57:18 -04:00
18 changed files with 7490 additions and 11 deletions

View File

@@ -0,0 +1,498 @@
<?php
namespace ProcessMaker\BusinessModel;
class EmailEvent
{
/*private $arrayFieldDefinition = array(
"EMAIL_EVENT_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "emailEventUid"),
"PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"),
"EVN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUid"),
"EMAIL_EVENT_FROM" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "messageTypeUid"),
"EMAIL_EVENT_TO" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "EmailEventUserUid"),
"EMAIL_EVENT_SUBJECT" => array("type" => "array", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "EmailEventVariables"),
"PRF_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "EmailEventCorrelation")
);
*/
/**
* Get the email accounts of the current workspace
*
* return array
*/
public function getEmailEventAccounts()
{
try {
$criteria = new \Criteria("workflow");
$criteria->clearSelectColumns();
$criteria->addSelectColumn(\UsersPeer::USR_UID);
$criteria->addSelectColumn(\UsersPeer::USR_EMAIL);
$criteria->add(\UsersPeer::USR_STATUS, "ACTIVE");
$result = \UsersPeer::doSelectRS($criteria);
$result->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$result->next();
$accountsArray = array();
while ($aRow = $result->getRow()) {
if (($aRow['USR_EMAIL'] != null) || ($aRow['USR_EMAIL'] != "")) {
$accountsArray[] = array_change_key_case($aRow, CASE_LOWER);
}
$result->next();
}
return $accountsArray;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get the Email-Event data
* @var string $evn_uid. uid for activity
* @var string $pro_uid. uid for process
* return array
*/
public function getEmailEventData($pro_uid, $evn_uid)
{
try {
//Get data
$criteria = $this->getEmailEventCriteria();
$criteria->add(\EmailEventPeer::EVN_UID, $evn_uid, \Criteria::EQUAL);
$criteria->add(\EmailEventPeer::PRJ_UID, $pro_uid, \Criteria::EQUAL);
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$row = $rsCriteria->getRow();
if(is_array($row)) {
$row = array_change_key_case($row, CASE_LOWER);
}
return $row;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get the Email-Event data
* @var string $emailEventUid. uid for email event
* @var string $pro_uid. uid for process
* return array
*/
public function getEmailEventDataByUid($pro_uid, $emailEventUid)
{
try {
//Get data
$criteria = $this->getEmailEventCriteria();
$criteria->add(\EmailEventPeer::EMAIL_EVENT_UID, $emailEventUid, \Criteria::EQUAL);
$criteria->add(\EmailEventPeer::PRJ_UID, $pro_uid, \Criteria::EQUAL);
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$row = $rsCriteria->getRow();
if(is_array($row)) {
$row = array_change_key_case($row, CASE_LOWER);
}
return $row;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Save Data for Email-Event
* @var string $prj_uid. Uid for Process
* @var string $arrayData. Data for Trigger
*
* return array
*/
public function save($prj_uid = '', $arrayData = array())
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
//Verify data
$process->throwExceptionIfNotExistsProcess($prj_uid, "projectUid");
//Create
$db = \Propel::getConnection("workflow");
try {
$emailEvent = new \EmailEvent();
$emailEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
$emailEventUid = \ProcessMaker\Util\Common::generateUID();
$emailEvent->setEmailEventUid($emailEventUid);
$emailEvent->setPrjUid($prj_uid);
$db->begin();
$result = $emailEvent->save();
$db->commit();
return $this->getEmailEvent($emailEventUid);
} catch (\Exception $e) {
$db->rollback();
throw $e;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Update Email-Event
*
* @param string $emailEventUid Unique id of Email-Event
* @param array $arrayData Data
*
* return array Return data of the Email-Event updated
*/
public function update($emailEventUid, array $arrayData)
{
try {
//Verify data
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
$arrayDataBackup = $arrayData;
//Set variables
$arrayEmailEventData = $this->getEmailEvent($emailEventUid);
//Verify data
$this->verifyIfEmailEventExists($emailEventUid);
//Update
$db = \Propel::getConnection("workflow");
try {
$emailEvent = \EmailEventPeer::retrieveByPK($emailEventUid);
$emailEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
$db->begin();
$result = $emailEvent->save();
$db->commit();
$arrayData = $arrayDataBackup;
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
return $arrayData;
} catch (\Exception $e) {
$cnn->rollback();
throw $e;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Delete Email-Event
*
* @param string $emailEventUid Unique id of Email-Event
*
* return void
*/
public function delete($pro_uid, $emailEventUid, $passValidation = true)
{
try {
//Verify data
if($passValidation) {
$this->verifyIfEmailEventExists($emailEventUid);
//Delete file
$filesManager = new \ProcessMaker\BusinessModel\FilesManager();
$arrayData = $this->getEmailEventDataByUid($pro_uid, $emailEventUid);
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
if(sizeof($arrayData)) {
$prfUid = $arrayData['PRF_UID'];
$filesManager->deleteProcessFilesManager('',$prfUid);
}
}
//Delete Email event
$criteria = new \Criteria("workflow");
$criteria->add(\EmailEventPeer::EMAIL_EVENT_UID, $emailEventUid, \Criteria::EQUAL);
$result = \EmailEventPeer::doDelete($criteria);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Delete Email-Event by event uid
*
* @param string $emailEventUid Unique id of Email-Event
*
* return void
*/
public function deleteByEvent($prj_uid, $evn_uid)
{
try {
//Verify data
if (!$this->existsEvent($prj_uid, $evn_uid)) {
throw new \Exception(\G::LoadTranslation("ID_EMAIL_EVENT_DEFINITION_DOES_NOT_EXIST"));
}
$arrayData = $this->existsEvent($prj_uid, $evn_uid);
$this->delete($prj_uid, $arrayData[0]);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get data of a Email-Event
*
* @param string $emailEventUid Unique id of Email-Event
* @param bool $flagGetRecord Value that set the getting
*
* return array Return an array with data of a Email-Event
*/
public function getEmailEvent($emailEventUid)
{
try {
//Verify data
$this->verifyIfEmailEventExists($emailEventUid);
//Get data
$criteria = $this->getEmailEventCriteria();
$criteria->add(\EmailEventPeer::EMAIL_EVENT_UID, $emailEventUid, \Criteria::EQUAL);
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$row = $rsCriteria->getRow();
//Return
return $row;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the Email-Event
*
* @param string $emailEventUid Unique id of Email-Event
*
* return bool Return true if exists the Email-Event, false otherwise
*/
public function exists($emailEventUid)
{
try {
$obj = \EmailEventPeer::retrieveByPK($emailEventUid);
return (!is_null($obj))? true : false;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get criteria for Email-Event
*
* return object
*/
public function getEmailEventCriteria()
{
try {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_UID);
$criteria->addSelectColumn(\EmailEventPeer::PRJ_UID);
$criteria->addSelectColumn(\EmailEventPeer::EVN_UID);
$criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_FROM);
$criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_TO);
$criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_SUBJECT);
$criteria->addSelectColumn(\EmailEventPeer::PRF_UID);
return $criteria;
} catch (\Exception $e) {
throw $e;
}
}
public function verifyIfEmailEventExists($emailEventUid)
{
if (!$this->exists($emailEventUid)) {
throw new \Exception(\G::LoadTranslation("ID_EMAIL_EVENT_DEFINITION_DOES_NOT_EXIST", array("Email Event Uid", $emailEventUid)));
}
}
/**
* Verify if exists the Event of a Message-Event-Definition
*
* @param string $projectUid Unique id of Project
* @param string $eventUid Unique id of Event
*
* return bool Return true if exists the Event of a Message-Event-Definition, false otherwise
*/
public function existsEvent($projectUid, $eventUid)
{
try {
$criteria = $this->getEmailEventCriteria();
$criteria->add(\EmailEventPeer::PRJ_UID, $projectUid, \Criteria::EQUAL);
$criteria->add(\EmailEventPeer::EVN_UID, $eventUid, \Criteria::EQUAL);
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
$rsCriteria->next();
$row = $rsCriteria->getRow();
if(is_array($row)) {
$row = array_change_key_case($row, CASE_LOWER);
}
return (sizeof($row))? $row : false;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Email-event for the Case
*
* @param string $elementOriginUid Unique id of Element Origin (unique id of Task)
* @param string $elementDestUid Unique id of Element Dest (unique id of Task)
* @param array $arrayApplicationData Case data
*
* return void
*/
public function emailEventBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData)
{
try {
//Verify if the Project is BPMN
$bpmn = new \ProcessMaker\Project\Bpmn();
if (!$bpmn->exists($arrayApplicationData["PRO_UID"])) {
return;
}
//Element origin and dest
$elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
$arrayElement = array(
"elementOrigin" => array("uid" => $elementOriginUid, "type" => "bpmnActivity"),
"elementDest" => array("uid" => $elementDestUid, "type" => "bpmnActivity")
);
foreach ($arrayElement as $key => $value) {
$arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
array(
\ElementTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"],
\ElementTaskRelationPeer::ELEMENT_TYPE => "bpmnEvent",
\ElementTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"]
),
true
);
if (!is_null($arrayElementTaskRelationData)) {
$arrayElement[$key]["uid"] = $arrayElementTaskRelationData["ELEMENT_UID"];
$arrayElement[$key]["type"] = "bpmnEvent";
}
}
$elementOriginUid = $arrayElement["elementOrigin"]["uid"];
$elementOriginType = $arrayElement["elementOrigin"]["type"];
$elementDestUid = $arrayElement["elementDest"]["uid"];
$elementDestType = $arrayElement["elementDest"]["type"];
//Get Message-Events of throw type
$arrayEvent = $bpmn->getEmailEventTypeBetweenElementOriginAndElementDest(
$elementOriginUid,
$elementOriginType,
$elementDestUid,
$elementDestType
);
//Email-event
foreach ($arrayEvent as $value) {
$result = $this->sendEmail($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData);
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Email-event do function
*
* @param string $appUID Unique id of application
* @param string $prj_uid Unique id of Project
* @param string $eventUid Unique id of event
* @param array $arrayApplicationData Case data
*
* return void
*/
public function sendEmail($appUID, $prj_uid, $eventUid, $arrayApplicationData)
{
if (!$this->existsEvent($prj_uid, $eventUid)) {
throw new \Exception(\G::LoadTranslation("ID_EMAIL_EVENT_DEFINITION_DOES_NOT_EXIST"));
}
$arrayData = $this->existsEvent($prj_uid, $eventUid);
if(sizeof($arrayData)) {
$prfUid = $arrayData[6];
$filesManager = new \ProcessMaker\BusinessModel\FilesManager();
$contentFile = $filesManager->getProcessFileManager($prj_uid, $prfUid);
\PMFSendMessage($appUID, $arrayData[3], $arrayData[4], '', '', $arrayData[5], $contentFile['prf_filename'], array());
}
}
/**
* Update process file Uid
*
* @param string $oldUid Unique id of old process file
* @param string $newUid Unique id of new process file
* @param string $projectUid Unique id of Project
*
* return bool Return array if exists, false otherwise
*/
public function updatePrfUid($oldUid, $newUid, $projectUid) {
try {
$newValues = array();
$rowData = $this->verifyIfEmailEventExistsByPrfUid($oldUid, $projectUid);
if(is_array($rowData)) {
$newValues['PRF_UID'] = $newUid;
$this->update($rowData['EMAIL_EVENT_UID'], $newValues);
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the Email Event of
*
* @param string $oldUid Unique id of old process file
* @param string $projectUid Unique id of Project
*
* return bool Return array if exists, false otherwise
*/
public function verifyIfEmailEventExistsByPrfUid($oldUid, $projectUid)
{
try {
$criteria = $this->getEmailEventCriteria();
$criteria->add(\EmailEventPeer::PRJ_UID, $projectUid, \Criteria::EQUAL);
$criteria->add(\EmailEventPeer::PRF_UID, $oldUid, \Criteria::EQUAL);
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$row = $rsCriteria->getRow();
if(is_array($row)) {
$row = array_change_key_case($row, CASE_UPPER);
}
return (sizeof($row))? $row : false;
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -242,6 +242,41 @@ class FilesManager
throw $e;
}
}
public function addProcessFilesManagerInDb($aData)
{
try {
$oProcessFiles = new \ProcessFiles();
$aData = array_change_key_case($aData, CASE_UPPER);
$oProcessFiles->fromArray($aData, \BasePeer::TYPE_FIELDNAME);
if($this->existsProcessFile($aData['PRF_UID'])) {
$sPkProcessFiles = \G::generateUniqueID();
$oProcessFiles->setPrfUid($sPkProcessFiles);
$sDirectory = PATH_DATA_MAILTEMPLATES . $aData['PRO_UID'] . PATH_SEP . basename($aData['PRF_PATH']);
$oProcessFiles->setPrfPath($sDirectory);
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
$emailEvent->updatePrfUid($aData['PRF_UID'], $sPkProcessFiles, $aData['PRO_UID']);
}
$result = $oProcessFiles->save();
} catch (Exception $e) {
throw $e;
}
}
public function existsProcessFile($prfUid)
{
try {
$obj = \ProcessFilesPeer::retrieveByPK($prfUid);
return (!is_null($obj))? true : false;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Return the Process Files Manager
@@ -306,9 +341,11 @@ class FilesManager
public function getFileManagerUid($path)
{
try {
$path = explode("/",$path);
$baseName = $path[count($path)-2].DIRECTORY_SEPARATOR.$path[count($path)-1];
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID);
$criteria->add(\ProcessFilesPeer::PRF_PATH, $path, \Criteria::EQUAL);
$criteria->add(\ProcessFilesPeer::PRF_PATH, "%" . $baseName . "%", \Criteria::LIKE);
$rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
@@ -371,6 +408,9 @@ class FilesManager
$oProcessFiles->setPrfUpdateUsrUid($userUID);
$oProcessFiles->setPrfUpdateDate($sDate);
$oProcessFiles->save();
$path = PATH_DATA_MAILTEMPLATES.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
$fp = fopen($path, 'w');
$content = stripslashes($aData['prf_content']);
$content = str_replace("@amp@", "&", $content);
@@ -417,8 +457,11 @@ class FilesManager
if ($path == '') {
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid')));
}
if (file_exists($path)) {
$sFile = end(explode("/",$path));
$path = PATH_DATA_MAILTEMPLATES.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
if (file_exists($path) && !is_dir($path)) {
unlink($path);
}

View File

@@ -391,7 +391,7 @@ abstract class Importer
foreach ($arrayWorkflowTables["tasks"] as $key => $value) {
$arrayTaskData = $value;
if (!in_array($arrayTaskData["TAS_TYPE"], array("GATEWAYTOGATEWAY", "WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT"))) {
if (!in_array($arrayTaskData["TAS_TYPE"], array("GATEWAYTOGATEWAY", "WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "END-EMAIL-EVENT", "INTERMEDIATE-EMAIL-EVENT"))) {
$result = $workflow->updateTask($arrayTaskData["TAS_UID"], $arrayTaskData);
}
}

View File

@@ -28,7 +28,8 @@ class BpmnWorkflow extends Project\Bpmn
"end-message-event" => array("type" => "END-MESSAGE-EVENT", "prefix" => "eme-"),
"start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"),
"intermediate-throw-message-event" => array("type" => "INTERMEDIATE-THROW-MESSAGE-EVENT", "prefix" => "itme-"),
"intermediate-catch-message-event" => array("type" => "INTERMEDIATE-CATCH-MESSAGE-EVENT", "prefix" => "icme-")
"intermediate-catch-message-event" => array("type" => "INTERMEDIATE-CATCH-MESSAGE-EVENT", "prefix" => "icme-"),
"end-email-event" => array("type" => "END-EMAIL-EVENT", "prefix" => "eee-")
);
private $arrayElementTaskRelation = array();
@@ -582,6 +583,20 @@ class BpmnWorkflow extends Project\Bpmn
$messageEventDefinition->delete($arrayMessageEventDefinitionData["MSGED_UID"]);
}
}
//Email-Event - Delete
$arrayEventType = array("END", "INTERMEDIATE");
$arrayEventMarker = array("EMAIL");
if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
if ($emailEvent->existsEvent($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid())) {
$arrayEmailEventData = $emailEvent->getEmailEventData($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid());
$arrayEmailEventData = array_change_key_case($arrayEmailEventData, CASE_UPPER);
$emailEvent->delete($bpmnEvent->getPrjUid(), $arrayEmailEventData["EMAIL_EVENT_UID"], true);
}
}
//Element-Task-Relation - Delete
$this->removeElementTaskRelation($bpmnEvent->getEvnUid(), "bpmnEvent");
@@ -850,6 +865,16 @@ class BpmnWorkflow extends Project\Bpmn
$result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault);
$result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL");
break;
case "EMAIL":
$taskUid = $this->createTaskByElement(
$event->getEvnUid(),
"bpmnEvent",
"end-email-event"
);
$result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault);
$result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL");
break;
default:
//EMPTY //and others types
$result = $this->wp->addRoute($activityUid, -1, $routeType, $routeCondition, $routeDefault);
@@ -938,6 +963,16 @@ class BpmnWorkflow extends Project\Bpmn
"end-message-event"
);
$result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault);
$result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL");
break;
case "EMAIL":
$taskUid = $this->createTaskByElement(
$event->getEvnUid(),
"bpmnEvent",
"end-email-event"
);
$result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault);
$result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL");
break;
@@ -1025,6 +1060,16 @@ class BpmnWorkflow extends Project\Bpmn
$result = $this->wp->addRoute($activity["ACT_UID"], $taskUid, "SEQUENTIAL");
$result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL");
break;
case "EMAIL":
$taskUid = $this->createTaskByElement(
$event->getEvnUid(),
"bpmnEvent",
"end-email-event"
);
$result = $this->wp->addRoute($activity["ACT_UID"], $taskUid, "SEQUENTIAL");
$result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL");
break;
default:
//EMPTY //This it's already implemented
//and others types

View File

@@ -1473,5 +1473,50 @@ class Bpmn extends Handler
throw $e;
}
}
public function getEmailEventTypeBetweenElementOriginAndElementDest(
$elementOriginUid,
$elementOriginType,
$elementDestUid,
$elementDestType
) {
try {
$arrayEventType = array("END", "INTERMEDIATE");
$arrayEventMarker = array("EMAIL");
$this->arrayElementOriginChecked = array();
$arrayEventAux = $this->getElementsBetweenElementOriginAndElementDest(
$elementOriginUid,
$elementOriginType,
$elementDestUid,
$elementDestType,
0
);
ksort($arrayEventAux);
$arrayEvent = array();
foreach ($arrayEventAux as $value) {
if ($value[1] == "bpmnEvent") {
$event = \BpmnEventPeer::retrieveByPK($value[0]);
if (!is_null($event) &&
in_array($event->getEvnType(), $arrayEventType) && in_array($event->getEvnMarker(), $arrayEventMarker)
) {
$arrayEvent[] = $value;
}
}
}
//Return
return $arrayEvent;
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
throw $e;
}
}
}

View File

@@ -855,6 +855,32 @@ class Workflow extends Handler
$messageEventDefinition->delete($row["MSGED_UID"]);
}
//Delete Email-Event
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_UID);
$criteria->add(\EmailEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$emailEvent->delete($sProcessUID,$row["EMAIL_EVENT_UID"],false);
}
//Delete files Manager
$filesManager = new \ProcessMaker\BusinessModel\FilesManager();
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID);
$criteria->add(\ProcessFilesPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
$rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$filesManager->deleteProcessFilesManager($sProcessUID, $row["PRF_UID"]);
}
//Delete Script-Task
$scriptTask = new \ProcessMaker\BusinessModel\ScriptTask();
@@ -1258,6 +1284,22 @@ class Workflow extends Handler
}
}
}
//Update EMAIL_EVENT.EVN_UID
if (isset($arrayWorkflowData["emailEvent"])) {
foreach ($arrayWorkflowData["emailEvent"] as $key => $value) {
$emailEventEventUid = $arrayWorkflowData["emailEvent"][$key]["EVN_UID"];
foreach ($arrayUid as $value2) {
$arrayItem = $value2;
if ($arrayItem["old_uid"] == $emailEventEventUid) {
$arrayWorkflowData["emailEvent"][$key]["EVN_UID"] = $arrayItem["new_uid"];
break;
}
}
}
}
//Update SCRIPT_TASK.ACT_UID
if (isset($arrayWorkflowData["scriptTask"])) {

View File

@@ -0,0 +1,123 @@
<?php
namespace ProcessMaker\Services\Api\Project;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Project\EmailEvent Api Controller
*
* @protected
*/
class EmailEvent extends Api
{
private $EmailEvent;
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
$this->EmailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url GET /:prj_uid/email-event/accounts
*
* @param string $prj_uid {@min 1} {@max 32}
*/
public function doGetEmailEventAccounts($prj_uid)
{
try {
$response = $this->EmailEvent->GetEmailEventAccounts();
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:prj_uid/email-event/:act_uid
*
* @param string $prj_uid {@min 1} {@max 32}
* @param string $act_uid {@min 1} {@max 32}
*/
public function doGetEmailEvent($prj_uid, $act_uid)
{
try {
$response = $this->EmailEvent->getEmailEventData($prj_uid, $act_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url POST /:prj_uid/email-event
*
* @param string $prj_uid {@min 1} {@max 32}
*/
public function doPostEmailEvent($prj_uid, array $request_data)
{
try {
$response = $this->EmailEvent->save($prj_uid, $request_data);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url PUT /:prj_uid/email-event/:email_event_uid
*
* @param string $prj_uid {@min 32}{@max 32}
* @param string $email_event_uid {@min 32}{@max 32}
* @param array $request_data
*/
public function doPutEmailEvent($prj_uid, $email_event_uid, array $request_data)
{
try {
$arrayData = $this->EmailEvent->update($email_event_uid, $request_data);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url DELETE /:prj_uid/email-event/:email_event_uid
*
* @param string $prj_uid {@min 32}{@max 32}
* @param string $email_event_uid {@min 32}{@max 32}
*/
public function doDeleteEmailEvent($prj_uid, $email_event_uid)
{
try {
$this->EmailEvent->delete($prj_uid, $email_event_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url DELETE /:prj_uid/email-event/by-event/:act_uid
*
* @param string $prj_uid {@min 32}{@max 32}
* @param string $act_uid {@min 32}{@max 32}
*/
public function doDeleteEmailEventByEvent ($prj_uid, $act_uid)
{
try {
$this->EmailEvent->deleteByEvent($prj_uid, $act_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}

View File

@@ -42,7 +42,7 @@ debug = 1
web-entry-event = "ProcessMaker\Services\Api\Project\WebEntryEvent"
message-event-definition = "ProcessMaker\Services\Api\Project\MessageEventDefinition"
script-task = "ProcessMaker\Services\Api\Project\ScriptTask"
email-event = "ProcessMaker\Services\Api\Project\EmailEvent"
email-event = "ProcessMaker\Services\Api\Project\EmailEvent"
[alias: projects]
project = "ProcessMaker\Services\Api\Project"