Merged in bugfix/PMCORE-959 (pull request #7322)
PMCORE-959 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
120d3010c9
File diff suppressed because one or more lines are too long
@@ -7100,8 +7100,8 @@ msgstr "Delete data..."
|
||||
# TRANSLATION
|
||||
# LABEL/ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE
|
||||
#: LABEL/ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE
|
||||
msgid "[LABEL/ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE] Do you want to delete the Email Server?"
|
||||
msgstr "Do you want to delete the Email Server?"
|
||||
msgid "[LABEL/ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE] Are you sure you want to delete this Email Server? the components that were using it will now use the default email server."
|
||||
msgstr "Are you sure you want to delete this Email Server? the components that were using it will now use the default email server."
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_EMAIL_SERVER_DOES_NOT_EXIST
|
||||
|
||||
@@ -58003,7 +58003,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_EMAIL_SERVER_CONFIRM_DELETE','en','Do you want to delete the Email Server?','2014-12-24') ,
|
||||
( 'LABEL','ID_EMAIL_SERVER_DEFAULT','en','Default','2014-12-24') ,
|
||||
( 'LABEL','ID_EMAIL_SERVER_DELETE_DATA','en','Delete data...','2014-12-24') ,
|
||||
( 'LABEL','ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE','en','Do you want to delete the Email Server?','2015-01-15') ,
|
||||
( 'LABEL','ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE','en','Are you sure you want to delete this Email Server? the components that were using it will now use the default email server.','2015-01-15') ,
|
||||
( 'LABEL','ID_EMAIL_SERVER_DOES_NOT_EXIST','en','The email server with {0}: {1} does not exist.','2014-12-24') ,
|
||||
( 'LABEL','ID_EMAIL_SERVER_EDIT','en','Edit Email Server','2014-12-24') ,
|
||||
( 'LABEL','ID_EMAIL_SERVER_FROM_MAIL_EMPTY','en','The email has not been sent because configuration email in the Email Server Settings (admin/settings/email) is empty. Please fill this information.','2016-03-13') ,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -97,4 +97,41 @@ class AbeConfiguration extends model
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Receiver Uid when the email server is deleted
|
||||
*
|
||||
* @param string $emailServerUid
|
||||
* @return void
|
||||
*/
|
||||
public function updateReceiverUidToEmpty($emailServerUid)
|
||||
{
|
||||
$query = AbeConfiguration::query();
|
||||
|
||||
$query->where('ABE_EMAIL_SERVER_RECEIVER_UID', '=', $emailServerUid);
|
||||
|
||||
$query->update(['ABE_EMAIL_SERVER_RECEIVER_UID' => '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Email Server Uid when the email server is deleted
|
||||
*
|
||||
* @param string $emailServerUid
|
||||
* @return void
|
||||
*/
|
||||
public function updateEmailServerUidToDefaultOrEmpty($emailServerUid)
|
||||
{
|
||||
$emailServerModel = new EmailServerModel();
|
||||
$emailServerDefault = $emailServerModel->getEmailServerDefault();
|
||||
|
||||
$query = AbeConfiguration::query();
|
||||
|
||||
$query->where('ABE_EMAIL_SERVER_UID', '=', $emailServerUid);
|
||||
|
||||
if (!empty($emailServerDefault)) {
|
||||
$query->update(['ABE_EMAIL_SERVER_UID' => $emailServerDefault['MESS_UID']]);
|
||||
} else {
|
||||
$query->update(['ABE_EMAIL_SERVER_UID' => '']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,31 @@
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
|
||||
class EmailEvent extends Model
|
||||
{
|
||||
protected $table = 'EMAIL_EVENT';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Update the email event when the email server is deleted
|
||||
*
|
||||
* @param $emailServerUid
|
||||
* @return void
|
||||
*/
|
||||
public function updateServerAndFromToDefaultOrEmpty($emailServerUid)
|
||||
{
|
||||
$emailServerModel = new EmailServerModel();
|
||||
$emailServerDefault = $emailServerModel->getEmailServerDefault();
|
||||
$query = EmailEvent::query();
|
||||
|
||||
$query->where('EMAIL_SERVER_UID', '=', $emailServerUid);
|
||||
|
||||
if (!empty($emailServerDefault)) {
|
||||
$query->update(['EMAIL_SERVER_UID' => $emailServerDefault['MESS_UID'], 'EMAIL_EVENT_FROM' => $emailServerDefault['MESS_ACCOUNT']]);
|
||||
} else {
|
||||
$query->update(['EMAIL_SERVER_UID' => '', 'EMAIL_EVENT_FROM' => '']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,4 +103,22 @@ class EmailServerModel extends Model
|
||||
|
||||
return $firstElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the email server is IMAP
|
||||
*
|
||||
* @param string $emailServerUid
|
||||
* @return boolean
|
||||
*/
|
||||
public function isImap($emailServerUid)
|
||||
{
|
||||
$query = EmailServerModel::query()->select(['EMAIL_SERVER.MESS_UID']);
|
||||
$query->where('EMAIL_SERVER.MESS_UID', '=', $emailServerUid);
|
||||
$query->where('MESS_ENGINE', '=', 'IMAP');
|
||||
$res = $query->get()->values()->toArray();
|
||||
if (!empty($res)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user