PMC-1346 Changes in the email server creation

This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-11-21 15:07:44 -04:00
parent ab30241886
commit 70b71985a3
12 changed files with 1097 additions and 263 deletions

View File

@@ -1,46 +1,7 @@
<?php <?php
/**
* class.rbac.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
use ProcessMaker\Exception\RBACException; use ProcessMaker\Exception\RBACException;
/**
* File: $Id$
*
* RBAC class definition
*
* @package gulliver.system
*/
/**
* Clase Wrapper
*
* @package gulliver.system
*/
class RBAC class RBAC
{ {
const ADMIN_USER_UID = '00000000000000000000000000000001'; const ADMIN_USER_UID = '00000000000000000000000000000001';
@@ -180,7 +141,11 @@ class RBAC
'UPD' => ['PM_SETUP'], 'UPD' => ['PM_SETUP'],
'DEL' => ['PM_SETUP'], 'DEL' => ['PM_SETUP'],
'LST' => ['PM_SETUP'], 'LST' => ['PM_SETUP'],
'TEST' => ['PM_SETUP'] 'TEST' => ['PM_SETUP'],
'createAuthUrl' => ['PM_SETUP']
],
'emailServerGmailOAuth.php' => [
'code' => ['PM_SETUP']
], ],
'processes_GetFile.php' => [ 'processes_GetFile.php' => [
'mailTemplates' => ['PM_FACTORY'], 'mailTemplates' => ['PM_FACTORY'],

View File

@@ -0,0 +1,265 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\GmailOAuth;
use Exception;
use Faker\Factory;
use Google_Client;
use Google_Service_Gmail_Message;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use PHPMailerOAuth;
use ProcessMaker\GmailOAuth\GmailOAuth;
use RBAC;
use Tests\TestCase;
class GmailOAuthTest extends TestCase
{
use DatabaseTransactions;
private $faker;
/**
* Init properties
*/
public function setUp()
{
parent::setUp();
$this->faker = Factory::create();
global $RBAC;
$RBAC = RBAC::getSingleton();
$RBAC->initRBAC();
}
/**
* This ensures that the properties of the GmailOAuth object have consistency.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setEmailServerUid()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setEmailEngine()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setClientID()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setClientSecret()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setRedirectURI()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setEmailEngine()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setFromAccount()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setSenderEmail()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setSenderName()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setSendTestMail()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setMailTo()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setSetDefaultConfiguration()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::setRefreshToken()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getEmailServerUid()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getClientID()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getClientSecret()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getRedirectURI()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getEmailEngine()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getFromAccount()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getSenderEmail()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getSenderName()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getSendTestMail()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getMailTo()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getSetDefaultConfiguration()
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getRefreshToken()
*/
public function it_should_set_and_get_properties()
{
$faker = $this->faker;
$expected = $faker->word;
$digit = $faker->randomDigitNotNull;
$gmailOAuth = new GmailOAuth();
$gmailOAuth->setEmailServerUid($expected);
$actual = $gmailOAuth->getEmailServerUid();
$this->assertEquals($expected, $actual);
$gmailOAuth->setClientID($expected);
$actual = $gmailOAuth->getClientID();
$this->assertEquals($expected, $actual);
$gmailOAuth->setClientSecret($expected);
$actual = $gmailOAuth->getClientSecret();
$this->assertEquals($expected, $actual);
$gmailOAuth->setRedirectURI($expected);
$actual = $gmailOAuth->getRedirectURI();
$this->assertEquals($expected, $actual);
$gmailOAuth->setEmailEngine($expected);
$actual = $gmailOAuth->getEmailEngine();
$this->assertEquals($expected, $actual);
$gmailOAuth->setFromAccount($expected);
$actual = $gmailOAuth->getFromAccount();
$this->assertEquals($expected, $actual);
$gmailOAuth->setSenderEmail($expected);
$actual = $gmailOAuth->getSenderEmail();
$this->assertEquals($expected, $actual);
$gmailOAuth->setSenderName($expected);
$actual = $gmailOAuth->getSenderName();
$this->assertEquals($expected, $actual);
$gmailOAuth->setSendTestMail($expected);
$actual = $gmailOAuth->getSendTestMail();
$this->assertEquals($expected, $actual);
$gmailOAuth->setMailTo($expected);
$actual = $gmailOAuth->getMailTo();
$this->assertEquals($expected, $actual);
$gmailOAuth->setSetDefaultConfiguration($expected);
$actual = $gmailOAuth->getSetDefaultConfiguration();
$this->assertEquals($expected, $actual);
$gmailOAuth->setRefreshToken($expected);
$actual = $gmailOAuth->getRefreshToken();
$this->assertEquals($expected, $actual);
}
/**
* Obtenga una instancia de Google_Client.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getGoogleClient()
*/
public function it_should_()
{
$gmailOAuth = new GmailOAuth();
$gmailOAuth->setClientID("");
$gmailOAuth->setClientSecret("");
$gmailOAuth->setRedirectURI("");
$googleClient = $gmailOAuth->getGoogleClient();
$this->assertTrue($googleClient instanceof Google_Client);
}
/**
* Create Email Server data.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::saveEmailServer()
*/
public function it_should_create_email_server()
{
$this->markTestIncomplete("It required valid workspace");
$faker = $this->faker;
$gmailOAuth = new GmailOAuth();
$gmailOAuth->setEmailEngine("GMAILAPI");
$gmailOAuth->setClientID($faker->uuid);
$gmailOAuth->setClientSecret($faker->uuid);
$gmailOAuth->setRefreshToken($faker->uuid);
$gmailOAuth->setFromAccount($faker->email);
$gmailOAuth->setSenderEmail(1);
$gmailOAuth->setSenderName($faker->word);
$gmailOAuth->setSendTestMail(1);
$gmailOAuth->setMailTo($faker->email);
$gmailOAuth->setSetDefaultConfiguration(0);
$this->expectException(Exception::class);
$result = $gmailOAuth->saveEmailServer();
}
/**
* Update Email Server data.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::saveEmailServer()
*/
public function it_should_udpate_email_server()
{
$this->markTestIncomplete("It required valid workspace");
$faker = $this->faker;
$gmailOAuth = new GmailOAuth();
$gmailOAuth->setEmailServerUid($faker->uuid);
$gmailOAuth->setEmailEngine("GMAILAPI");
$gmailOAuth->setClientID($faker->uuid);
$gmailOAuth->setClientSecret($faker->uuid);
$gmailOAuth->setRefreshToken($faker->uuid);
$gmailOAuth->setFromAccount($faker->email);
$gmailOAuth->setSenderEmail(1);
$gmailOAuth->setSenderName($faker->word);
$gmailOAuth->setSendTestMail(1);
$gmailOAuth->setMailTo($faker->email);
$gmailOAuth->setSetDefaultConfiguration(0);
$this->expectException(Exception::class);
$result = $gmailOAuth->saveEmailServer();
}
/**
* This ensures proof of email delivery with Google_Service_Gmail.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::sendTestEmailWithGoogleServiceGmail()
*/
public function it_should_send_an_email_test_with_google_service_gmail()
{
$faker = $this->faker;
$gmailOauth = new GmailOAuth();
$result = $gmailOauth->sendTestEmailWithGoogleServiceGmail();
$this->assertTrue($result instanceof Google_Service_Gmail_Message);
$gmailOauth->setFromAccount($faker->email);
$result = $gmailOauth->sendTestEmailWithGoogleServiceGmail();
$this->assertTrue($result instanceof Google_Service_Gmail_Message);
$gmailOauth->setSenderEmail($faker->email);
$result = $gmailOauth->sendTestEmailWithGoogleServiceGmail();
$this->assertTrue($result instanceof Google_Service_Gmail_Message);
$gmailOauth->setMailTo($faker->email);
$gmailOauth->setSendTestMail(0);
$result = $gmailOauth->sendTestEmailWithGoogleServiceGmail();
$this->assertTrue($result instanceof Google_Service_Gmail_Message);
}
/**
* This test ensures that the message body for the email test.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getRawMessage()
*/
public function it_should_get_raw_message_for_test_email()
{
$gmailOAuth = new GmailOAuth();
$result = $gmailOAuth->getRawMessage();
$this->assertTrue(is_string($result));
}
/**
* This ensures proof of email delivery with PHPMailerOAuth.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::sendTestMailWithPHPMailerOAuth()
*/
public function it_should_send_an_email_test_with_PHPMailerOAuth()
{
$faker = $this->faker;
$gmailOauth = new GmailOAuth();
$result = $gmailOauth->sendTestMailWithPHPMailerOAuth();
$this->assertTrue($result instanceof PHPMailerOAuth);
$gmailOauth->setFromAccount($faker->email);
$result = $gmailOauth->sendTestMailWithPHPMailerOAuth();
$this->assertTrue($result instanceof PHPMailerOAuth);
$gmailOauth->setSenderEmail($faker->email);
$result = $gmailOauth->sendTestMailWithPHPMailerOAuth();
$this->assertTrue($result instanceof PHPMailerOAuth);
$gmailOauth->setMailTo($faker->email);
$gmailOauth->setSendTestMail(0);
$result = $gmailOauth->sendTestMailWithPHPMailerOAuth();
$this->assertTrue($result instanceof PHPMailerOAuth);
}
/**
* This ensures proof of get message body.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::getMessageBody()
*/
public function it_should_get_message_body()
{
$gmailOauth = new GmailOAuth();
$result = $gmailOauth->getMessageBody();
$this->assertTrue(is_string($result));
}
}

View File

@@ -101,7 +101,7 @@ class EmailServerMapBuilder
$tMap->addColumn('OAUTH_REFRESH_TOKEN', 'OauthRefreshToken', 'string', CreoleTypes::VARCHAR, true, 256); $tMap->addColumn('OAUTH_REFRESH_TOKEN', 'OauthRefreshToken', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addValidator('MESS_ENGINE', 'validValues', 'propel.validator.ValidValuesValidator', 'MAIL|PHPMAILER|XOAUTH2', 'Please enter a valid value for MESS_ENGINE'); $tMap->addValidator('MESS_ENGINE', 'validValues', 'propel.validator.ValidValuesValidator', 'MAIL|PHPMAILER|XOAUTH2|GMAILAPI', 'Please enter a valid value for MESS_ENGINE');
} // doBuild() } // doBuild()

View File

@@ -5008,7 +5008,7 @@
<column name="OAUTH_CLIENT_SECRET" type="VARCHAR" size="256" required="true" default=""/> <column name="OAUTH_CLIENT_SECRET" type="VARCHAR" size="256" required="true" default=""/>
<column name="OAUTH_REFRESH_TOKEN" type="VARCHAR" size="256" required="true" default=""/> <column name="OAUTH_REFRESH_TOKEN" type="VARCHAR" size="256" required="true" default=""/>
<validator column="MESS_ENGINE"> <validator column="MESS_ENGINE">
<rule name="validValues" value="MAIL|PHPMAILER|XOAUTH2" message="Please enter a valid value for MESS_ENGINE"/> <rule name="validValues" value="MAIL|PHPMAILER|XOAUTH2|GMAILAPI" message="Please enter a valid value for MESS_ENGINE"/>
</validator> </validator>
</table> </table>

View File

@@ -4307,6 +4307,18 @@ msgstr "Click the lock to make changes."
msgid "Click the lock to prevent further changes." msgid "Click the lock to prevent further changes."
msgstr "Click the lock to prevent further changes." msgstr "Click the lock to prevent further changes."
# TRANSLATION
# LABEL/ID_CLIENT_ID
#: LABEL/ID_CLIENT_ID
msgid "Client ID"
msgstr "Client ID"
# TRANSLATION
# LABEL/ID_CLIENT_SECRET
#: LABEL/ID_CLIENT_SECRET
msgid "Client Secret"
msgstr "Client Secret"
# TRANSLATION # TRANSLATION
# LABEL/ID_CLOSE # LABEL/ID_CLOSE
#: LABEL/ID_CLOSE #: LABEL/ID_CLOSE
@@ -7034,8 +7046,8 @@ msgstr "The email was resend to"
# TRANSLATION # TRANSLATION
# LABEL/ID_EMAIL_SERVER_ACCOUNT_FROM # LABEL/ID_EMAIL_SERVER_ACCOUNT_FROM
#: LABEL/ID_EMAIL_SERVER_ACCOUNT_FROM #: LABEL/ID_EMAIL_SERVER_ACCOUNT_FROM
msgid "Sender Account" msgid "From Account"
msgstr "Sender Account" msgstr "From Account"
# TRANSLATION # TRANSLATION
# LABEL/ID_EMAIL_SERVER_CONFIRM_DELETE # LABEL/ID_EMAIL_SERVER_CONFIRM_DELETE
@@ -18671,6 +18683,12 @@ msgstr "SMTP (PHPMailer)"
msgid "SMTP (OpenMail)" msgid "SMTP (OpenMail)"
msgstr "SMTP (OpenMail)" msgstr "SMTP (OpenMail)"
# TRANSLATION
# LABEL/ID_MESS_ENGINE_TYPE_4
#: LABEL/ID_MESS_ENGINE_TYPE_4
msgid "OAUTH (GMail OAuth)"
msgstr "OAUTH (GMail OAuth)"
# TRANSLATION # TRANSLATION
# LABEL/ID_MESS_SEND_MAX_REQUIRED # LABEL/ID_MESS_SEND_MAX_REQUIRED
#: LABEL/ID_MESS_SEND_MAX_REQUIRED #: LABEL/ID_MESS_SEND_MAX_REQUIRED

View File

@@ -57525,6 +57525,8 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_CLEAR_LOG','en','Clear Log','2014-01-15') , ( 'LABEL','ID_CLEAR_LOG','en','Clear Log','2014-01-15') ,
( 'LABEL','ID_CLICK_LOCK','en','Click the lock to make changes.','2014-01-15') , ( 'LABEL','ID_CLICK_LOCK','en','Click the lock to make changes.','2014-01-15') ,
( 'LABEL','ID_CLICK_UNLOCK','en','Click the lock to prevent further changes.','2014-01-15') , ( 'LABEL','ID_CLICK_UNLOCK','en','Click the lock to prevent further changes.','2014-01-15') ,
( 'LABEL','ID_CLIENT_ID','en','Client ID','2019-11-14') ,
( 'LABEL','ID_CLIENT_SECRET','en','Client Secret','2019-11-14') ,
( 'LABEL','ID_CLOSE','en','Close','2014-01-15') , ( 'LABEL','ID_CLOSE','en','Close','2014-01-15') ,
( 'LABEL','ID_CLOSE_EDITOR','en','Close Editor','2014-01-15') , ( 'LABEL','ID_CLOSE_EDITOR','en','Close Editor','2014-01-15') ,
( 'LABEL','ID_CODE','en','Code','2014-01-15') , ( 'LABEL','ID_CODE','en','Code','2014-01-15') ,
@@ -57991,7 +57993,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_EMAIL_MORE_USER','en','This email is assigned to more than one user. Please contact your administrator.','2015-10-02') , ( 'LABEL','ID_EMAIL_MORE_USER','en','This email is assigned to more than one user. Please contact your administrator.','2015-10-02') ,
( 'LABEL','ID_EMAIL_NOT_CORRESPONDS_TOKEN','en','The email does not corresponds to the token gmail user.','2015-10-02') , ( 'LABEL','ID_EMAIL_NOT_CORRESPONDS_TOKEN','en','The email does not corresponds to the token gmail user.','2015-10-02') ,
( 'LABEL','ID_EMAIL_RESENT_TO','en','The email was resend to','2016-04-08') , ( 'LABEL','ID_EMAIL_RESENT_TO','en','The email was resend to','2016-04-08') ,
( 'LABEL','ID_EMAIL_SERVER_ACCOUNT_FROM','en','Sender Account','2017-02-21') , ( 'LABEL','ID_EMAIL_SERVER_ACCOUNT_FROM','en','From Account','2017-02-21') ,
( 'LABEL','ID_EMAIL_SERVER_CONFIRM_DELETE','en','Do you want to delete the Email Server?','2014-12-24') , ( '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_DEFAULT','en','Default','2014-12-24') ,
( 'LABEL','ID_EMAIL_SERVER_DELETE_DATA','en','Delete data...','2014-12-24') , ( 'LABEL','ID_EMAIL_SERVER_DELETE_DATA','en','Delete data...','2014-12-24') ,
@@ -59974,6 +59976,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_MESS_ENGINE_TYPE_1','en','Mail (PHP)','2014-01-15') , ( 'LABEL','ID_MESS_ENGINE_TYPE_1','en','Mail (PHP)','2014-01-15') ,
( 'LABEL','ID_MESS_ENGINE_TYPE_2','en','SMTP (PHPMailer)','2014-01-15') , ( 'LABEL','ID_MESS_ENGINE_TYPE_2','en','SMTP (PHPMailer)','2014-01-15') ,
( 'LABEL','ID_MESS_ENGINE_TYPE_3','en','SMTP (OpenMail)','2014-01-15') , ( 'LABEL','ID_MESS_ENGINE_TYPE_3','en','SMTP (OpenMail)','2014-01-15') ,
( 'LABEL','ID_MESS_ENGINE_TYPE_4','en','OAUTH (GMail OAuth)','2019-11-15') ,
( 'LABEL','ID_MESS_SEND_MAX_REQUIRED','en','The maximum number of attempts to send mail is a required field.','2014-01-15') , ( 'LABEL','ID_MESS_SEND_MAX_REQUIRED','en','The maximum number of attempts to send mail is a required field.','2014-01-15') ,
( 'LABEL','ID_MESS_TEST_BODY','en','ProcessMaker Test Email','2014-01-15') , ( 'LABEL','ID_MESS_TEST_BODY','en','ProcessMaker Test Email','2014-01-15') ,
( 'LABEL','ID_MESS_TEST_MESSAGE_ERROR_PHP_MAIL','en','Test message send failed, error:','2014-01-15') , ( 'LABEL','ID_MESS_TEST_MESSAGE_ERROR_PHP_MAIL','en','Test message send failed, error:','2014-01-15') ,

View File

@@ -1,4 +1,5 @@
<?php <?php
global $RBAC; global $RBAC;
$resultRbac = $RBAC->requirePermissions('PM_SETUP_EMAIL'); $resultRbac = $RBAC->requirePermissions('PM_SETUP_EMAIL');

View File

@@ -1,11 +1,15 @@
<?php <?php
use ProcessMaker\Core\System;
use ProcessMaker\GmailOAuth\GmailOAuth;
$option = (isset($_POST["option"])) ? $_POST["option"] : ""; $option = (isset($_POST["option"])) ? $_POST["option"] : "";
$response = array(); $response = [];
$RBAC->allows(basename(__FILE__), $option); $RBAC->allows(basename(__FILE__), $option);
switch ($option) { switch ($option) {
case "INS": case "INS":
$arrayData = array(); $arrayData = [];
$server = ""; $server = "";
$port = ""; $port = "";
@@ -69,7 +73,7 @@ switch ($option) {
} }
break; break;
case "UPD": case "UPD":
$arrayData = array(); $arrayData = [];
$emailServerUid = $_POST["emailServerUid"]; $emailServerUid = $_POST["emailServerUid"];
@@ -173,7 +177,7 @@ switch ($option) {
} }
break; break;
case "TEST": case "TEST":
$arrayData = array(); $arrayData = [];
$server = ""; $server = "";
$port = ""; $port = "";
@@ -225,7 +229,35 @@ switch ($option) {
$response["message"] = $e->getMessage(); $response["message"] = $e->getMessage();
} }
break; break;
case "createAuthUrl":
try {
$gmailOAuth = new GmailOAuth();
$gmailOAuth->setClientID($_POST['clientID']);
$gmailOAuth->setClientSecret($_POST['clientSecret']);
$gmailOAuth->setRedirectURI(System::getServerMainPath() . "/emailServer/emailServerGmailOAuth");
$gmailOAuth->setEmailEngine($_POST['emailEngine']);
$gmailOAuth->setFromAccount($_POST['fromAccount']);
$gmailOAuth->setSenderEmail($_POST['senderEmail']);
$gmailOAuth->setSenderName($_POST['senderName']);
$gmailOAuth->setSendTestMail((int) $_POST['sendTestMail']);
$gmailOAuth->setMailTo($_POST['mailTo']);
$gmailOAuth->setSetDefaultConfiguration((int) $_POST['setDefaultConfiguration']);
if (!empty($_POST['emailServerUid'])) {
$gmailOAuth->setEmailServerUid($_POST['emailServerUid']);
}
$client = $gmailOAuth->getGoogleClient();
$response = [
"status" => 200,
"data" => $client->createAuthUrl()
];
$_SESSION['gmailOAuth'] = $gmailOAuth;
} catch (Exception $e) {
$response = [
"status" => 500,
"message" => $e->getMessage()
];
}
break;
} }
echo G::json_encode($response); echo G::json_encode($response);

