Merged in feature/HOR-4823 (pull request #6604)
HOR-4825 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\BusinessModel\EmailEvent;
|
||||
use ProcessMaker\Core\System;
|
||||
|
||||
class Processes
|
||||
@@ -4183,26 +4184,19 @@ class Processes
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createEmailEvent($processUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
|
||||
|
||||
$emailServer = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
$arrayEmailServerDefault = $emailServer->getEmailServerDefault();
|
||||
|
||||
$emailEvent = new EmailEvent();
|
||||
foreach ($arrayData as $value) {
|
||||
if (isset($value['__EMAIL_SERVER_UID_PRESERVED__']) && $value['__EMAIL_SERVER_UID_PRESERVED__'] === true) {
|
||||
unset($value['__EMAIL_SERVER_UID_PRESERVED__']);
|
||||
} else {
|
||||
} elseif(!EmailServer::exists($value['EMAIL_SERVER_UID'])) {
|
||||
unset($value['EMAIL_EVENT_FROM']);
|
||||
unset($value['EMAIL_SERVER_UID']);
|
||||
if (!empty($arrayEmailServerDefault)) {
|
||||
$value['EMAIL_EVENT_FROM'] = $arrayEmailServerDefault['MESS_ACCOUNT'];
|
||||
$value['EMAIL_SERVER_UID'] = $arrayEmailServerDefault['MESS_UID'];
|
||||
}
|
||||
}
|
||||
|
||||
$emailEventData = $emailEvent->save($processUid, $value);
|
||||
|
||||
@@ -1,28 +1,46 @@
|
||||
<?php
|
||||
|
||||
class EmailServer extends BaseEmailServer
|
||||
{
|
||||
/**
|
||||
* Get the evn_description column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function loadDefaultAccount ()
|
||||
{
|
||||
$c = new Criteria( 'workflow' );
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
/**
|
||||
* Load the default account
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function loadDefaultAccount()
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(EmailServerPeer::MESS_ACCOUNT);
|
||||
$c->add(EmailServerPeer::MESS_DEFAULT, 1);
|
||||
$rs = EmailServerPeer::doSelectRS($c, Propel::getDBConnection('workflow_ro'));
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$response = $rs->getRow();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( EmailServerPeer::MESS_ACCOUNT );
|
||||
return $response;
|
||||
}
|
||||
|
||||
$c->add( EmailServerPeer::MESS_DEFAULT, 1 );
|
||||
/**
|
||||
* Check if the MESS_UID exist
|
||||
*
|
||||
* @param string $emailServerUid
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function exists($emailServerUid)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->add(EmailServerPeer::MESS_UID, $emailServerUid, Criteria::EQUAL);
|
||||
$dataset = EmailServerPeer::doSelectOne($criteria);
|
||||
|
||||
$rs = EmailServerPeer::doSelectRS( $c, Propel::getDBConnection('workflow_ro') );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
$response=$row;
|
||||
return !is_null($dataset);
|
||||
|
||||
return $response;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -466,8 +466,17 @@ class EmailEvent
|
||||
}
|
||||
$arrayData = $this->existsEvent($prj_uid, $eventUid);
|
||||
if (sizeof($arrayData)) {
|
||||
$oEmailServer = new EmailServer();
|
||||
$configEmailData = $oEmailServer->getEmailServer($arrayData[7]);
|
||||
$emailServer = new EmailServer();
|
||||
if (empty($arrayData[7])){
|
||||
$configEmailData = $emailServer->getEmailServerDefault();
|
||||
//We will to show a message, if is not defined the email server default
|
||||
if(empty($configEmailData)){
|
||||
$emailServer->throwExceptionIfNotExistsEmailServer('', 'MESS_UID');
|
||||
}
|
||||
} else {
|
||||
$configEmailData = $emailServer->getEmailServer($arrayData[7]);
|
||||
}
|
||||
|
||||
$emailGroupTo = [];
|
||||
$emailTo = '';
|
||||
$prfUid = $arrayData[6];
|
||||
|
||||
Reference in New Issue
Block a user