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
/**
* 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;
/**
* File: $Id$
*
* RBAC class definition
*
* @package gulliver.system
*/
/**
* Clase Wrapper
*
* @package gulliver.system
*/
class RBAC
{
const ADMIN_USER_UID = '00000000000000000000000000000001';
@@ -180,7 +141,11 @@ class RBAC
'UPD' => ['PM_SETUP'],
'DEL' => ['PM_SETUP'],
'LST' => ['PM_SETUP'],
'TEST' => ['PM_SETUP']
'TEST' => ['PM_SETUP'],
'createAuthUrl' => ['PM_SETUP']
],
'emailServerGmailOAuth.php' => [
'code' => ['PM_SETUP']
],
'processes_GetFile.php' => [
'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->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()

View File

@@ -5008,7 +5008,7 @@
<column name="OAUTH_CLIENT_SECRET" type="VARCHAR" size="256" required="true" default=""/>
<column name="OAUTH_REFRESH_TOKEN" type="VARCHAR" size="256" required="true" default=""/>
<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>
</table>

View File

@@ -4307,6 +4307,18 @@ msgstr "Click the lock to make changes."
msgid "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
# LABEL/ID_CLOSE
#: LABEL/ID_CLOSE
@@ -7034,8 +7046,8 @@ msgstr "The email was resend to"
# TRANSLATION
# LABEL/ID_EMAIL_SERVER_ACCOUNT_FROM
#: LABEL/ID_EMAIL_SERVER_ACCOUNT_FROM
msgid "Sender Account"
msgstr "Sender Account"
msgid "From Account"
msgstr "From Account"
# TRANSLATION
# LABEL/ID_EMAIL_SERVER_CONFIRM_DELETE
@@ -18671,6 +18683,12 @@ msgstr "SMTP (PHPMailer)"
msgid "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
# 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_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_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_EDITOR','en','Close Editor','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_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_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_DEFAULT','en','Default','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_2','en','SMTP (PHPMailer)','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_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') ,

View File

@@ -1,7 +1,8 @@
<?php
global $RBAC;
$resultRbac = $RBAC->requirePermissions('PM_SETUP_EMAIL');
$resultRbac = $RBAC->requirePermissions('PM_SETUP_EMAIL');
if (!$resultRbac) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
@@ -13,7 +14,7 @@ $configuration = new Configurations();
$arrayConfigPage = $configuration->getConfiguration("emailServerList", "pageSize", null, $_SESSION["USER_LOGGED"]);
$arrayConfig = array();
$arrayConfig["pageSize"] = (isset($arrayConfigPage["pageSize"]))? $arrayConfigPage["pageSize"] : 20;
$arrayConfig["pageSize"] = (isset($arrayConfigPage["pageSize"])) ? $arrayConfigPage["pageSize"] : 20;
$headPublisher = headPublisher::getSingleton();
$headPublisher->addContent("emailServer/emailServer"); //Adding a HTML file
@@ -21,7 +22,7 @@ $headPublisher->addExtJsScript("emailServer/emailServer", false); //Adding a Jav
$headPublisher->assign("CONFIG", $arrayConfig);
/*----------------------------------********---------------------------------*/
$headPublisher->assign("EMAILSERVER_LICENSED", (PMLicensedFeatures::getSingleton()->verifyfeature("zIKRGpDM3pjcHFsWGplNDN0dTl5bGN3UTNiOWdQU0E5Q05QTksrU1ladWQ0VT0="))? 1 : 0);
$headPublisher->assign("EMAILSERVER_LICENSED", (PMLicensedFeatures::getSingleton()->verifyfeature("zIKRGpDM3pjcHFsWGplNDN0dTl5bGN3UTNiOWdQU0E5Q05QTksrU1ladWQ0VT0=")) ? 1 : 0);
/*----------------------------------********---------------------------------*/
G::RenderPage("publish", "extJs");

View File

@@ -1,11 +1,15 @@
<?php
$option = (isset($_POST["option"]))? $_POST["option"] : "";
$response = array();
use ProcessMaker\Core\System;
use ProcessMaker\GmailOAuth\GmailOAuth;
$option = (isset($_POST["option"])) ? $_POST["option"] : "";
$response = [];
$RBAC->allows(basename(__FILE__), $option);
switch ($option) {
case "INS":
$arrayData = array();
$arrayData = [];
$server = "";
$port = "";
@@ -16,45 +20,45 @@ switch ($option) {
$smtpSecure = "";
$cboEmailEngine = $_POST["cboEmailEngine"];
$accountFrom = (isset($_POST["accountFrom"]))? $_POST["accountFrom"] : "";
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
$fromName = $_POST["fromName"];
$fromMail = $_POST["fromMail"];
$sendTestMail = (int)($_POST["sendTestMail"]);
$mailTo = ($sendTestMail == 1)? $_POST["mailTo"] : "";
$emailServerDefault = (int)($_POST["emailServerDefault"]);
$sendTestMail = (int) ($_POST["sendTestMail"]);
$mailTo = ($sendTestMail == 1) ? $_POST["mailTo"] : "";
$emailServerDefault = (int) ($_POST["emailServerDefault"]);
if ($cboEmailEngine == "PHPMAILER") {
$server = $_POST["server"];
$port = (int)($_POST["port"]);
$reqAuthentication = (int)($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
$port = (int) ($_POST["port"]);
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
$smtpSecure = $_POST["smtpSecure"];
} elseif ($cboEmailEngine == "IMAP") {
$server = $_POST["server"];
$port = (int)($_POST["port"]);
$port = (int) ($_POST["port"]);
$incomingServer = $_POST["incomingServer"];
$incomingPort = (int)($_POST["incomingPort"]);
$reqAuthentication = (int)($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
$incomingPort = (int) ($_POST["incomingPort"]);
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
$smtpSecure = $_POST["smtpSecure"];
}
try {
$arrayData = array(
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
"MESS_INCOMING_SERVER" => $incomingServer,
"MESS_INCOMING_PORT" => $incomingPort,
"MESS_RAUTH" => $reqAuthentication,
"MESS_ACCOUNT" => $accountFrom,
"MESS_PASSWORD" => $password,
"MESS_FROM_MAIL" => $fromMail,
"MESS_FROM_NAME" => $fromName,
"SMTPSECURE" => $smtpSecure,
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
"MESS_INCOMING_SERVER" => $incomingServer,
"MESS_INCOMING_PORT" => $incomingPort,
"MESS_RAUTH" => $reqAuthentication,
"MESS_ACCOUNT" => $accountFrom,
"MESS_PASSWORD" => $password,
"MESS_FROM_MAIL" => $fromMail,
"MESS_FROM_NAME" => $fromName,
"SMTPSECURE" => $smtpSecure,
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
);
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
@@ -62,14 +66,14 @@ switch ($option) {
$arrayEmailServerData = $emailSever->create($arrayData);
$response["status"] = "OK";
$response["data"] = $arrayEmailServerData;
$response["data"] = $arrayEmailServerData;
} catch (Exception $e) {
$response["status"] = "ERROR";
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
break;
case "UPD":
$arrayData = array();
$arrayData = [];
$emailServerUid = $_POST["emailServerUid"];
@@ -82,45 +86,45 @@ switch ($option) {
$smtpSecure = "";
$cboEmailEngine = $_POST["cboEmailEngine"];
$accountFrom = (isset($_POST["accountFrom"]))? $_POST["accountFrom"] : "";
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
$fromName = $_POST["fromName"];
$fromMail = $_POST["fromMail"];
$sendTestMail = (int)($_POST["sendTestMail"]);
$mailTo = ($sendTestMail == 1)? $_POST["mailTo"] : "";
$emailServerDefault = (int)($_POST["emailServerDefault"]);
$sendTestMail = (int) ($_POST["sendTestMail"]);
$mailTo = ($sendTestMail == 1) ? $_POST["mailTo"] : "";
$emailServerDefault = (int) ($_POST["emailServerDefault"]);
if ($cboEmailEngine == "PHPMAILER") {
$server = $_POST["server"];
$port = (int)($_POST["port"]);
$reqAuthentication = (int)($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
$port = (int) ($_POST["port"]);
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
$smtpSecure = $_POST["smtpSecure"];
} elseif ($cboEmailEngine == "IMAP") {
$server = $_POST["server"];
$port = (int)($_POST["port"]);
$port = (int) ($_POST["port"]);
$incomingServer = $_POST["incomingServer"];
$incomingPort = (int)($_POST["incomingPort"]);
$reqAuthentication = (int)($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
$incomingPort = (int) ($_POST["incomingPort"]);
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
$smtpSecure = $_POST["smtpSecure"];
}
try {
$arrayData = array(
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
"MESS_INCOMING_SERVER" => $incomingServer,
"MESS_INCOMING_PORT" => $incomingPort,
"MESS_RAUTH" => $reqAuthentication,
"MESS_ACCOUNT" => $accountFrom,
"MESS_PASSWORD" => $password,
"MESS_FROM_MAIL" => $fromMail,
"MESS_FROM_NAME" => $fromName,
"SMTPSECURE" => $smtpSecure,
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
"MESS_INCOMING_SERVER" => $incomingServer,
"MESS_INCOMING_PORT" => $incomingPort,
"MESS_RAUTH" => $reqAuthentication,
"MESS_ACCOUNT" => $accountFrom,
"MESS_PASSWORD" => $password,
"MESS_FROM_MAIL" => $fromMail,
"MESS_FROM_NAME" => $fromName,
"SMTPSECURE" => $smtpSecure,
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
);
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
@@ -128,9 +132,9 @@ switch ($option) {
$arrayEmailServerData = $emailSever->update($emailServerUid, $arrayData);
$response["status"] = "OK";
$response["data"] = $arrayEmailServerData;
$response["data"] = $arrayEmailServerData;
} catch (Exception $e) {
$response["status"] = "ERROR";
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
@@ -145,7 +149,7 @@ switch ($option) {
$response["status"] = "OK";
} catch (Exception $e) {
$response["status"] = "ERROR";
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
break;
@@ -153,27 +157,27 @@ switch ($option) {
$pageSize = $_POST["pageSize"];
$search = $_POST["search"];
$sortField = (isset($_POST["sort"]))? $_POST["sort"]: "";
$sortDir = (isset($_POST["dir"]))? $_POST["dir"]: "";
$start = (isset($_POST["start"]))? $_POST["start"]: 0;
$limit = (isset($_POST["limit"]))? $_POST["limit"]: $pageSize;
$sortField = (isset($_POST["sort"])) ? $_POST["sort"] : "";
$sortDir = (isset($_POST["dir"])) ? $_POST["dir"] : "";
$start = (isset($_POST["start"])) ? $_POST["start"] : 0;
$limit = (isset($_POST["limit"])) ? $_POST["limit"] : $pageSize;
try {
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
$result = $emailSever->getEmailServers(array("filter" => $search), $sortField, $sortDir, $start, $limit);
$response["status"] = "OK";
$response["status"] = "OK";
$response["success"] = true;
$response["resultTotal"] = $result["total"];
$response["resultRoot"] = $result["data"];
$response["resultRoot"] = $result["data"];
} catch (Exception $e) {
$response["status"] = "ERROR";
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
break;
case "TEST":
$arrayData = array();
$arrayData = [];
$server = "";
$port = "";
@@ -184,48 +188,76 @@ switch ($option) {
$smtpSecure = "";
$cboEmailEngine = $_POST["cboEmailEngine"];
$accountFrom = (isset($_POST["accountFrom"]))? $_POST["accountFrom"] : "";
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
$fromName = $_POST["fromName"];
$fromMail = $_POST["fromMail"];
$sendTestMail = (int)($_POST["sendTestMail"]);
$mailTo = ($sendTestMail == 1)? $_POST["mailTo"] : "";
$emailServerDefault = (int)($_POST["emailServerDefault"]);
$sendTestMail = (int) ($_POST["sendTestMail"]);
$mailTo = ($sendTestMail == 1) ? $_POST["mailTo"] : "";
$emailServerDefault = (int) ($_POST["emailServerDefault"]);
if ($cboEmailEngine == "PHPMAILER" || $cboEmailEngine == "IMAP") {
$server = $_POST["server"];
$port = (int)($_POST["port"]);
$reqAuthentication = (int)($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
$port = (int) ($_POST["port"]);
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
$smtpSecure = $_POST["smtpSecure"];
}
try {
$arrayData = array(
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
"MESS_RAUTH" => $reqAuthentication,
"MESS_ACCOUNT" => $accountFrom,
"MESS_PASSWORD" => $password,
"MESS_FROM_MAIL" => $fromMail,
"MESS_FROM_NAME" => $fromName,
"SMTPSECURE" => $smtpSecure,
"MESS_ENGINE" => $cboEmailEngine,
"MESS_SERVER" => $server,
"MESS_PORT" => $port,
"MESS_RAUTH" => $reqAuthentication,
"MESS_ACCOUNT" => $accountFrom,
"MESS_PASSWORD" => $password,
"MESS_FROM_MAIL" => $fromMail,
"MESS_FROM_NAME" => $fromName,
"SMTPSECURE" => $smtpSecure,
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
"MAIL_TO" => $mailTo,
"MESS_DEFAULT" => $emailServerDefault
);
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
$arrayEmailServerData = $emailSever->testConnection($arrayData);
$response["data"] = $arrayEmailServerData;
$response["data"] = $arrayEmailServerData;
} catch (Exception $e) {
$response["status"] = "ERROR";
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
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);

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(
"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_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"),
@@ -1127,7 +1127,7 @@ class EmailServer
public function getEmailServerDataFromRecord(array $record)
{
try {
return array(
return [
$this->getFieldNameByFormatFieldName("MESS_UID") => $record["MESS_UID"],
$this->getFieldNameByFormatFieldName("MESS_ENGINE") => $record["MESS_ENGINE"],
$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_SECRET") => $record["OAUTH_CLIENT_SECRET"],
$this->getFieldNameByFormatFieldName("OAUTH_REFRESH_TOKEN") => $record["OAUTH_REFRESH_TOKEN"]
);
];
} catch (Exception $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":
msg = _("ID_EMAIL_SERVER_DELETE_DATA");
break;
//case "LST":
// break;
case "TEST":
msg = _("ID_EMAIL_SERVER_TEST_DATA");
break;
@@ -40,9 +38,9 @@ emailServer.application = {
/*----------------------------------********---------------------------------*/
if (Ext.getCmp("chkEmailServerDefault").checked) {
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/
var emailDefault = 1;
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/
} else {
var emailDefault = 0;
}
@@ -102,7 +100,7 @@ emailServer.application = {
cboEmailEngine: typeEmailEngine,
fromMail: Ext.getCmp("txtFromMail").getValue(),
fromName: Ext.getCmp("txtFromName").getValue(),
sendTestMail: (Ext.getCmp("chkSendTestMail").checked)? 1 : 0,
sendTestMail: (Ext.getCmp("chkSendTestMail").checked) ? 1 : 0,
mailTo: Ext.getCmp("txtMailTo").getValue(),
emailServerDefault: emailDefault
};
@@ -156,9 +154,6 @@ emailServer.application = {
}
}
break;
//case "LST":
// break;
case "TEST":
showTestConnection(typeEmailEngine, dataResponse.data);
@@ -213,6 +208,8 @@ emailServer.application = {
emailServerSetMailTo(Ext.getCmp("chkSendTestMail").checked);
Ext.getCmp("txtMailTo").setValue("");
Ext.getCmp("textClientId").setValue("");
Ext.getCmp("textClientSecret").setValue("");
/*----------------------------------********---------------------------------*/
Ext.getCmp("chkEmailServerDefault").setValue(false);
@@ -229,19 +226,19 @@ emailServer.application = {
case "UPD":
var record = grdpnlMain.getSelectionModel().getSelected();
if (typeof(record) != "undefined") {
if (typeof (record) != "undefined") {
Ext.getCmp("emailServerUid").setValue(record.get("MESS_UID"));
Ext.getCmp("cboEmailEngine").setValue(record.get("MESS_ENGINE"));
emailServerSetEmailEngine(record.get("MESS_ENGINE"));
Ext.getCmp("txtServer").setValue(record.get("MESS_SERVER"));
Ext.getCmp("txtPort").setValue((record.get("MESS_PORT") != 0)? record.get("MESS_PORT") : "");
Ext.getCmp("txtPort").setValue((record.get("MESS_PORT") != 0) ? record.get("MESS_PORT") : "");
Ext.getCmp("txtIncomingServer").setValue(record.get("MESS_INCOMING_SERVER"));
Ext.getCmp("txtIncomingPort").setValue((record.get("MESS_INCOMING_PORT") !== 0)? record.get("MESS_INCOMING_PORT") : "");
Ext.getCmp("txtIncomingPort").setValue((record.get("MESS_INCOMING_PORT") !== 0) ? record.get("MESS_INCOMING_PORT") : "");
Ext.getCmp("chkReqAuthentication").setValue((parseInt(record.get("MESS_RAUTH")) == 1)? true : false);
Ext.getCmp("chkReqAuthentication").setValue((parseInt(record.get("MESS_RAUTH")) == 1) ? true : false);
emailServerSetPassword(Ext.getCmp("chkReqAuthentication").checked);
@@ -250,17 +247,19 @@ emailServer.application = {
Ext.getCmp("txtFromMail").setValue(record.get("MESS_FROM_MAIL"));
Ext.getCmp("txtFromName").setValue(record.get("MESS_FROM_NAME"));
Ext.getCmp("rdoGrpSmtpSecure").setValue((record.get("SMTPSECURE") != "")? record.get("SMTPSECURE") : "No");
Ext.getCmp("chkSendTestMail").setValue((parseInt(record.get("MESS_TRY_SEND_INMEDIATLY")) == 1)? true : false);
Ext.getCmp("rdoGrpSmtpSecure").setValue((record.get("SMTPSECURE") != "") ? record.get("SMTPSECURE") : "No");
Ext.getCmp("chkSendTestMail").setValue((parseInt(record.get("MESS_TRY_SEND_INMEDIATLY")) == 1) ? true : false);
emailServerSetMailTo(Ext.getCmp("chkSendTestMail").checked);
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) {
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/
Ext.getCmp("chkEmailServerDefault").setValue(true);
/*----------------------------------********---------------------------------*/
/*----------------------------------********---------------------------------*/
} else {
Ext.getCmp("chkEmailServerDefault").setValue(false);
}
@@ -278,6 +277,12 @@ emailServer.application = {
{
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") {
Ext.getCmp("txtServer").setVisible(true);
Ext.getCmp("txtPort").setVisible(true);
@@ -334,6 +339,29 @@ emailServer.application = {
Ext.getCmp("txtIncomingPort").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 {
//MAIL
Ext.getCmp("txtServer").setVisible(false);
@@ -360,7 +388,7 @@ emailServer.application = {
function emailServerSetPassword(flagPassChecked)
{
if (flagPassChecked) {
if (flagPassChecked && Ext.getCmp("cboEmailEngine").getValue() !== 'GMAILAPI') {
Ext.getCmp("txtPassword").setVisible(true);
Ext.getCmp("txtPassword").allowBlank = false;
} else {
@@ -387,67 +415,67 @@ emailServer.application = {
FLAGTEST = 1;
if (option === "PHPMAILER" || option === "IMAP") {
if (typeof(testData.resolving_name) != "undefined") {
if (typeof (testData.resolving_name) != "undefined") {
if (testData.resolving_name.result) {
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.resolving_name.title + "<br />";
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.resolving_name.title + "<br />";
} else {
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.resolving_name.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.resolving_name.message + "</span><br />";
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.resolving_name.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.resolving_name.message + "</span><br />";
FLAGTEST = 0;
}
}
if (typeof(testData.check_port) != "undefined") {
if (typeof (testData.check_port) != "undefined") {
if (testData.check_port.result) {
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.check_port.title + "<br />";
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.check_port.title + "<br />";
} else {
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.check_port.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.check_port.message + "</span><br />";
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.check_port.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.check_port.message + "</span><br />";
FLAGTEST = 0;
}
}
if (typeof(testData.establishing_connection_host) != "undefined") {
if (typeof (testData.establishing_connection_host) != "undefined") {
if (testData.establishing_connection_host.result) {
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.establishing_connection_host.title + "<br />";
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.establishing_connection_host.title + "<br />";
} else {
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.establishing_connection_host.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.establishing_connection_host.message + "</span><br />";
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.establishing_connection_host.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.establishing_connection_host.message + "</span><br />";
FLAGTEST = 0;
}
}
if (typeof(testData.login) != "undefined") {
if (typeof (testData.login) != "undefined") {
if (testData.login.result != "") {
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.login.title + "<br />";
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.login.title + "<br />";
} else {
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.login.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.login.message + "</span><br />";
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.login.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.login.message + "</span><br />";
FLAGTEST = 0;
}
}
if (typeof(testData.sending_email) != "undefined") {
if (typeof (testData.sending_email) != "undefined") {
if (testData.sending_email.result) {
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.sending_email.title + "<br />";
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.sending_email.title + "<br />";
} else {
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.sending_email.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.sending_email.message + "</span><br />";
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.sending_email.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.sending_email.message + "</span><br />";
FLAGTEST = 0;
}
}
} else {
//MAIL
if (typeof(testData.verifying_mail) != "undefined") {
if (typeof (testData.verifying_mail) != "undefined") {
if (testData.verifying_mail.result) {
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em;\" />" + testData.verifying_mail.title + "<br />";
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em;\" />" + testData.verifying_mail.title + "<br />";
} else {
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.verifying_mail.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.verifying_mail.message + "</span><br />";
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.verifying_mail.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.verifying_mail.message + "</span><br />";
FLAGTEST = 0;
}
}
if (typeof(testData.sending_email) != "undefined") {
if (typeof (testData.sending_email) != "undefined") {
if (testData.sending_email.result) {
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.sending_email.title + "<br />";
msg = msg + "<img src = \"/images/select-icon.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em; color: #0000FF;\" />" + testData.sending_email.title + "<br />";
} else {
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.sending_email.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.sending_email.message + "</span><br />";
msg = msg + "<img src = \"/images/error.png\" width=\"21\" height=\"21\" style=\"margin-right: 0.6em;\" />" + testData.sending_email.title + "<br /><span style=\"margin-left:2.3em; color: #0000FF;\">" + testData.sending_email.message + "</span><br />";
FLAGTEST = 0;
}
}
@@ -504,7 +532,9 @@ emailServer.application = {
{name: "SMTPSECURE", type: "string"},
{name: "MESS_TRY_SEND_INMEDIATLY", type: "int"},
{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"}
]
}),
@@ -540,7 +570,7 @@ emailServer.application = {
var emailUrlValidationText = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))|((([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))$/i;
Ext.apply(Ext.form.VTypes, {
emailUrlValidation: function(val, field)
emailUrlValidation: function (val, field)
{
return emailUrlValidationText.test(val);
}
@@ -555,7 +585,8 @@ emailServer.application = {
/*----------------------------------********---------------------------------*/
["IMAP", "SMTP - IMAP (PHPMailer)"],
/*----------------------------------********---------------------------------*/
["MAIL", "Mail (PHP)"]
["MAIL", "Mail (PHP)"],
["GMAILAPI", "GMAIL API (PHPMailer)"]
]
});
@@ -579,7 +610,7 @@ emailServer.application = {
forceSelection: true,
listeners: {
select: function(combo, value)
select: function (combo, value)
{
emailServerSetEmailEngine(Ext.getCmp("cboEmailEngine").getValue());
}
@@ -597,7 +628,7 @@ emailServer.application = {
id: "txtPort",
name: "txtPort",
fieldLabel: _("PORT_DEFAULT"), //Port (default 25)
fieldLabel: _("PORT_DEFAULT"), //Port (default 25)
anchor: "36%",
maxLength: 3,
@@ -615,7 +646,7 @@ emailServer.application = {
id: "txtIncomingPort",
name: "txtIncomingPort",
fieldLabel: _("INCOMING_PORT_DEFAULT"), //Port (default 993)
fieldLabel: _("INCOMING_PORT_DEFAULT"), //Port (default 993)
anchor: "36%",
maxLength: 3,
@@ -628,7 +659,7 @@ emailServer.application = {
boxLabel: _("REQUIRE_AUTHENTICATION"), //Require authentication
handler: function()
handler: function ()
{
emailServerSetPassword(this.checked);
}
@@ -680,7 +711,7 @@ emailServer.application = {
vertical: true,
items: [
{boxLabel: "No", inputValue: "No", name: "rdoGrpSmtpSecure", checked: true},
{boxLabel: "No", inputValue: "No", name: "rdoGrpSmtpSecure", checked: true},
{boxLabel: "TLS", inputValue: "tls", name: "rdoGrpSmtpSecure"},
{boxLabel: "SSL", inputValue: "ssl", name: "rdoGrpSmtpSecure"}
]
@@ -692,7 +723,7 @@ emailServer.application = {
boxLabel: _("SEND_TEST_MAIL"), //Send a test mail
handler: function()
handler: function ()
{
emailServerSetMailTo(this.checked);
}
@@ -756,66 +787,140 @@ emailServer.application = {
var btnCancel = new Ext.Action({
id: "btnCancel",
text: _("ID_CANCEL"),
width: 85,
disabled: false,
handler: function ()
{
handler: function () {
Ext.getCmp("frmEmailServer").setVisible(true);
winData.hide();
}
});
var textClientId = new Ext.form.TextField({
id: "textClientId",
name: "textClientId",
fieldLabel: _("ID_CLIENT_ID")
});
var textClientSecret = new Ext.form.TextField({
id: "textClientSecret",
name: "textClientSecret",
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);
parameters = {
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",
frame: true,
labelAlign: "right",
labelWidth: 150,
autoWidth: true,
autoScroll: false,
defaults: {width: 325},
items: [
{
xtype: "hidden",
id: "emailServerUid",
name: "emailServerUid"
},
cboEmailEngine,
txtServer,
txtPort,
txtIncomingServer,
txtIncomingPort,
chkReqAuthentication,
textClientId,
textClientSecret,
txtAccountFrom,
txtPassword,
txtFromMail,
txtFromName,
rdoGrpSmtpSecure,
chkSendTestMail,
txtMailTo
/*----------------------------------********---------------------------------*/
, chkEmailServerDefault
/*----------------------------------********---------------------------------*/
]
});
//Components
var winData = new Ext.Window({
layout: "fit",
width: 550,
height: 450,
//title: "",
modal: true,
resizable: false,
closeAction: "hide",
items: [
new Ext.FormPanel({
id: "frmEmailServer",
frame: true,
labelAlign: "right",
labelWidth: 150,
autoWidth: true,
autoScroll: false,
defaults: {width: 325},
items: [
{
xtype: "hidden",
id: "emailServerUid",
name: "emailServerUid"
},
cboEmailEngine,
txtServer,
txtPort,
txtIncomingServer,
txtIncomingPort,
chkReqAuthentication,
txtAccountFrom,
txtPassword,
txtFromMail,
txtFromName,
rdoGrpSmtpSecure,
chkSendTestMail,
txtMailTo
/*----------------------------------********---------------------------------*/
, chkEmailServerDefault
/*----------------------------------********---------------------------------*/
]
})
],
buttons: [btnTest, btnSave, btnCancel]
items: [frmEmailServer],
buttons: [buttonContinue, btnTest, btnSave, btnCancel]
});
winData.show();
winData.hide();
var winTestConnection = new Ext.Window({
layout: "fit",
@@ -906,7 +1011,7 @@ emailServer.application = {
{
var record = grdpnlMain.getSelectionModel().getSelected();
if (typeof(record) != "undefined") {
if (typeof (record) != "undefined") {
Ext.getCmp("btnSave").disable();
EMAILSERVEROPTION = "UPD";
@@ -927,18 +1032,18 @@ emailServer.application = {
{
var record = grdpnlMain.getSelectionModel().getSelected();
if (typeof(record) != "undefined") {
if (typeof (record) != "undefined") {
Ext.MessageBox.confirm(
_("ID_CONFIRM"),
_("ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE"),
function (btn)
{
if (btn == "yes") {
EMAILSERVEROPTION = "DEL";
emailServerProcessAjax(EMAILSERVEROPTION, record.get("MESS_UID"));
_("ID_CONFIRM"),
_("ID_EMAIL_SERVER_DELETE_WARNING_MESSAGE"),
function (btn) {
if (btn == "yes") {
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"));
}
}
}
);
}
}
@@ -1016,32 +1121,32 @@ emailServer.application = {
var rendererMessServer = function (value)
{
return (value != "")? value : "-";
return (value != "") ? value : "-";
};
var rendererMessPort = function (value)
{
return (value != 0)? value : "-";
return (value != 0) ? value : "-";
};
var rendererMessIncomingServer = function (value)
{
return (value !== "")? value : "-";
return (value !== "") ? value : "-";
};
var rendererMessIncomingPort = function (value)
{
return (value !== 0)? value : "-";
return (value !== 0) ? value : "-";
};
var rendererMessSmtpSecure = function (value)
{
return (value != "")? value : "-";
return (value != "") ? value : "-";
};
var rendererMessDefault = function (value)
{
return (value == 1)? "<img src = \"/images/ext/default/saved.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em;\" />" : "";
return (value == 1) ? "<img src = \"/images/ext/default/saved.png\" width=\"17\" height=\"17\" style=\"margin-right: 0.9em;\" />" : "";
};
var cmodel = new Ext.grid.ColumnModel({
@@ -1050,20 +1155,20 @@ emailServer.application = {
},
columns: [
{id: "MESS_UID", dataIndex: "MESS_UID", hidden: true, header: "uid_emailServer", width: 0, hideable: false, align: "left"},
{id: "MESS_UID", dataIndex: "MESS_UID", hidden: true, header: "uid_emailServer", width: 0, hideable: false, align: "left"},
{id: "MESS_ENGINE", dataIndex: "MESS_ENGINE", hidden: false, header: _("EMAIL_ENGINE"), width: 80, hideable: true, align: "left"},
{id: "MESS_SERVER", dataIndex: "MESS_SERVER", hidden: false, header: _("ID_SERVER"), width: 150, hideable: true, align: "center", renderer: rendererMessServer},
{id: "MESS_PORT", dataIndex: "MESS_PORT", hidden: false, header: _("ID_EMAIL_SERVER_PORT"), width: 50, hideable: true, align: "center", renderer: rendererMessPort},
{id: "MESS_PORT", dataIndex: "MESS_PORT", hidden: false, header: _("ID_EMAIL_SERVER_PORT"), width: 50, hideable: true, align: "center", renderer: rendererMessPort},
{id: "MESS_INCOMING_SERVER", dataIndex: "MESS_INCOMING_SERVER", hidden: true, header: _("ID_INCOMING_SERVER"), width: 150, hideable: true, align: "center", renderer: rendererMessIncomingServer},
{id: "MESS_INCOMING_PORT", dataIndex: "MESS_INCOMING_PORT", hidden: true, header: _("ID_EMAIL_SERVER_PORT"), width: 50, hideable: true, align: "center", renderer: rendererMessIncomingPort},
{id: "MESS_RAUTH", dataIndex: "MESS_RAUTH", hidden: true, header: _("REQUIRE_AUTHENTICATION"), width: 50, hideable: false, align: "left"},
{id: "MESS_ACCOUNT", dataIndex: "MESS_ACCOUNT", hidden: false, header: _("ID_EMAIL_SERVER_ACCOUNT_FROM"), width: 130, hideable: true, align: "left"},
{id: "MESS_PASSWORD", dataIndex: "MESS_PASSWORD", hidden: true, header: _("ID_PASSWORD"), width: 130, hideable: false, align: "left"},
{id: "MESS_INCOMING_PORT", dataIndex: "MESS_INCOMING_PORT", hidden: true, header: _("ID_EMAIL_SERVER_PORT"), width: 50, hideable: true, align: "center", renderer: rendererMessIncomingPort},
{id: "MESS_RAUTH", dataIndex: "MESS_RAUTH", hidden: true, header: _("REQUIRE_AUTHENTICATION"), width: 50, hideable: false, align: "left"},
{id: "MESS_ACCOUNT", dataIndex: "MESS_ACCOUNT", hidden: false, header: _("ID_EMAIL_SERVER_ACCOUNT_FROM"), width: 130, hideable: true, align: "left"},
{id: "MESS_PASSWORD", dataIndex: "MESS_PASSWORD", hidden: true, header: _("ID_PASSWORD"), width: 130, hideable: false, align: "left"},
{id: "MESS_FROM_MAIL", dataIndex: "MESS_FROM_MAIL", hidden: false, header: _("ID_FROM_EMAIL"), width: 130, hideable: true, align: "left"},
{id: "MESS_FROM_NAME", dataIndex: "MESS_FROM_NAME", hidden: false, header: _("ID_FROM_NAME"), width: 150, hideable: true, align: "left"},
{id: "SMTPSECURE", dataIndex: "SMTPSECURE", hidden: false, header: _("USE_SECURE_CONNECTION"), width: 140, hideable: true, align: "center", renderer: rendererMessSmtpSecure},
{id: "MESS_TRY_SEND_INMEDIATLY", dataIndex: "MESS_TRY_SEND_INMEDIATLY", hidden: true, header: _("SEND_TEST_MAIL"), width: 50, hideable: false, align: "left"},
{id: "MAIL_TO", dataIndex: "MAIL_TO", hidden: false, header: _("MAIL_TO"), width: 150, hideable: true, align: "left"},
{id: "MESS_TRY_SEND_INMEDIATLY", dataIndex: "MESS_TRY_SEND_INMEDIATLY", hidden: true, header: _("SEND_TEST_MAIL"), width: 50, hideable: false, align: "left"},
{id: "MAIL_TO", dataIndex: "MAIL_TO", hidden: false, header: _("MAIL_TO"), width: 150, hideable: true, align: "left"},
{id: "MESS_DEFAULT", dataIndex: "MESS_DEFAULT", hidden: false, header: _("ID_EMAIL_SERVER_DEFAULT"), width: 50, hideable: true, align: "center", renderer: rendererMessDefault}
]
});
@@ -1129,7 +1234,7 @@ emailServer.application = {
{
var record = grdpnlMain.getSelectionModel().getSelected();
if (typeof(record) != "undefined") {
if (typeof (record) != "undefined") {
Ext.getCmp("btnSave").disable();
EMAILSERVEROPTION = "UPD";
@@ -1157,14 +1262,14 @@ emailServer.application = {
//Initialize events
grdpnlMain.on(
"rowcontextmenu",
function (grid, rowIndex, evt)
{
var sm = grid.getSelectionModel();
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
},
this
);
"rowcontextmenu",
function (grid, rowIndex, evt)
{
var sm = grid.getSelectionModel();
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
},
this
);
grdpnlMain.addListener("rowcontextmenu", onMnuContext, this);