View File

@@ -0,0 +1,26 @@
<?php
use ProcessMaker\Core\System;
use ProcessMaker\GmailOAuth\GmailOAuth;
$header = "location:" . System::getServerMainPath() . "/setup/main?s=EMAIL_SERVER";
$validInput = empty($_GET['code']) || empty($_SESSION['gmailOAuth']) || !is_object($_SESSION['gmailOAuth']);
if ($validInput) {
G::header($header);
}
$RBAC->allows(basename(__FILE__), "code");
$gmailOAuth = $_SESSION['gmailOAuth'];
$googleClient = $gmailOAuth->getGoogleClient();
$result = $googleClient->authenticate($_GET['code']);
if (isset($result["error"])) {
G::header($header);
}
$gmailOAuth->setRefreshToken($googleClient->getRefreshToken());
$gmailOAuth->saveEmailServer();
$gmailOAuth->sendTestMailWithPHPMailerOAuth();
G::header($header);

View File

@@ -14,7 +14,7 @@ class EmailServer
{ {
private $arrayFieldDefinition = array( private $arrayFieldDefinition = array(
"MESS_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "emailServerUid"), "MESS_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "emailServerUid"),
"MESS_ENGINE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("PHPMAILER", "MAIL", "IMAP"), "fieldNameAux" => "emailServerEngine"), "MESS_ENGINE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("PHPMAILER", "MAIL", "IMAP", "GMAILAPI"), "fieldNameAux" => "emailServerEngine"),
"MESS_SERVER" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerServer"), "MESS_SERVER" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerServer"),
"MESS_PORT" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerPort"), "MESS_PORT" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerPort"),
"MESS_INCOMING_SERVER" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerIncomingServer"), "MESS_INCOMING_SERVER" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerIncomingServer"),
@@ -1127,7 +1127,7 @@ class EmailServer
public function getEmailServerDataFromRecord(array $record) public function getEmailServerDataFromRecord(array $record)
{ {
try { try {
return array( return [
$this->getFieldNameByFormatFieldName("MESS_UID") => $record["MESS_UID"], $this->getFieldNameByFormatFieldName("MESS_UID") => $record["MESS_UID"],
$this->getFieldNameByFormatFieldName("MESS_ENGINE") => $record["MESS_ENGINE"], $this->getFieldNameByFormatFieldName("MESS_ENGINE") => $record["MESS_ENGINE"],
$this->getFieldNameByFormatFieldName("MESS_SERVER") => $record["MESS_SERVER"], $this->getFieldNameByFormatFieldName("MESS_SERVER") => $record["MESS_SERVER"],
@@ -1150,7 +1150,7 @@ class EmailServer
$this->getFieldNameByFormatFieldName("OAUTH_CLIENT_ID") => $record["OAUTH_CLIENT_ID"], $this->getFieldNameByFormatFieldName("OAUTH_CLIENT_ID") => $record["OAUTH_CLIENT_ID"],
$this->getFieldNameByFormatFieldName("OAUTH_CLIENT_SECRET") => $record["OAUTH_CLIENT_SECRET"], $this->getFieldNameByFormatFieldName("OAUTH_CLIENT_SECRET") => $record["OAUTH_CLIENT_SECRET"],
$this->getFieldNameByFormatFieldName("OAUTH_REFRESH_TOKEN") => $record["OAUTH_REFRESH_TOKEN"] $this->getFieldNameByFormatFieldName("OAUTH_REFRESH_TOKEN") => $record["OAUTH_REFRESH_TOKEN"]
); ];
} catch (Exception $e) { } catch (Exception $e) {
throw $e; throw $e;
} }

View File

@@ -0,0 +1,419 @@
<?php
namespace ProcessMaker\GmailOAuth;
use G;
use Google_Client;
use Google_Service_Gmail;
use Google_Service_Gmail_Message;
use PHPMailerOAuth;
use ProcessMaker\BusinessModel\EmailServer;
use ProcessMaker\Core\System;
use TemplatePower;
class GmailOAuth
{
private $emailServerUid;
private $emailEngine;
private $clientID;
private $clientSecret;
private $fromAccount;
private $senderEmail;
private $senderName;
private $sendTestMail;
private $mailTo;
private $setDefaultConfiguration;
private $redirectURI;
private $refreshToken;
/**
* Set $emailServerUid property.
* @param string $emailServerUid
* @return void
*/
public function setEmailServerUid($emailServerUid): void
{
$this->emailServerUid = $emailServerUid;
}
/**
* Set $clientID property.
* @param string $clientID
* @return void
*/
public function setClientID($clientID): void
{
$this->clientID = $clientID;
}
/**
* Set $clientSecret property.
* @param string $clientSecret
* @return void
*/
public function setClientSecret($clientSecret): void
{
$this->clientSecret = $clientSecret;
}
/**
* Set $redirectURI property.
* @param string $redirectURI
* @return void
*/
public function setRedirectURI($redirectURI): void
{
$this->redirectURI = $redirectURI;
}
/**
* Set $emailEngine property.
* @param string $emailEngine
* @return void
*/
public function setEmailEngine($emailEngine): void
{
$this->emailEngine = $emailEngine;
}
/**
* Set $fromAccount property.
* @param string $fromAccount
* @return void
*/
public function setFromAccount($fromAccount): void
{
$this->fromAccount = $fromAccount;
}
/**
* Set $senderEmail property.
* @param string $senderEmail
* @return void
*/
public function setSenderEmail($senderEmail): void
{
$this->senderEmail = $senderEmail;
}
/**
* Set $senderName property.
* @param string $senderName
* @return void
*/
public function setSenderName($senderName): void
{
$this->senderName = $senderName;
}
/**
* Set $sendTestMail property.
* @param string $sendTestMail
* @return void
*/
public function setSendTestMail($sendTestMail): void
{
$this->sendTestMail = $sendTestMail;
}
/**
* Set $mailTo property.
* @param string $mailTo
* @return void
*/
public function setMailTo($mailTo): void
{
$this->mailTo = $mailTo;
}
/**
* Set $setDefaultConfiguration property.
* @param string $setDefaultConfiguration
* @return void
*/
public function setSetDefaultConfiguration($setDefaultConfiguration): void
{
$this->setDefaultConfiguration = $setDefaultConfiguration;
}
/**
* Set $refreshToken property.
* @param string $refreshToken
* @return void
*/
public function setRefreshToken($refreshToken): void
{
$this->refreshToken = $refreshToken;
}
/**
* Get $emailServerUid property.
* @return string
*/
public function getEmailServerUid()
{
return $this->emailServerUid;
}
/**
* Get $clientID property.
* @return string
*/
public function getClientID()
{
return $this->clientID;
}
/**
* Get $clientSecret property.
* @return string
*/
public function getClientSecret()
{
return $this->clientSecret;
}
/**
* Get $redirectURI property.
* @return string
*/
public function getRedirectURI()
{
return $this->redirectURI;
}
/**
* Get $emailEngine property.
* @return string
*/
public function getEmailEngine()
{
return $this->emailEngine;
}
/**
* Get $fromAccount property.
* @return string
*/
public function getFromAccount()
{
return $this->fromAccount;
}
/**
* Get $senderEmail property.
* @return string
*/
public function getSenderEmail()
{
return $this->senderEmail;
}
/**
* Get $senderName property.
* @return string
*/
public function getSenderName()
{
return $this->senderName;
}
/**
* Get $sendTestMail property.
* @return string
*/
public function getSendTestMail()
{
return $this->sendTestMail;
}
/**
* Get $mailTo property.
* @return string
*/
public function getMailTo()
{
return $this->mailTo;
}
/**
* Get $defaultConfiguration property.
* @return string
*/
public function getSetDefaultConfiguration()
{
return $this->setDefaultConfiguration;
}
/**
* Get $refreshToken property.
* @return string
*/
public function getRefreshToken()
{
return $this->refreshToken;
}
/**
* Get a Google_Client object, this may vary depending on the service provider.
* @return Google_Client
*/
public function getGoogleClient(): Google_Client
{
$googleClient = new Google_Client();
$googleClient->setClientId($this->clientID);
$googleClient->setClientSecret($this->clientSecret);
$googleClient->setRedirectUri($this->redirectURI);
$googleClient->setAccessType('offline');
$googleClient->setApprovalPrompt('force');
$googleClient->addScope(Google_Service_Gmail::MAIL_GOOGLE_COM);
return $googleClient;
}
/**
* Save the data in the EmailServer table, and return the stored fields.
* @return array
*/
public function saveEmailServer(): array
{
$result = [];
$data = [
"MESS_ENGINE" => $this->emailEngine,
"OAUTH_CLIENT_ID" => $this->clientID,
"OAUTH_CLIENT_SECRET" => $this->clientSecret,
"OAUTH_REFRESH_TOKEN" => $this->refreshToken,
"MESS_ACCOUNT" => $this->fromAccount,
"MESS_FROM_MAIL" => $this->senderEmail,
"MESS_FROM_NAME" => $this->senderName,
"MESS_TRY_SEND_INMEDIATLY" => $this->sendTestMail,
"MAIL_TO" => $this->mailTo,
"MESS_DEFAULT" => $this->setDefaultConfiguration,
"MESS_RAUTH" => 1,
"SMTPSECURE" => "No",
"MESS_PASSWORD" => "",
"MESS_SERVER" => "smtp.gmail.com",
"MESS_PORT" => "",
"MESS_PASSWORD" => "",
"MESS_INCOMING_SERVER" => "",
"MESS_INCOMING_PORT" => ""
];
$emailServer = new EmailServer();
if (empty($this->emailServerUid)) {
$result = $emailServer->create($data);
} else {
$result = $emailServer->update($this->emailServerUid, $data);
}
return $result;
}
/**
* This sends a test email with Google_Service_Gmail_Message object, as long
* as the test flag is activated.
* @return Google_Service_Gmail_Message
*/
public function sendTestEmailWithGoogleServiceGmail(): Google_Service_Gmail_Message
{
$googleServiceGmailMessage = new Google_Service_Gmail_Message();
if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) {
return $googleServiceGmailMessage;
}
if (!filter_var($this->senderEmail, FILTER_VALIDATE_EMAIL)) {
return $googleServiceGmailMessage;
}
if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) {
return $googleServiceGmailMessage;
}
if ($this->sendTestMail === 0) {
return $googleServiceGmailMessage;
}
$googleClient = $this->getGoogleClient();
$googleClient->refreshToken($this->getRefreshToken());
if ($googleClient->isAccessTokenExpired()) {
$newAccessToken = $googleClient->getAccessToken();
$googleClient->setAccessToken($newAccessToken);
}
$raw = $this->getRawMessage();
$googleServiceGmailMessage->setRaw($raw);
$service = new Google_Service_Gmail($googleClient);
$result = $service->users_messages->send("me", $googleServiceGmailMessage);
return $result;
}
/**
* Get message body.
* @return string
*/
public function getMessageBody(): string
{
$templateTower = new TemplatePower(PATH_TPL . "admin" . PATH_SEP . "email.tpl");
$templateTower->prepare();
$templateTower->assign("server", System::getServerHostname());
$templateTower->assign("date", date("H:i:s"));
$templateTower->assign("ver", System::getVersion());
$templateTower->assign("engine", G::LoadTranslation("ID_MESS_ENGINE_TYPE_4"));
$templateTower->assign("msg", G::LoadTranslation("ID_MESS_TEST_BODY"));
$outputContent = $templateTower->getOutputContent();
return $outputContent;
}
/**
* Get a plain text of the test message.
* @return string
*/
public function getRawMessage(): string
{
$outputContent = $this->getMessageBody();
$strRawMessage = ""
. "From: Email <{$this->fromAccount}> \r\n"
. "To: <{$this->mailTo}>\r\n"
. "Subject: =?utf-8?B?" . base64_encode(G::LoadTranslation("ID_MESS_TEST_SUBJECT")) . "?=\r\n"
. "MIME-Version: 1.0\r\n"
. "Content-Type: text/html; charset=utf-8\r\n"
. "Content-Transfer-Encoding: quoted-printable\r\n\r\n"
. "{$outputContent}\r\n";
$raw = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
return $raw;
}
/**
* This sends a test email with PHPMailerOAuth object, as long
* as the test flag is activated.
* @return PHPMailerOAuth
*/
public function sendTestMailWithPHPMailerOAuth(): PHPMailerOAuth
{
$phpMailerOAuth = new PHPMailerOAuth();
if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth;
}
if (!filter_var($this->senderEmail, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth;
}
if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth;
}
if ($this->sendTestMail === 0) {
return $phpMailerOAuth;
}
$phpMailerOAuth->isHTML(true);
$phpMailerOAuth->isSMTP();
$phpMailerOAuth->Host = 'smtp.gmail.com';
$phpMailerOAuth->SMTPAuth = true;
$phpMailerOAuth->AuthType = 'XOAUTH2';
$phpMailerOAuth->oauthUserEmail = $this->fromAccount;
$phpMailerOAuth->oauthClientId = $this->clientID;
$phpMailerOAuth->oauthClientSecret = $this->clientSecret;
$phpMailerOAuth->oauthRefreshToken = $this->refreshToken;
$phpMailerOAuth->SetFrom($this->senderEmail, $this->senderName);
$phpMailerOAuth->Subject = G::LoadTranslation("ID_MESS_TEST_SUBJECT");
$phpMailerOAuth->Body = utf8_encode($this->getMessageBody());
$phpMailerOAuth->AddAddress($this->mailTo);
$phpMailerOAuth->Send();
return $phpMailerOAuth;
}
}

