PMC-778
This commit is contained in:
committed by
Paula Quispe
parent
5344dc7f32
commit
90a8150bd7
31
database/factories/AbeConfigurationFactory.php
Normal file
31
database/factories/AbeConfigurationFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\AbeConfiguration::class, function (Faker $faker) {
|
||||
$process = \ProcessMaker\Model\Process::all()->random();
|
||||
$task = \ProcessMaker\Model\Task::all()->random();
|
||||
$dynaForm = \ProcessMaker\Model\Dynaform::all()->random();
|
||||
$emailServer = \ProcessMaker\Model\EmailServerModel::all()->random();
|
||||
return [
|
||||
'ABE_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'ABE_TYPE' => $faker->randomElement(['', 'LINK']),
|
||||
'ABE_TEMPLATE' => 'actionByEmail.html',
|
||||
'ABE_DYN_TYPE' => 'NORMAL',
|
||||
'DYN_UID' => $dynaForm->DYN_UID,
|
||||
'ABE_EMAIL_FIELD' => 'admin@processmaker.com',
|
||||
'ABE_ACTION_FIELD' => '',
|
||||
'ABE_CASE_NOTE_IN_RESPONSE' => $faker->randomElement(['0', '1']),
|
||||
'ABE_FORCE_LOGIN' => $faker->randomElement(['0', '1']),
|
||||
'ABE_CREATE_DATE' => $faker->dateTime(),
|
||||
'ABE_UPDATE_DATE' => $faker->dateTime(),
|
||||
'ABE_SUBJECT_FIELD' => '',
|
||||
'ABE_MAILSERVER_OR_MAILCURRENT' => 0,
|
||||
'ABE_CUSTOM_GRID' => '',
|
||||
'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID,
|
||||
'ABE_ACTION_BODY_FIELD' => '',
|
||||
'ABE_EMAIL_SERVER_RECEIVER_UID' => ''
|
||||
];
|
||||
});
|
||||
20
database/factories/AbeRequestFactory.php
Normal file
20
database/factories/AbeRequestFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\AbeRequest::class, function (Faker $faker) {
|
||||
$process = \ProcessMaker\Model\Application::all()->random();
|
||||
$abeConfiguration = \ProcessMaker\Model\AbeConfiguration::all()->random();
|
||||
return [
|
||||
'ABE_REQ_UID' => G::generateUniqueID(),
|
||||
'ABE_UID' => $abeConfiguration->ABE_UID,
|
||||
'APP_UID' => $process->APP_UID,
|
||||
'DEL_INDEX' => 0,
|
||||
'ABE_REQ_SENT_TO' => $faker->email,
|
||||
'ABE_REQ_SUBJECT' => '',
|
||||
'ABE_REQ_BODY' => '',
|
||||
'ABE_REQ_DATE' => $faker->date(),
|
||||
'ABE_REQ_STATUS' => '',
|
||||
'ABE_REQ_ANSWERED' => $faker->numberBetween(1, 9)
|
||||
];
|
||||
});
|
||||
2
database/factories/EmailServerFactory.php
Normal file → Executable file
2
database/factories/EmailServerFactory.php
Normal file → Executable file
@@ -2,7 +2,7 @@
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\EmailServer::class, function(Faker $faker) {
|
||||
$factory->define(\ProcessMaker\Model\EmailServerModel::class, function(Faker $faker) {
|
||||
return [
|
||||
'MESS_UID' => G::generateUniqueID(),
|
||||
'MESS_ENGINE' => '',
|
||||
|
||||
6
tests/unit/workflow/engine/classes/WsBaseTest.php
Normal file → Executable file
6
tests/unit/workflow/engine/classes/WsBaseTest.php
Normal file → Executable file
@@ -6,7 +6,7 @@ use Illuminate\Support\Facades\Queue;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppThread;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\EmailServer;
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\User;
|
||||
@@ -114,13 +114,13 @@ class WsBaseTest extends TestCase
|
||||
/**
|
||||
* Create a email server configuration.
|
||||
*
|
||||
* @return ProcessMaker\Model\EmailServer;
|
||||
* @return ProcessMaker\Model\EmailServerModel;
|
||||
*/
|
||||
private function createEmailServer()
|
||||
{
|
||||
$passwordEnv = env('emailAccountPassword');
|
||||
$password = G::encrypt("hash:" . $passwordEnv, 'EMAILENCRYPT');
|
||||
$emailServer = factory(EmailServer::class)->create([
|
||||
$emailServer = factory(EmailServerModel::class)->create([
|
||||
'MESS_ENGINE' => env('emailEngine'),
|
||||
'MESS_SERVER' => env('emailServer'),
|
||||
'MESS_PORT' => env('emailPort'),
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
||||
|
||||
use ProcessMaker\BusinessModel\ActionsByEmail;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AbeConfiguration;
|
||||
use ProcessMaker\Model\AbeRequest;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Dynaform;
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ActionsByEmailTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test the forwardMail method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ActionsByEmail::forwardMail()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_forward_mail_method()
|
||||
{
|
||||
//Create the Task factory
|
||||
factory(Task::class)->create();
|
||||
//Create the Process factory
|
||||
factory(Process::class)->create();
|
||||
//Create the Dynaform factory
|
||||
factory(Dynaform::class)->create();
|
||||
//Create the EmailServerModel factory
|
||||
factory(EmailServerModel::class)->create();
|
||||
//Create the Application factory
|
||||
factory(Application::class)->create();
|
||||
//Create the Delegation factory
|
||||
$delegation = factory(Delegation::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
$abeConfiguration = factory(AbeConfiguration::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
$abeRequest = factory(AbeRequest::class)->create([
|
||||
'ABE_UID' => $abeConfiguration->ABE_UID,
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'ABE_REQ_UID' => $abeConfiguration->ABE_UID,
|
||||
]);
|
||||
|
||||
//Prepare the array send to the method
|
||||
$arrayData = [
|
||||
'action' => 'forwardMail',
|
||||
'REQ_UID' => $abeRequest->ABE_REQ_UID,
|
||||
'limit' => '',
|
||||
'start' => ''
|
||||
];
|
||||
|
||||
//Create the ActionsByEmail object
|
||||
$abe = new ActionsByEmail();
|
||||
//Call the forwardMail method
|
||||
$res = $abe->forwardMail($arrayData);
|
||||
|
||||
//Assert the email was sent successfully
|
||||
$this->assertContains('**ID_EMAIL_RESENT_TO**: ' . $abeRequest->ABE_REQ_SENT_TO, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the forwardMail method when an error occurs
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ActionsByEmail::forwardMail()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_forward_mail_method_when_an_error_occurs()
|
||||
{
|
||||
//Create the Task factory
|
||||
factory(Task::class)->create();
|
||||
//Create the Process factory
|
||||
factory(Process::class)->create();
|
||||
//Create the Dynaform factory
|
||||
factory(Dynaform::class)->create();
|
||||
//Create the EmailServerModel factory
|
||||
factory(EmailServerModel::class)->create();
|
||||
//Create the Application factory
|
||||
factory(Application::class)->create();
|
||||
//Create the Delegation factory
|
||||
$delegation = factory(Delegation::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
$abeConfiguration = factory(AbeConfiguration::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
$abeRequest = factory(AbeRequest::class)->create([
|
||||
'ABE_UID' => $abeConfiguration->ABE_UID,
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'ABE_REQ_UID' => $abeConfiguration->ABE_UID
|
||||
]);
|
||||
|
||||
//Prepare the array send to the method
|
||||
$arrayData = [
|
||||
'action' => 'forwardMail',
|
||||
'REQ_UID' => '',
|
||||
'limit' => '',
|
||||
'start' => ''
|
||||
];
|
||||
|
||||
//Create the ActionsByEmail object
|
||||
$abe = new ActionsByEmail();
|
||||
//Call the forwardMail method
|
||||
$res = $abe->forwardMail($arrayData);
|
||||
|
||||
//Assert that an unexpected error occur
|
||||
$this->assertContains('**ID_UNEXPECTED_ERROR_OCCURRED_PLEASE**', $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the forwardMail method when the email cannot be sent
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ActionsByEmail::forwardMail()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_forward_mail_method_when_the_email_cannot_be_sent()
|
||||
{
|
||||
//Create the Task factory
|
||||
factory(Task::class)->create();
|
||||
//Create the Process factory
|
||||
factory(Process::class)->create();
|
||||
//Create the Dynaform factory
|
||||
factory(Dynaform::class)->create();
|
||||
//Create the EmailServerModel factory
|
||||
factory(EmailServerModel::class)->create();
|
||||
//Create the Application factory
|
||||
factory(Application::class)->create();
|
||||
//Create the Delegation factory
|
||||
$delegation = factory(Delegation::class)->create([
|
||||
'DEL_FINISH_DATE' => '2019-09-27 14:53:06'
|
||||
]);
|
||||
//Create the AbeConfiguration factory
|
||||
$abeConfiguration = factory(AbeConfiguration::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
$abeRequest = factory(AbeRequest::class)->create([
|
||||
'ABE_UID' => $abeConfiguration->ABE_UID,
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'ABE_REQ_UID' => $abeConfiguration->ABE_UID,
|
||||
]);
|
||||
|
||||
//Prepare the array send to the method
|
||||
$arrayData = [
|
||||
'action' => 'forwardMail',
|
||||
'REQ_UID' => $abeRequest->ABE_REQ_UID,
|
||||
'limit' => '',
|
||||
'start' => ''
|
||||
];
|
||||
|
||||
//Create the ActionsByEmail object
|
||||
$abe = new ActionsByEmail();
|
||||
//Call the forwardMail method
|
||||
$res = $abe->forwardMail($arrayData);
|
||||
|
||||
//Assert the email was not sent
|
||||
$this->assertContains('**ID_UNABLE_TO_SEND_EMAIL**', $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the forwardMail method when the REQ_UID is not set
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ActionsByEmail::forwardMail()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_forward_mail_method_when_the_req_uid_is_not_set()
|
||||
{
|
||||
//Create the Task factory
|
||||
factory(Task::class)->create();
|
||||
//Create the Process factory
|
||||
factory(Process::class)->create();
|
||||
//Create the Dynaform factory
|
||||
factory(Dynaform::class)->create();
|
||||
//Create the EmailServerModel factory
|
||||
factory(EmailServerModel::class)->create();
|
||||
//Create the Application factory
|
||||
factory(Application::class)->create();
|
||||
//Create the Delegation factory
|
||||
$delegation = factory(Delegation::class)->create([
|
||||
'DEL_FINISH_DATE' => '2019-09-27 14:53:06'
|
||||
]);
|
||||
//Create the AbeConfiguration factory
|
||||
$abeConfiguration = factory(AbeConfiguration::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
$abeRequest = factory(AbeRequest::class)->create([
|
||||
'ABE_UID' => $abeConfiguration->ABE_UID,
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'ABE_REQ_UID' => $abeConfiguration->ABE_UID,
|
||||
]);
|
||||
|
||||
//Prepare the array send to the method
|
||||
$arrayData = [
|
||||
'action' => 'forwardMail',
|
||||
'limit' => '',
|
||||
'start' => ''
|
||||
];
|
||||
|
||||
//Create the ActionsByEmail object
|
||||
$abe = new ActionsByEmail();
|
||||
//Call the forwardMail method
|
||||
$res = $abe->forwardMail($arrayData);
|
||||
|
||||
//Assert the email was not sent
|
||||
$this->assertContains('**ID_UNEXPECTED_ERROR_OCCURRED_PLEASE**', $res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AbeConfiguration;
|
||||
use ProcessMaker\Model\AbeRequest;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Dynaform;
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AbeConfigurationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Call the setUp parent method
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the tearDown parent method
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the getAbeRequest method
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AbeConfiguration::getAbeRequest()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_get_abe_request_method()
|
||||
{
|
||||
//Create the Task factory
|
||||
factory(Task::class)->create();
|
||||
//Create the Process factory
|
||||
factory(Process::class)->create();
|
||||
//Create the Dynaform factory
|
||||
factory(Dynaform::class)->create();
|
||||
//Create the EmailServerModel factory
|
||||
factory(EmailServerModel::class)->create();
|
||||
//Create the Application factory
|
||||
factory(Application::class)->create();
|
||||
//Create the Delegation factory
|
||||
$delegation = factory(Delegation::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
$abeConfiguration = factory(AbeConfiguration::class)->create();
|
||||
//Create the AbeConfiguration factory
|
||||
factory(AbeRequest::class)->create([
|
||||
'ABE_UID' => $abeConfiguration->ABE_UID,
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'ABE_REQ_UID' => $abeConfiguration->ABE_UID
|
||||
]);
|
||||
|
||||
//Call the getAbeRequest method
|
||||
$res = AbeConfiguration::getAbeRequest($abeConfiguration->ABE_UID);
|
||||
|
||||
//Assert the result is not empty
|
||||
$this->assertNotEmpty($res);
|
||||
//Assert the result is the one looked for
|
||||
$this->assertEquals($res['ABE_UID'], $abeConfiguration->ABE_UID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getAbeRequest method when the result is empty
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AbeConfiguration::getAbeRequest()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_get_abe_request_method_when_the_result_is_empty()
|
||||
{
|
||||
//Creates the Task factory
|
||||
factory(Task::class)->create();
|
||||
//Creates the Process factory
|
||||
factory(Process::class)->create();
|
||||
//Creates the Dynaform factory
|
||||
factory(Dynaform::class)->create();
|
||||
//Creates the EmailServer factory
|
||||
factory(EmailServerModel::class)->create();
|
||||
//Creates the Application factory
|
||||
factory(Application::class)->create();
|
||||
//Creates the Delegation factory
|
||||
$delegation = factory(Delegation::class)->create();
|
||||
//Creates the AbeConfiguration factory
|
||||
$abeConfiguration = factory(AbeConfiguration::class)->create();
|
||||
//Creates the AbeConfiguration factory
|
||||
factory(AbeRequest::class)->create([
|
||||
'ABE_UID' => $abeConfiguration->ABE_UID,
|
||||
'APP_UID' => $delegation->APP_UID,
|
||||
'DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'ABE_REQ_UID' => $abeConfiguration->ABE_UID
|
||||
]);
|
||||
|
||||
//Call the getAbeRequest method
|
||||
$res = AbeConfiguration::getAbeRequest('');
|
||||
|
||||
//Asserts the result has one record
|
||||
$this->assertEmpty($res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EmailServerModelTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Call the setUp parent method
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the tearDown parent method
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the getEmailServer method
|
||||
*
|
||||
* @covers \ProcessMaker\Model\EmailServerModel::getEmailServer()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_get_email_server_method()
|
||||
{
|
||||
//Create the EmailServerModel factory
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
|
||||
//Create the EmailServerModel object
|
||||
$email = new EmailServerModel();
|
||||
//Call the getEmailServer method
|
||||
$res = $email->getEmailServer($emailServer->MESS_UID);
|
||||
|
||||
//Assert the result es not empty
|
||||
$this->assertNotEmpty($res);
|
||||
//Assert the result is the one looked for
|
||||
$this->assertEquals($res['MESS_UID'], $emailServer->MESS_UID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the getEmailServer method with an empty result
|
||||
*
|
||||
* @covers \ProcessMaker\Model\EmailServerModel::getEmailServer()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_get_email_server_method_with_an_empty_result()
|
||||
{
|
||||
//Create the EmailServerModel factory
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
|
||||
//Create the EmailServerModel object
|
||||
$email = new EmailServerModel();
|
||||
//Call the getEmailServer method
|
||||
$res = $email->getEmailServer('');
|
||||
|
||||
//Assert the result is empty
|
||||
$this->assertEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the getEmailServerDefault method
|
||||
*
|
||||
* @covers \ProcessMaker\Model\EmailServerModel::getEmailServerDefault()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_get_email_server_default()
|
||||
{
|
||||
//Create the EmailServer factory
|
||||
$emailServer = factory(EmailServerModel::class)->create([
|
||||
'MESS_DEFAULT' => 1
|
||||
]);
|
||||
|
||||
//Create the EmailServerModel object
|
||||
$email = new EmailServerModel();
|
||||
//Call the getEmailServerDefault method
|
||||
$res = $email->getEmailServerDefault();
|
||||
|
||||
//Assert the result es not empty
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
}
|
||||
@@ -483,6 +483,19 @@ class ActionsByEmailCoreClass extends PMPlugin
|
||||
$this->setEmailFrom($emailFrom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the email from in a public way
|
||||
*
|
||||
* @param array $setup
|
||||
* @return void
|
||||
* @see ProcessMaker\BusinessModel\ActionsByEmail::forwardMail()
|
||||
*/
|
||||
public function publicDefineEmailFrom($setup)
|
||||
{
|
||||
//Call the defineEmailFrom private method
|
||||
$this->defineEmailFrom($setup);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the email to
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@ use AbeConfigurationPeer;
|
||||
use AbeRequests;
|
||||
use AbeRequestsPeer;
|
||||
use AbeResponsesPeer;
|
||||
use ActionsByEmailCoreClass;
|
||||
use AppDelegation;
|
||||
use AppDelegationPeer;
|
||||
use AppMessage;
|
||||
@@ -18,6 +19,8 @@ use G;
|
||||
use PmDynaform;
|
||||
use PMLicensedFeatures;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Model\AbeConfiguration as AbeConfigurationModel;
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use Publisher;
|
||||
use ResultSet;
|
||||
@@ -267,10 +270,10 @@ class ActionsByEmail
|
||||
|
||||
/**
|
||||
* Get the information for the log.
|
||||
*
|
||||
*
|
||||
* @param array $arrayData
|
||||
* @return array
|
||||
*
|
||||
*
|
||||
* @see ProcessMaker\Services\Api\ActionsByEmail->loadActionByEmail()
|
||||
* @see workflow/engine/methods/actionsByEmail/actionsByEmailAjax.php
|
||||
* @link https://wiki.processmaker.com/3.3/Actions_by_Email
|
||||
@@ -376,34 +379,27 @@ class ActionsByEmail
|
||||
if (!isset($arrayData['REQ_UID'])) {
|
||||
$arrayData['REQ_UID'] = '';
|
||||
}
|
||||
|
||||
$abeRequest = new AbeRequests();
|
||||
$dataRes = $abeRequest->getAbeRequest($arrayData['REQ_UID']);
|
||||
|
||||
$dataRes = AbeConfigurationModel::getAbeRequest($arrayData['REQ_UID']);
|
||||
if (!empty($dataRes)) {
|
||||
if (is_null($dataRes['DEL_FINISH_DATE'])) {
|
||||
|
||||
$emailServer = new EmailServer();
|
||||
$criteria = $emailServer->getEmailServerCriteria();
|
||||
$rsCriteria = EmailServerPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
if ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayConfigAux = $row;
|
||||
$arrayConfigAux["SMTPSecure"] = $row["SMTPSECURE"];
|
||||
}
|
||||
$aSetup = (!empty($arrayConfigAux))? $arrayConfigAux : System::getEmailConfiguration();
|
||||
|
||||
$emailServer = new EmailServerModel();
|
||||
$criteria = $emailServer->getEmailServer($dataRes['ABE_EMAIL_SERVER_UID']);
|
||||
$setup = !empty($criteria) ? $criteria : $emailServer->getEmailServerDefault();
|
||||
$spool = new SpoolRun();
|
||||
$spool->setConfig($aSetup);
|
||||
$spool->setConfig($setup);
|
||||
$abeCore = new ActionsByEmailCoreClass();
|
||||
$abeCore->setTaskAbeProperties([
|
||||
'ABE_MAILSERVER_OR_MAILCURRENT' => $dataRes['ABE_MAILSERVER_OR_MAILCURRENT'],
|
||||
'ABE_TYPE' => $dataRes['ABE_TYPE']
|
||||
]);
|
||||
$abeCore->publicDefineEmailFrom($setup);
|
||||
$messageArray = AppMessage::buildMessageRow(
|
||||
'',
|
||||
$dataRes['APP_UID'],
|
||||
$dataRes['DEL_INDEX'],
|
||||
WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL,
|
||||
$dataRes['ABE_REQ_SUBJECT'],
|
||||
$aSetup['MESS_ACCOUNT'],
|
||||
$abeCore->getEmailFrom(),
|
||||
$dataRes['ABE_REQ_SENT_TO'],
|
||||
$dataRes['ABE_REQ_BODY'],
|
||||
'',
|
||||
@@ -413,7 +409,7 @@ class ActionsByEmail
|
||||
'pending',
|
||||
1,
|
||||
'',
|
||||
false,
|
||||
true,
|
||||
isset($dataRes['APP_NUMBER']) ? $dataRes['APP_NUMBER'] : 0,
|
||||
$dataRes['PRO_ID'],
|
||||
$dataRes['TAS_ID']
|
||||
@@ -436,10 +432,10 @@ class ActionsByEmail
|
||||
throw $error;
|
||||
}
|
||||
} else {
|
||||
$message = G::LoadTranslation('ID_UNABLE_TO_SEND_EMAIL');
|
||||
$message = G::LoadTranslation('ID_UNABLE_TO_SEND_EMAIL');
|
||||
}
|
||||
} else {
|
||||
$message = G::LoadTranslation('ID_UNEXPECTED_ERROR_OCCURRED_PLEASE');
|
||||
$message = G::LoadTranslation('ID_UNEXPECTED_ERROR_OCCURRED_PLEASE');
|
||||
}
|
||||
|
||||
//Return
|
||||
@@ -451,7 +447,7 @@ class ActionsByEmail
|
||||
* @param array $arrayData
|
||||
*
|
||||
* @return string $message
|
||||
*
|
||||
*
|
||||
* @see workflow/engine/methods/actionsByEmail/actionsByEmailAjax.php
|
||||
* @see ProcessMaker\Services\Api\ActionsByEmail->viewForm()
|
||||
* @link https://wiki.processmaker.com/3.3/Actions_by_Email#Actions_by_Email_Log
|
||||
@@ -560,10 +556,10 @@ class ActionsByEmail
|
||||
|
||||
/**
|
||||
* Get the decision from Actions By Email by BPMN dynaform.
|
||||
*
|
||||
*
|
||||
* @param array $dataRes
|
||||
* @return string
|
||||
*
|
||||
*
|
||||
* @see ActionsByEmail->viewForm()
|
||||
* @link https://wiki.processmaker.com/3.3/Actions_by_Email
|
||||
*/
|
||||
@@ -640,7 +636,7 @@ class ActionsByEmail
|
||||
$message = $field->label . ': ';
|
||||
if (!empty($value)) {
|
||||
/**
|
||||
* Value 'On' is deprecated in version ProcessMaker 3.x.x.
|
||||
* Value 'On' is deprecated in version ProcessMaker 3.x.x.
|
||||
* now return '1'.
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
100
workflow/engine/src/ProcessMaker/Model/AbeConfiguration.php
Normal file
100
workflow/engine/src/ProcessMaker/Model/AbeConfiguration.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AbeConfiguration extends model
|
||||
{
|
||||
protected $table = "ABE_CONFIGURATION";
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Relation between process
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relation between task
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'TAS_UID', 'TAS_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relation between emailServer
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function emailServer()
|
||||
{
|
||||
return $this->belongsTo(EmailServer::class, 'MESS_UID', 'MESS_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the notification sent
|
||||
*
|
||||
* @param string $abeRequestUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAbeRequest($abeRequestUid)
|
||||
{
|
||||
$selectedColumns = [
|
||||
'ABE_CONFIGURATION.ABE_UID',
|
||||
'ABE_CONFIGURATION.PRO_UID',
|
||||
'ABE_CONFIGURATION.TAS_UID',
|
||||
'ABE_CONFIGURATION.ABE_EMAIL_SERVER_UID',
|
||||
'ABE_CONFIGURATION.ABE_TYPE',
|
||||
'ABE_CONFIGURATION.ABE_MAILSERVER_OR_MAILCURRENT',
|
||||
'TASK.TAS_ID',
|
||||
'PROCESS.PRO_ID',
|
||||
'ABE_REQUESTS.ABE_REQ_UID',
|
||||
'ABE_REQUESTS.APP_UID',
|
||||
'ABE_REQUESTS.DEL_INDEX',
|
||||
'ABE_REQUESTS.ABE_REQ_SENT_TO',
|
||||
'ABE_REQUESTS.ABE_REQ_SUBJECT',
|
||||
'ABE_REQUESTS.ABE_REQ_BODY',
|
||||
'ABE_REQUESTS.ABE_REQ_ANSWERED',
|
||||
'ABE_REQUESTS.ABE_REQ_STATUS',
|
||||
'APP_DELEGATION.DEL_FINISH_DATE',
|
||||
'APP_DELEGATION.APP_NUMBER'
|
||||
];
|
||||
$query = AbeConfiguration::query()->select($selectedColumns);
|
||||
|
||||
$query->leftJoin('TASK', function ($join) {
|
||||
$join->on('ABE_CONFIGURATION.TAS_UID', '=', 'TASK.TAS_UID');
|
||||
});
|
||||
$query->leftJoin('PROCESS', function ($join) {
|
||||
$join->on('ABE_CONFIGURATION.PRO_UID', '=', 'PROCESS.PRO_UID');
|
||||
});
|
||||
$query->leftJoin('ABE_REQUESTS', function ($join) {
|
||||
$join->on('ABE_CONFIGURATION.ABE_UID', '=', 'ABE_REQUESTS.ABE_UID');
|
||||
});
|
||||
$query->leftJoin('APP_DELEGATION', function ($join) {
|
||||
$join->on('ABE_REQUESTS.APP_UID', '=', 'APP_DELEGATION.APP_UID')
|
||||
->on('ABE_REQUESTS.DEL_INDEX', '=', 'APP_DELEGATION.DEL_INDEX');
|
||||
});
|
||||
$query->where('ABE_REQUESTS.ABE_REQ_UID', '=', $abeRequestUid);
|
||||
|
||||
$query->limit(1);
|
||||
|
||||
$res = $query->get()->values()->toArray();
|
||||
|
||||
if (!empty($res)) {
|
||||
return $res[0];
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
33
workflow/engine/src/ProcessMaker/Model/AbeRequest.php
Normal file
33
workflow/engine/src/ProcessMaker/Model/AbeRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AbeRequest extends Model
|
||||
{
|
||||
protected $table = "ABE_REQUESTS";
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Relation between application
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function application()
|
||||
{
|
||||
return $this->hasOne(Application::class, 'APP_UID', 'APP_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relation between abeConfiguration
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function abeConfiguration()
|
||||
{
|
||||
return $this->hasOne(AbeConfiguration::class, 'ABE_UID', 'ABE_UID');
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EmailServer extends Model
|
||||
{
|
||||
protected $table = 'EMAIL_SERVER';
|
||||
protected $primaryKey = 'MESS_UID';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
84
workflow/engine/src/ProcessMaker/Model/EmailServerModel.php
Normal file
84
workflow/engine/src/ProcessMaker/Model/EmailServerModel.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EmailServerModel extends Model
|
||||
{
|
||||
protected $table = 'EMAIL_SERVER';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Obtain the selected columns of the EMAIL_SERVER table
|
||||
*
|
||||
* @param string $messUid
|
||||
* @return array
|
||||
* @see ProcessMaker\BusinessModel\ActionsByEmail::forwardMail()
|
||||
*/
|
||||
public function getEmailServer($messUid)
|
||||
{
|
||||
$selectedColumns = [
|
||||
'EMAIL_SERVER.MESS_UID',
|
||||
'EMAIL_SERVER.MESS_ENGINE',
|
||||
'EMAIL_SERVER.MESS_SERVER',
|
||||
'EMAIL_SERVER.MESS_PORT',
|
||||
'EMAIL_SERVER.MESS_RAUTH',
|
||||
'EMAIL_SERVER.MESS_ACCOUNT',
|
||||
'EMAIL_SERVER.MESS_PASSWORD',
|
||||
'EMAIL_SERVER.MESS_FROM_MAIL',
|
||||
'EMAIL_SERVER.MESS_FROM_NAME',
|
||||
'EMAIL_SERVER.SMTPSECURE',
|
||||
'EMAIL_SERVER.MESS_TRY_SEND_INMEDIATLY',
|
||||
'EMAIL_SERVER.MAIL_TO',
|
||||
'EMAIL_SERVER.MESS_DEFAULT'
|
||||
];
|
||||
$query = EmailServerModel::query()->select($selectedColumns);
|
||||
$query->where('EMAIL_SERVER.MESS_UID', '=', $messUid);
|
||||
$res = $query->get()->values()->toArray();
|
||||
$firstElement = head($res);
|
||||
|
||||
return $firstElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the default EMAI_SERVER configuration
|
||||
*
|
||||
* @return array
|
||||
* @see ProcessMaker\BusinessModel\ActionsByEmail::forwardMail()
|
||||
*/
|
||||
public function getEmailServerDefault()
|
||||
{
|
||||
$selectedColumns = [
|
||||
'EMAIL_SERVER.MESS_UID',
|
||||
'EMAIL_SERVER.MESS_ENGINE',
|
||||
'EMAIL_SERVER.MESS_SERVER',
|
||||
'EMAIL_SERVER.MESS_PORT',
|
||||
'EMAIL_SERVER.MESS_INCOMING_SERVER',
|
||||
'EMAIL_SERVER.MESS_INCOMING_PORT',
|
||||
'EMAIL_SERVER.MESS_RAUTH',
|
||||
'EMAIL_SERVER.MESS_ACCOUNT',
|
||||
'EMAIL_SERVER.MESS_PASSWORD',
|
||||
'EMAIL_SERVER.MESS_FROM_MAIL',
|
||||
'EMAIL_SERVER.MESS_FROM_NAME',
|
||||
'EMAIL_SERVER.SMTPSECURE',
|
||||
'EMAIL_SERVER.MESS_TRY_SEND_INMEDIATLY',
|
||||
'EMAIL_SERVER.MAIL_TO',
|
||||
'EMAIL_SERVER.MESS_DEFAULT'
|
||||
];
|
||||
$query = EmailServerModel::query()->select($selectedColumns)
|
||||
->where('MESS_DEFAULT', '=', 1);
|
||||
$firstElement = $query->get()->values()->toArray();
|
||||
|
||||
if (!empty($firstElement)) {
|
||||
$firstElement = head($firstElement);
|
||||
// @todo these index are been keep due to compatibility reasons
|
||||
$firstElement['MESS_BACKGROUND'] = '';
|
||||
$firstElement['MESS_PASSWORD_HIDDEN'] = '';
|
||||
$firstElement['MESS_EXECUTE_EVERY'] = '';
|
||||
$firstElement['MESS_SEND_MAX'] = '';
|
||||
}
|
||||
|
||||
return $firstElement;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user