PMCORE-959

This commit is contained in:
Andrea Adamczyk
2020-04-17 09:38:03 -04:00
parent b7586c06f0
commit 890e0c9e8e
11 changed files with 330 additions and 5 deletions

View File

@@ -7,6 +7,9 @@ use Exception;
use G;
use Illuminate\Support\Facades\Crypt;
use ProcessMaker\Core\System;
use ProcessMaker\Model\AbeConfiguration;
use ProcessMaker\Model\EmailEvent;
use ProcessMaker\Model\EmailServerModel;
use SpoolRun;
use TemplatePower;
use WsBase;
@@ -1071,6 +1074,11 @@ class EmailServer
public function delete($emailServerUid)
{
try {
$emailServerModel = new EmailServerModel();
//Verify if the email server is IMAP
$isImap = $emailServerModel->isImap($emailServerUid);
$abeConfiguration = new AbeConfiguration();
//Verify data
$this->throwExceptionIfNotExistsEmailServer($emailServerUid, $this->arrayFieldNameForException["emailServerUid"]);
$this->throwExceptionIfIsDefault($emailServerUid, $this->arrayFieldNameForException["emailServerUid"]);
@@ -1078,6 +1086,18 @@ class EmailServer
$criteria->add(\EmailServerPeer::MESS_UID, $emailServerUid, \Criteria::EQUAL);
\EmailServerPeer::doDelete($criteria);
//If the email server protocol is IMAP, then the field Receiver account of the Email Response option in Actions by Email will be empty.
if ($isImap) {
$abeConfiguration->updateReceiverUidToEmpty($emailServerUid);
}
//Update the ABE_CONFIGURATION email server
$abeConfiguration->updateEmailServerUidToDefaultOrEmpty($emailServerUid);
//Update the events that use this server
$emailEvent = new EmailEvent();
$emailEvent->updateServerAndFromToDefaultOrEmpty($emailServerUid);
//Logging the delete action
$this->getDefaultContextLog();
$info = array(