View File

@@ -25,8 +25,6 @@ emailServer.application = {
case "DEL": case "DEL":
msg = _("ID_EMAIL_SERVER_DELETE_DATA"); msg = _("ID_EMAIL_SERVER_DELETE_DATA");
break; break;
//case "LST":
// break;
case "TEST": case "TEST":
msg = _("ID_EMAIL_SERVER_TEST_DATA"); msg = _("ID_EMAIL_SERVER_TEST_DATA");
break; break;
@@ -156,9 +154,6 @@ emailServer.application = {
} }
} }
break; break;
//case "LST":
// break;
case "TEST": case "TEST":
showTestConnection(typeEmailEngine, dataResponse.data); showTestConnection(typeEmailEngine, dataResponse.data);
@@ -213,6 +208,8 @@ emailServer.application = {
emailServerSetMailTo(Ext.getCmp("chkSendTestMail").checked); emailServerSetMailTo(Ext.getCmp("chkSendTestMail").checked);
Ext.getCmp("txtMailTo").setValue(""); Ext.getCmp("txtMailTo").setValue("");
Ext.getCmp("textClientId").setValue("");
Ext.getCmp("textClientSecret").setValue("");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
Ext.getCmp("chkEmailServerDefault").setValue(false); Ext.getCmp("chkEmailServerDefault").setValue(false);
@@ -255,6 +252,8 @@ emailServer.application = {
emailServerSetMailTo(Ext.getCmp("chkSendTestMail").checked); emailServerSetMailTo(Ext.getCmp("chkSendTestMail").checked);
Ext.getCmp("txtMailTo").setValue(record.get("MAIL_TO")); Ext.getCmp("txtMailTo").setValue(record.get("MAIL_TO"));
Ext.getCmp("textClientId").setValue(record.get("OAUTH_CLIENT_ID"));
Ext.getCmp("textClientSecret").setValue(record.get("OAUTH_CLIENT_SECRET"));
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
if (parseInt(record.get("MESS_DEFAULT")) == 1) { if (parseInt(record.get("MESS_DEFAULT")) == 1) {
@@ -278,6 +277,12 @@ emailServer.application = {
{ {
Ext.getCmp("frmEmailServer").getForm().clearInvalid(); Ext.getCmp("frmEmailServer").getForm().clearInvalid();
Ext.getCmp("textClientId").setVisible(false);
Ext.getCmp("textClientSecret").setVisible(false);
Ext.getCmp("buttonContinue").setVisible(false);
Ext.getCmp("btnTest").setVisible(true);
Ext.getCmp("btnSave").setVisible(true);
if (cboEmailEngine === "PHPMAILER") { if (cboEmailEngine === "PHPMAILER") {
Ext.getCmp("txtServer").setVisible(true); Ext.getCmp("txtServer").setVisible(true);
Ext.getCmp("txtPort").setVisible(true); Ext.getCmp("txtPort").setVisible(true);
@@ -334,6 +339,29 @@ emailServer.application = {
Ext.getCmp("txtIncomingPort").allowBlank = false; Ext.getCmp("txtIncomingPort").allowBlank = false;
Ext.getCmp("txtAccountFrom").allowBlank = false; Ext.getCmp("txtAccountFrom").allowBlank = false;
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
} else if (cboEmailEngine === "GMAILAPI") {
Ext.getCmp("txtServer").setVisible(false);
Ext.getCmp("txtPort").setVisible(false);
Ext.getCmp("txtIncomingServer").setVisible(false);
Ext.getCmp("txtIncomingPort").setVisible(false);
Ext.getCmp("chkReqAuthentication").setVisible(false);
Ext.getCmp("rdoGrpSmtpSecure").setVisible(false);
Ext.getCmp("btnTest").setVisible(false);
Ext.getCmp("btnSave").setVisible(false);
Ext.getCmp("txtAccountFrom").setVisible(true);
Ext.getCmp("textClientId").setVisible(true);
Ext.getCmp("textClientSecret").setVisible(true);
Ext.getCmp("buttonContinue").setVisible(true);
emailServerSetPassword(false);
Ext.getCmp("txtServer").allowBlank = true;
Ext.getCmp("txtPort").allowBlank = true;
Ext.getCmp("txtIncomingServer").allowBlank = true;
Ext.getCmp("txtIncomingPort").allowBlank = true;
Ext.getCmp("txtAccountFrom").allowBlank = false;
Ext.getCmp("txtPassword").allowBlank = true;
} else { } else {
//MAIL //MAIL
Ext.getCmp("txtServer").setVisible(false); Ext.getCmp("txtServer").setVisible(false);
@@ -360,7 +388,7 @@ emailServer.application = {
function emailServerSetPassword(flagPassChecked) function emailServerSetPassword(flagPassChecked)
{ {
if (flagPassChecked) { if (flagPassChecked && Ext.getCmp("cboEmailEngine").getValue() !== 'GMAILAPI') {
Ext.getCmp("txtPassword").setVisible(true); Ext.getCmp("txtPassword").setVisible(true);
Ext.getCmp("txtPassword").allowBlank = false; Ext.getCmp("txtPassword").allowBlank = false;
} else { } else {
@@ -504,7 +532,9 @@ emailServer.application = {
{name: "SMTPSECURE", type: "string"}, {name: "SMTPSECURE", type: "string"},
{name: "MESS_TRY_SEND_INMEDIATLY", type: "int"}, {name: "MESS_TRY_SEND_INMEDIATLY", type: "int"},
{name: "MAIL_TO", type: "string"}, {name: "MAIL_TO", type: "string"},
{name: "MESS_DEFAULT", type: "int"} {name: "MESS_DEFAULT", type: "int"},
{name: "OAUTH_CLIENT_ID", type: "string"},
{name: "OAUTH_CLIENT_SECRET", type: "string"}
] ]
}), }),
@@ -555,7 +585,8 @@ emailServer.application = {
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
["IMAP", "SMTP - IMAP (PHPMailer)"], ["IMAP", "SMTP - IMAP (PHPMailer)"],
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
["MAIL", "Mail (PHP)"] ["MAIL", "Mail (PHP)"],
["GMAILAPI", "GMAIL API (PHPMailer)"]
] ]
}); });
@@ -756,38 +787,100 @@ emailServer.application = {
var btnCancel = new Ext.Action({ var btnCancel = new Ext.Action({
id: "btnCancel", id: "btnCancel",
text: _("ID_CANCEL"), text: _("ID_CANCEL"),
width: 85, width: 85,
disabled: false, disabled: false,
handler: function () {
handler: function () Ext.getCmp("frmEmailServer").setVisible(true);
{
winData.hide(); winData.hide();
} }
}); });
//Components var textClientId = new Ext.form.TextField({
var winData = new Ext.Window({ id: "textClientId",
layout: "fit", name: "textClientId",
width: 550, fieldLabel: _("ID_CLIENT_ID")
height: 450, });
//title: "", var textClientSecret = new Ext.form.TextField({
modal: true, id: "textClientSecret",
resizable: false, name: "textClientSecret",
closeAction: "hide", fieldLabel: _("ID_CLIENT_SECRET")
});
var buttonContinue = new Ext.Action({
id: 'buttonContinue',
text: _("ID_CONTINUE"),
width: 85,
handler: function () {
var frmEmailServer, parameters;
frmEmailServer = Ext.getCmp("frmEmailServer");
if (frmEmailServer.getForm().isValid()) {
winData.setDisabled(true);
items: [ parameters = {
new Ext.FormPanel({ option: 'createAuthUrl',
emailEngine: Ext.getCmp("cboEmailEngine").getValue(),
clientID: Ext.getCmp("textClientId").getValue(),
clientSecret: Ext.getCmp("textClientSecret").getValue(),
fromAccount: Ext.getCmp("txtAccountFrom").getValue(),
senderEmail: Ext.getCmp("txtFromMail").getValue(),
senderName: Ext.getCmp("txtFromName").getValue(),
sendTestMail: (Ext.getCmp("chkSendTestMail").checked) ? 1 : 0,
mailTo: Ext.getCmp("txtMailTo").getValue(),
setDefaultConfiguration: Ext.getCmp("chkEmailServerDefault").checked ? 1 : 0
};
if (EMAILSERVEROPTION === "UPD") {
parameters.emailServerUid = Ext.getCmp("emailServerUid").getValue();
}
Ext.Ajax.request({
url: "emailServerAjax",
method: "POST",
params: parameters,
success: function (response) {
winData.setDisabled(false);
var dataResponse = Ext.util.JSON.decode(response.responseText);
if (dataResponse.status === 200) {
if (window.parent.parent) {
window.parent.parent.location = dataResponse.data;
} else if (window.parent) {
window.parent.location = dataResponse.data;
} else {
window.location = dataResponse.data;
}
} else {
Ext.MessageBox.show({
title: _("ID_ERROR"),
icon: Ext.MessageBox.ERROR,
msg: dataResponse.message,
buttons: {ok: _("ID_ACCEPT")}
});
}
},
failure: function () {
winData.setDisabled(false);
Ext.MessageBox.show({
title: _("ID_ERROR"),
icon: Ext.MessageBox.ERROR,
msg: "",
buttons: {ok: _("ID_ACCEPT")}
});
}
});
} else {
Ext.MessageBox.alert(_("ID_INVALID_DATA"), _("ID_CHECK_FIELDS_MARK_RED"));
}
}
});
var frmEmailServer = new Ext.FormPanel({
id: "frmEmailServer", id: "frmEmailServer",
frame: true, frame: true,
labelAlign: "right", labelAlign: "right",
labelWidth: 150, labelWidth: 150,
autoWidth: true, autoWidth: true,
autoScroll: false, autoScroll: false,
defaults: {width: 325}, defaults: {width: 325},
items: [ items: [
{ {
xtype: "hidden", xtype: "hidden",
@@ -800,6 +893,8 @@ emailServer.application = {
txtIncomingServer, txtIncomingServer,
txtIncomingPort, txtIncomingPort,
chkReqAuthentication, chkReqAuthentication,
textClientId,
textClientSecret,
txtAccountFrom, txtAccountFrom,
txtPassword, txtPassword,
txtFromMail, txtFromMail,
@@ -811,12 +906,22 @@ emailServer.application = {
, chkEmailServerDefault , chkEmailServerDefault
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
] ]
})
],
buttons: [btnTest, btnSave, btnCancel]
}); });
//Components
var winData = new Ext.Window({
layout: "fit",
width: 550,
height: 450,
modal: true,
resizable: false,
closeAction: "hide",
items: [frmEmailServer],
buttons: [buttonContinue, btnTest, btnSave, btnCancel]
});
winData.show();
winData.hide();
var winTestConnection = new Ext.Window({ var winTestConnection = new Ext.Window({
layout: "fit", layout: "fit",
width: 480, width: 480,
@@ -931,11 +1036,11 @@ emailServer.application = {
Ext.MessageBox.confirm( Ext.MessageBox.confirm(
_("ID_CONFIRM"), _("ID_CONFIRM"),
_("ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE"), _("ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE"),
function (btn) function (btn) {
{
if (btn == "yes") { if (btn == "yes") {
EMAILSERVEROPTION = "DEL"; EMAILSERVEROPTION = "DEL";
Ext.getCmp("cboEmailEngine").setValue(record.get("MESS_ENGINE"));
Ext.getCmp("rdoGrpSmtpSecure").setValue((record.get("SMTPSECURE") != "") ? record.get("SMTPSECURE") : "No");
emailServerProcessAjax(EMAILSERVEROPTION, record.get("MESS_UID")); emailServerProcessAjax(EMAILSERVEROPTION, record.get("MESS_UID"));
} }
} }