Merged in release/3.6.4 (pull request #7906)

release/3.6.4
This commit is contained in:
Paula Quispe
2021-04-29 14:58:30 +00:00
28 changed files with 786 additions and 1074 deletions

View File

@@ -45,7 +45,7 @@
"monolog/monolog": "1.19.0",
"geshi/geshi": "dev-master",
"libchart/libchart": "1.4.0",
"phpmailer/phpmailer": "^6.4",
"phpmailer/phpmailer": "5.2.27",
"pear/archive_tar": "1.4.*",
"pear/console_getopt": "1.4.*",
"typo3/class-alias-loader": "^1.0",
@@ -63,8 +63,7 @@
"predis/predis": "1.1.1",
"phpmyadmin/sql-parser": "^5.3",
"aws/aws-sdk-php": "~3.0",
"cretueusebiu/laravel-javascript": "^0.2.1",
"stevenmaguire/oauth2-microsoft": "^2.2"
"cretueusebiu/laravel-javascript": "^0.2.1"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.3",

135
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "947b26e190aba8014ec85499b1747166",
"content-hash": "8186bf55af9b094297df563f73892ff6",
"packages": [
{
"name": "aws/aws-sdk-php",
@@ -2825,59 +2825,70 @@
},
{
"name": "phpmailer/phpmailer",
"version": "v6.4.0",
"version": "v5.2.27",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "050d430203105c27c30efd1dce7aa421ad882d01"
"reference": "dde1db116511aa4956389d75546c5be4c2beb2a6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/050d430203105c27c30efd1dce7aa421ad882d01",
"reference": "050d430203105c27c30efd1dce7aa421ad882d01",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/dde1db116511aa4956389d75546c5be4c2beb2a6",
"reference": "dde1db116511aa4956389d75546c5be4c2beb2a6",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-filter": "*",
"ext-hash": "*",
"php": ">=5.5.0"
"php": ">=5.0.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"doctrine/annotations": "^1.2",
"phpcompatibility/php-compatibility": "^9.3.5",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.5.6",
"yoast/phpunit-polyfills": "^0.2.0"
"doctrine/annotations": "1.2.*",
"jms/serializer": "0.16.*",
"phpdocumentor/phpdocumentor": "2.*",
"phpunit/phpunit": "4.8.*",
"symfony/debug": "2.8.*",
"symfony/filesystem": "2.8.*",
"symfony/translation": "2.8.*",
"symfony/yaml": "2.8.*",
"zendframework/zend-cache": "2.5.1",
"zendframework/zend-config": "2.5.1",
"zendframework/zend-eventmanager": "2.5.1",
"zendframework/zend-filter": "2.5.1",
"zendframework/zend-i18n": "2.5.1",
"zendframework/zend-json": "2.5.1",
"zendframework/zend-math": "2.5.1",
"zendframework/zend-serializer": "2.5.*",
"zendframework/zend-servicemanager": "2.5.*",
"zendframework/zend-stdlib": "2.5.1"
},
"suggest": {
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
"psr/log": "For optional PSR-3 debug logging",
"stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication",
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)"
"league/oauth2-google": "Needed for Google XOAUTH2 authentication"
},
"type": "library",
"autoload": {
"psr-4": {
"PHPMailer\\PHPMailer\\": "src/"
}
"classmap": [
"class.phpmailer.php",
"class.phpmaileroauth.php",
"class.phpmaileroauthgoogle.php",
"class.smtp.php",
"class.pop3.php",
"extras/EasyPeasyICS.php",
"extras/ntlm_sasl_client.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-only"
"LGPL-2.1"
],
"authors": [
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Andy Prevost",
"email": "codeworxtech@users.sourceforge.net"
@@ -2887,17 +2898,7 @@
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"support": {
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.4.0"
},
"funding": [
{
"url": "https://github.com/Synchro",
"type": "github"
}
],
"time": "2021-03-31T20:06:42+00:00"
"time": "2018-11-15T22:32:31+00:00"
},
{
"name": "phpmyadmin/sql-parser",
@@ -3514,60 +3515,6 @@
],
"time": "2017-11-03T06:39:13+00:00"
},
{
"name": "stevenmaguire/oauth2-microsoft",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/stevenmaguire/oauth2-microsoft.git",
"reference": "f24f79d8c47224d24a1240270ca3b0a4c1521ed4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stevenmaguire/oauth2-microsoft/zipball/f24f79d8c47224d24a1240270ca3b0a4c1521ed4",
"reference": "f24f79d8c47224d24a1240270ca3b0a4c1521ed4",
"shasum": ""
},
"require": {
"league/oauth2-client": "^2.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Stevenmaguire\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Steven Maguire",
"email": "stevenmaguire@gmail.com",
"homepage": "https://github.com/stevenmaguire"
}
],
"description": "Microsoft OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"authorisation",
"authorization",
"client",
"microsoft",
"oauth",
"oauth2"
],
"support": {
"issues": "https://github.com/stevenmaguire/oauth2-microsoft/issues",
"source": "https://github.com/stevenmaguire/oauth2-microsoft/tree/master"
},
"time": "2017-06-07T13:42:47+00:00"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v6.2.4",
@@ -7969,5 +7916,5 @@
"php": ">=7.1"
},
"platform-dev": [],
"plugin-api-version": "2.0.0"
"plugin-api-version": "1.1.0"
}

View File

@@ -2,7 +2,6 @@
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request;
use PHPMailer\PHPMailer\PHPMailer;
use ProcessMaker\Core\System;
use ProcessMaker\Log\AuditLog;
use ProcessMaker\Plugins\PluginRegistry;

View File

@@ -1,6 +1,50 @@
<?php
/**
* class.mailer.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 PHPMailer\PHPMailer\PHPMailer;
/* Send emails using the class "PHPMailer"
* Email server configuration constants:
* MAIL_MAILER mail/smtp
* MAIL_HOST email.server.address
* MAIL_SMTPAUTH true/false
* MAIL_USERNAME Email Username (smtp)
* MAIL_PASSWORD Email Password (smtp)
* MAIL_TIMEOUT Email Timeout (smtp)
* MAIL_CHARSET Email Charset "utf-8"
* MAIL_ENCODING Email Encoding "base64"
* Other required configuration constants:
* PATH_HTMLMAIL Email templates path
* @author David Callizaya <davidsantos@colosa.com>
*/
/**
*
* @package gulliver.system
*
*/
class mailer
{

View File

@@ -145,15 +145,11 @@ class RBAC
'DEL' => ['PM_SETUP'],
'LST' => ['PM_SETUP'],
'TEST' => ['PM_SETUP'],
'createAuthUrl' => ['PM_SETUP'],
'createAuthUrlOffice365' => ['PM_SETUP']
'createAuthUrl' => ['PM_SETUP']
],
'emailServerGmailOAuth.php' => [
'code' => ['PM_SETUP']
],
'emailServerOffice365OAuth.php' => [
'code' => ['PM_SETUP']
],
'processes_GetFile.php' => [
'mailTemplates' => ['PM_FACTORY'],
'public' => ['PM_FACTORY']

View File

@@ -7,8 +7,8 @@ use Faker\Factory;
use Google_Client;
use Google_Service_Gmail_Message;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use PHPMailerOAuth;
use ProcessMaker\Core\System;
use ProcessMaker\EmailOAuth\PHPMailerOAuth;
use ProcessMaker\GmailOAuth\GmailOAuth;
use ProcessMaker\Model\User;
use RBAC;

View File

@@ -805,7 +805,6 @@ class Derivation
*/
private function updateList(array $arrayCurrentDelegationData, array $arrayNextDelegationData, $taskNextDelegation, array $arrayApplicationData, $delIndexNew, $aSp, $removeList)
{
return;
/*----------------------------------********---------------------------------*/
try {
if ($arrayNextDelegationData["TAS_UID"] != "-1") {
@@ -826,6 +825,10 @@ class Derivation
$arrayApplicationData2["REMOVED_LIST"] = $removeList;
// Force to delete the row for avoid problems with duplicate key insert
$inbox = new ListInbox();
$inbox->remove($arrayApplicationData2['APP_UID'], $arrayApplicationData2['DEL_INDEX']);
// Update the new row
$inbox = new ListInbox();
$inbox->newRow($arrayApplicationData2, $arrayApplicationData["CURRENT_USER_UID"], (($arrayNextDelegationData["TAS_ASSIGN_TYPE"] == "SELF_SERVICE")? true : false));
}

View File

@@ -1,8 +1,6 @@
<?php
use Illuminate\Support\Facades\Log;
use PHPMailer\PHPMailer\OAuth;
use PHPMailer\PHPMailer\PHPMailer;
use ProcessMaker\Core\System;
/**
@@ -521,18 +519,18 @@ class SpoolRun
case 'PHPMAILER':
case 'IMAP':
case 'GMAILAPI':
case 'OFFICE365API':
$phpMailer = new PHPMailer();
switch ($this->config['MESS_ENGINE']) {
case 'MAIL':
$phpMailer = new PHPMailer();
$phpMailer->Mailer = 'mail';
break;
case 'IMAP':
case 'PHPMAILER':
$phpMailer = new PHPMailer(true);
$phpMailer->Mailer = 'smtp';
break;
case 'GMAILAPI':
case 'OFFICE365API':
$phpMailer = new PHPMailerOAuth();
$phpMailer->AuthType = 'XOAUTH2';
$phpMailer->isSMTP();
break;
@@ -546,7 +544,6 @@ class SpoolRun
case 'IMAP':
case 'PHPMAILER':
case 'GMAILAPI':
case 'OFFICE365API':
//Posible Options for SMTPSecure are: "", "ssl" or "tls"
if (isset($this->config['SMTPSecure']) && preg_match('/^(ssl|tls)$/', $this->config['SMTPSecure'])) {
$phpMailer->SMTPSecure = $this->config['SMTPSecure'];
@@ -561,42 +558,14 @@ class SpoolRun
$phpMailer->Encoding = "8bit";
$phpMailer->Host = $this->config['MESS_SERVER'];
$phpMailer->Port = $this->config['MESS_PORT'];
if (!in_array($this->config['MESS_ENGINE'], ['GMAILAPI', 'OFFICE365API'])) {
if ($this->config['MESS_ENGINE'] !== 'GMAILAPI') {
$phpMailer->Username = $this->config['MESS_ACCOUNT'];
$phpMailer->Password = $this->config['MESS_PASSWORD'];
} else {
// Get provider
switch ($this->config['MESS_ENGINE']) {
case 'GMAILAPI':
$providerClass = '\League\OAuth2\Client\Provider\Google';
break;
case 'OFFICE365API':
$providerClass = '\Stevenmaguire\OAuth2\Client\Provider\Microsoft';
break;
default:
throw new Exception('Only Google and Microsoft OAuth2 providers are currently supported.');
break;
}
$provider = new $providerClass(
[
'clientId' => $this->config['OAUTH_CLIENT_ID'],
'clientSecret' => $this->config['OAUTH_CLIENT_SECRET'],
'accessType' => 'offline'
]
);
// Set OAuth to use
$phpMailer->setOAuth(
new OAuth(
[
'provider' => $provider,
'clientId' => $this->config['OAUTH_CLIENT_ID'],
'clientSecret' => $this->config['OAUTH_CLIENT_SECRET'],
'refreshToken' => $this->config['OAUTH_REFRESH_TOKEN'],
'userName' => $this->config['MESS_ACCOUNT']
]
)
);
$phpMailer->oauthUserEmail = $this->config['MESS_ACCOUNT'];
$phpMailer->oauthClientId = $this->config['OAUTH_CLIENT_ID'];
$phpMailer->oauthClientSecret = $this->config['OAUTH_CLIENT_SECRET'];
$phpMailer->oauthRefreshToken = $this->config['OAUTH_REFRESH_TOKEN'];
}
//From

View File

@@ -4167,6 +4167,21 @@ class WorkspaceTools
APP_STATUS_ID = 0");
$con->commit();
// Populating APPLICATION.APP_FINISH_DATE
CLI::logging("-> Populating APPLICATION.APP_FINISH_DATE \n");
$con->begin();
$stmt = $con->createStatement();
$rs = $stmt->executeQuery("UPDATE APPLICATION AS AP
INNER JOIN (
SELECT APP_DELEGATION.APP_NUMBER, APP_DELEGATION.DEL_FINISH_DATE
FROM APP_DELEGATION
ORDER BY DEL_FINISH_DATE DESC
) AS DEL
ON (AP.APP_NUMBER = DEL.APP_NUMBER)
SET AP.APP_FINISH_DATE = DEL.DEL_FINISH_DATE
WHERE AP.APP_FINISH_DATE IS NULL AND AP.APP_STATUS_ID = 3");
$con->commit();
// Populating APP_DELAY.USR_ID
CLI::logging("-> Populating APP_DELAY.USR_ID \n");
$con->begin();

View File

@@ -1,38 +1,11 @@
<?php
/**
* class.pmFunctions.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* 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.
*/
////////////////////////////////////////////////////
// PM Functions
//
// Copyright (C) 2007 COLOSA
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////
use Illuminate\Support\Facades\Log;
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util\ElementTranslation;
use ProcessMaker\Validation\SqlBlacklist;
use Illuminate\Support\Facades\DB;
/**
@@ -241,101 +214,60 @@ function literalDate ($date, $lang = 'en')
* @throws SQLException
*
*/
function executeQuery ($SqlStatement, $DBConnectionUID = 'workflow', $aParameter = array())
function executeQuery($sqlStatement, $dbConnectionUID = 'workflow', $parameters = [])
{
// This means the DBConnectionUID is not loaded yet, so we'll force DbConnections::loadAdditionalConnections
if (is_null(config('database.connections.' . $DBConnectionUID . '.driver'))) {
if (is_null(config('database.connections.' . $dbConnectionUID . '.driver'))) {
// Force to load the external connections
DbConnections::loadAdditionalConnections();
}
if (config('database.connections.' . $DBConnectionUID . '.driver') !== 'oracle') {
if (config('database.connections.' . $dbConnectionUID . '.driver') !== 'oracle') {
// If the connections drivers are "mysql", "pgsql" or "sqlsrv" we're using Laravel
$con = DB::connection($DBConnectionUID);
$con = DB::connection($dbConnectionUID);
$con->beginTransaction();
} else {
// If the connection driver is "oracle" we are using the native oci8 functions
$con = Propel::getConnection($DBConnectionUID);
$con = Propel::getConnection($dbConnectionUID);
$con->begin();
}
$blackList = System::getQueryBlackList();
$listQueries = explode('|', isset($blackList['queries']) ? $blackList['queries'] : '');
$aListAllTables = explode(
'|',
((isset($blackList['tables']))? $blackList['tables'] : '') .
((isset($blackList['pmtables']))? $blackList['pmtables'] : '')
);
$parseSqlStm = new PHPSQLParser($SqlStatement);
try {
//Parsing queries and check the blacklist
foreach ($parseSqlStm as $key => $value) {
if($key === 'parsed'){
$aParseSqlStm = $value;
continue;
}
}
$nameOfTable = '';
$arrayOfTables = array();
foreach ($aParseSqlStm as $key => $value) {
if(in_array($key, $listQueries)){
if(isset($value['table'])){
$nameOfTable = $value['table'];
} else {
foreach ($value as $valueTab) {
if(is_array($valueTab)){
$arrayOfTables = $valueTab;
} else {
$nameOfTable = $valueTab;
}
}
}
if(isset($nameOfTable) && $nameOfTable !== ''){
if(in_array($nameOfTable,$aListAllTables)){
G::SendTemporalMessage( G::loadTranslation('ID_NOT_EXECUTE_QUERY', array($nameOfTable)), 'error', 'labels' );
throw new SQLException(G::loadTranslation('ID_NOT_EXECUTE_QUERY', array($nameOfTable)));
}
}
if (is_array($arrayOfTables)){
foreach ($arrayOfTables as $row){
if(!empty($row)){
if(in_array($row, $aListAllTables)){
G::SendTemporalMessage(G::loadTranslation('ID_NOT_EXECUTE_QUERY', array($nameOfTable)), 'error', 'labels' );
throw new SQLException(G::loadTranslation('ID_NOT_EXECUTE_QUERY', array($nameOfTable)));
}
}
}
}
}
try {
(new SqlBlacklist($sqlStatement))->validate();
} catch (Exception $e) {
G::SendTemporalMessage($e->getMessage(), 'error', 'labels');
throw new SQLException($e->getMessage());
}
$statement = trim( $SqlStatement );
$statement = str_replace( '(', '', $statement );
$statement = trim($sqlStatement);
$statement = str_replace('(', '', $statement);
$result = false;
// Check to see if we're not running oracle, which is usually a safe default
if (config('database.connections.' . $DBConnectionUID . '.driver') != 'oracle') {
if (config('database.connections.' . $dbConnectionUID . '.driver') != 'oracle') {
try {
switch (true) {
case preg_match( "/^(SELECT|EXECUTE|EXEC|SHOW|DESCRIBE|EXPLAIN|BEGIN)\s/i", $statement ):
$result = $con->select( $SqlStatement );
case preg_match("/^(SELECT|EXECUTE|EXEC|SHOW|DESCRIBE|EXPLAIN|BEGIN)\s/i", $statement):
$result = $con->select($sqlStatement);
// Convert to 1 index key array of array results
$result = collect($result)->map(function($x) { return (array)$x; })->toArray();
$result = collect($result)->map(function ($x) {
return (array) $x;
})->toArray();
array_unshift($result, []);
unset($result[0]);
break;
case preg_match( "/^INSERT\s/i", $statement ):
$result = $con->insert( $SqlStatement );
case preg_match("/^INSERT\s/i", $statement):
$result = $con->insert($sqlStatement);
break;
case preg_match( "/^REPLACE\s/i", $statement ):
$result = $con->update( $SqlStatement );
case preg_match("/^REPLACE\s/i", $statement):
$result = $con->update($sqlStatement);
break;
case preg_match( "/^UPDATE\s/i", $statement ):
$result = $con->update( $SqlStatement );
case preg_match("/^UPDATE\s/i", $statement):
$result = $con->update($sqlStatement);
break;
case preg_match( "/^DELETE\s/i", $statement ):
$result = $con->delete( $SqlStatement );
case preg_match("/^DELETE\s/i", $statement):
$result = $con->delete($sqlStatement);
break;
}
$con->commit();
@@ -347,21 +279,19 @@ function executeQuery ($SqlStatement, $DBConnectionUID = 'workflow', $aParameter
$dataEncode = $con->getDSN();
if (isset($dataEncode["encoding"]) && $dataEncode["encoding"] != "") {
$result = executeQueryOci($SqlStatement, $con, $aParameter, $dataEncode["encoding"]);
$result = executeQueryOci($sqlStatement, $con, $parameters, $dataEncode["encoding"]);
} else {
$result = executeQueryOci($SqlStatement, $con, $aParameter);
$result = executeQueryOci($sqlStatement, $con, $parameters);
}
}
//Logger
$message = 'Sql Execution';
$context = [
'action' => 'execute-query',
'sql' => $SqlStatement
'sql' => $sqlStatement
];
Log::channel(':sqlExecution')->info($message, Bootstrap::context($context));
return $result;
} catch (SQLException $sqle) {
//Logger
$message = 'Sql Execution';
$context = [
'action' => 'execute-query',

View File

@@ -99,7 +99,7 @@ class EmailServerMapBuilder
$tMap->addColumn('OAUTH_CLIENT_SECRET', 'OauthClientSecret', 'string', CreoleTypes::VARCHAR, true, 512);
$tMap->addColumn('OAUTH_REFRESH_TOKEN', 'OauthRefreshToken', 'string', CreoleTypes::LONGVARCHAR, false, null);
$tMap->addColumn('OAUTH_REFRESH_TOKEN', 'OauthRefreshToken', 'string', CreoleTypes::VARCHAR, true, 512);
} // doBuild()

View File

@@ -133,7 +133,7 @@ abstract class BaseEmailServer extends BaseObject implements Persistent
* The value for the oauth_refresh_token field.
* @var string
*/
protected $oauth_refresh_token;
protected $oauth_refresh_token = '';
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -736,7 +736,7 @@ abstract class BaseEmailServer extends BaseObject implements Persistent
$v = (string) $v;
}
if ($this->oauth_refresh_token !== $v) {
if ($this->oauth_refresh_token !== $v || $v === '') {
$this->oauth_refresh_token = $v;
$this->modifiedColumns[] = EmailServerPeer::OAUTH_REFRESH_TOKEN;
}

View File

@@ -5063,7 +5063,7 @@
<column name="MESS_DEFAULT" type="INTEGER" required="true" default="0"/>
<column name="OAUTH_CLIENT_ID" type="VARCHAR" size="512" required="true" default=""/>
<column name="OAUTH_CLIENT_SECRET" type="VARCHAR" size="512" required="true" default=""/>
<column name="OAUTH_REFRESH_TOKEN" type="LONGVARCHAR" required="false"/>
<column name="OAUTH_REFRESH_TOKEN" type="VARCHAR" size="512" required="true" default=""/>
</table>
<table name="WEB_ENTRY_EVENT">

View File

@@ -24599,12 +24599,6 @@ msgstr "Server"
msgid "Server Address"
msgstr "Server Address"
# TRANSLATION
# LABEL/ID_SERVER_API
#: LABEL/ID_SERVER_API
msgid "Server API"
msgstr "Server API"
# TRANSLATION
# LABEL/ID_SERVER_COMMUNICATION_ERROR
#: LABEL/ID_SERVER_COMMUNICATION_ERROR

View File

@@ -61015,7 +61015,6 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_SENT_BY','en','Sent By','2014-01-15') ,
( 'LABEL','ID_SERVER','en','Server','2014-01-15') ,
( 'LABEL','ID_SERVER_ADDRESS','en','Server Address','2015-09-14') ,
( 'LABEL','ID_SERVER_API','en','Server API','2021-03-29') ,
( 'LABEL','ID_SERVER_COMMUNICATION_ERROR','en','Failed to connect to the server','2014-01-15') ,
( 'LABEL','ID_SERVER_ERROR','en','Server error','2014-09-18') ,
( 'LABEL','ID_SERVER_IP','en','Server IP Address','2014-01-15') ,

View File

@@ -2806,7 +2806,7 @@ CREATE TABLE `EMAIL_SERVER`
`MESS_DEFAULT` INTEGER default 0 NOT NULL,
`OAUTH_CLIENT_ID` VARCHAR(512) default '' NOT NULL,
`OAUTH_CLIENT_SECRET` VARCHAR(512) default '' NOT NULL,
`OAUTH_REFRESH_TOKEN` MEDIUMTEXT,
`OAUTH_REFRESH_TOKEN` VARCHAR(512) default '' NOT NULL,
PRIMARY KEY (`MESS_UID`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';
#-----------------------------------------------------------------------------

View File

@@ -1,5 +1,6 @@
<?php
use ProcessMaker\Model\Application as ModelApplication;
use ProcessMaker\Model\Process as ProcessModel;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util\DateTime;
@@ -233,18 +234,19 @@ if (isset($_GET['breakpoint'])) {
}
#end trigger debug session.......
//Save data - Start
// Save data - Start
unset($Fields['APP_STATUS']);
unset($Fields['APP_PROC_STATUS']);
unset($Fields['APP_PROC_CODE']);
unset($Fields['APP_PIN']);
unset($Fields['APP_FINISH_DATE']);
$Fields["USER_UID"] = $_SESSION["USER_LOGGED"];
$Fields["CURRENT_DYNAFORM"] = $_GET["UID"];
$Fields["OBJECT_TYPE"] = ($_GET["UID"] == "-1") ? "ASSIGN_TASK" : $_GET["TYPE"];
$oCase->updateCase($_SESSION['APPLICATION'], $Fields);
//Save data - End
// Save data - End
//Obtain previous and next step - Start
try {

View File

@@ -1,23 +1,22 @@
<?php
/**
* ription:This is a additional configuration for load all connections; if exist in a particular proccess
* @Date: 15-05-2008
*
* @author : Erik Amaru Ortiz <erik@colosa.com>
* This is an additional configuration to load all connections if exist in a particular process
*/
$dbHash = @explode( SYSTEM_HASH, G::decrypt( HASH_INSTALLATION, SYSTEM_HASH ) );
$dbHash = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
$host = $dbHash[0];
$user = $dbHash[1];
$pass = $dbHash[2];
$dbName = DB_NAME;
$pro = include (PATH_CORE . "config/databases.php");
$pro = include(PATH_CORE . "config/databases.php");
$pro['datasources']['root'] = Array ();
$pro['datasources']['root']['connection'] = "mysql://$user:$pass@$host/$dbName?encoding=utf8";
$port = (!empty(config('database.connections.workflow.port'))) ? config('database.connections.workflow.port') : 3306;
$pro['datasources']['root'] = [];
$pro['datasources']['root']['connection'] = "mysql://$user:$pass@$host:$port/$dbName?encoding=utf8";
$pro['datasources']['root']['adapter'] = "mysql";
return $pro;

View File

@@ -2,7 +2,6 @@
use ProcessMaker\Core\System;
use ProcessMaker\GmailOAuth\GmailOAuth;
use ProcessMaker\Office365OAuth\Office365OAuth;
$option = (isset($_POST["option"])) ? $_POST["option"] : "";
$response = [];
@@ -233,8 +232,6 @@ switch ($option) {
case "createAuthUrl":
try {
$gmailOAuth = new GmailOAuth();
$gmailOAuth->setServer($_POST['server']);
$gmailOAuth->setPort($_POST['port']);
$gmailOAuth->setClientID($_POST['clientID']);
$gmailOAuth->setClientSecret($_POST['clientSecret']);
$gmailOAuth->setRedirectURI(System::getServerMainPath() . "/emailServer/emailServerGmailOAuth");
@@ -261,38 +258,6 @@ switch ($option) {
];
}
break;
case "createAuthUrlOffice365":
try {
$office365OAuth = new Office365OAuth();
$office365OAuth->setServer($_POST['server']);
$office365OAuth->setPort($_POST['port']);
$office365OAuth->setClientID($_POST['clientID']);
$office365OAuth->setClientSecret($_POST['clientSecret']);
$office365OAuth->setRedirectURI(System::getServerMainPath() . "/emailServer/emailServerOffice365OAuth");
$office365OAuth->setEmailEngine($_POST['emailEngine']);
$office365OAuth->setFromAccount($_POST['fromAccount']);
$office365OAuth->setSenderEmail($_POST['senderEmail']);
$office365OAuth->setSenderName($_POST['senderName']);
$office365OAuth->setSendTestMail((int) $_POST['sendTestMail']);
$office365OAuth->setMailTo($_POST['mailTo']);
$office365OAuth->setSetDefaultConfiguration((int) $_POST['setDefaultConfiguration']);
if (!empty($_POST['emailServerUid'])) {
$office365OAuth->setEmailServerUid($_POST['emailServerUid']);
}
$client = $office365OAuth->getOffice365Client();
$response = [
"status" => 200,
"data" => $client->getAuthorizationUrl($office365OAuth->getOptions())
];
$_SESSION['office365OAuth'] = $office365OAuth;
} catch (Exception $e) {
$response = [
"status" => 500,
"message" => $e->getMessage()
];
}
break;
}
echo G::json_encode($response);

View File

@@ -1,42 +0,0 @@
<?php
use Illuminate\Support\Facades\Cache;
use ProcessMaker\Core\System;
use ProcessMaker\Office365OAuth\Office365OAuth;
Cache::forget('errorMessageIfNotAuthenticate');
try {
$header = "location:" . System::getServerMainPath() . "/setup/main?s=EMAIL_SERVER";
$validInput = empty($_GET['code']) || empty($_SESSION['office365OAuth']) || !is_object($_SESSION['office365OAuth']);
if ($validInput) {
G::header($header);
return;
}
$RBAC->allows(basename(__FILE__), "code");
$office365OAuth = $_SESSION['office365OAuth'];
$office365Client = $office365OAuth->getOffice365Client();
$accessToken = $office365Client->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
$token = $accessToken->getToken();
$office365OAuth->setRefreshToken($accessToken->getRefreshToken());
$office365OAuth->saveEmailServer();
$office365OAuth->sendTestMailWithPHPMailerOAuth('Stevenmaguire\OAuth2\Client\Provider\Microsoft');
} catch (Exception $e) {
/**
* The laravel cache is volatile in each session, you can specify the duration
* value in minutes for each session. We use 2 minutes, enough time to retrieve
* the error message if there is one.
*/
Cache::put('errorMessageIfNotAuthenticate', $e->getMessage(), 2);
}
G::header($header);
return;

View File

@@ -8,8 +8,6 @@ use Exception;
use G;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Log;
use Net;
use PHPMailer\PHPMailer\SMTP;
use ProcessMaker\Core\System;
use ProcessMaker\Model\AbeConfiguration;
use ProcessMaker\Model\EmailEvent;
@@ -22,7 +20,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", "GMAILAPI", "OFFICE365API"), "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"),
@@ -249,11 +247,12 @@ class EmailServer
}
/**
* Test connection by step.
* Test connection by step
*
* @param array $arrayData
* @param int $step
* @return string
* @param array $arrayData Data
* @param int $step Step
*
* @return array, return array with result of test connection by step
* @throws Exception
*/
public function testConnectionByStep(array $arrayData, $step = 0)
@@ -263,12 +262,12 @@ class EmailServer
//MAIL
if ($arrayData["MESS_ENGINE"] == "MAIL") {
$arrayDataMail = [];
$arrayDataMail = array();
$eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
$arrayDataMail["FROM_EMAIL"] = ($arrayData["MESS_FROM_MAIL"] != "" && preg_match($eregMail, $arrayData["MESS_FROM_MAIL"])) ? $arrayData["MESS_FROM_MAIL"] : "";
$arrayDataMail["FROM_NAME"] = ($arrayData["MESS_FROM_NAME"] != "") ? $arrayData["MESS_FROM_NAME"] : G::LoadTranslation("ID_MESS_TEST_BODY");
$arrayDataMail["FROM_EMAIL"] = ($arrayData["MESS_FROM_MAIL"] != "" && preg_match($eregMail, $arrayData["MESS_FROM_MAIL"]))? $arrayData["MESS_FROM_MAIL"] : "";
$arrayDataMail["FROM_NAME"] = ($arrayData["MESS_FROM_NAME"] != "")? $arrayData["MESS_FROM_NAME"] : G::LoadTranslation("ID_MESS_TEST_BODY");
$arrayDataMail["MESS_ENGINE"] = "MAIL";
$arrayDataMail["MESS_SERVER"] = "localhost";
$arrayDataMail["MESS_PORT"] = 25;
@@ -277,24 +276,26 @@ class EmailServer
$arrayDataMail["TO"] = $arrayData["MAIL_TO"];
$arrayDataMail["MESS_RAUTH"] = true;
$arrayTestMailResult = [];
$arrayTestMailResult = array();
try {
$arrayTestMailResult = $this->sendTestMail($arrayDataMail);
} catch (Exception $e) {
$arrayTestMailResult["status"] = false;
$arrayTestMailResult["message"] = $e->getMessage();
}
$arrayResult = [
$arrayResult = array(
"result" => $arrayTestMailResult["status"],
"message" => ""
];
);
if ($arrayTestMailResult["status"] == false) {
$arrayResult["message"] = G::LoadTranslation("ID_SENDMAIL_NOT_INSTALLED");
}
//Return
return $arrayResult;
}
@@ -310,7 +311,7 @@ class EmailServer
$passwdHide = "";
}
$passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
$passwdDec = G::decrypt($passwd,"EMAILENCRYPT");
$auxPass = explode("hash:", $passwdDec);
if (count($auxPass) > 1) {
@@ -324,24 +325,21 @@ class EmailServer
$arrayData["MESS_PASSWORD"] = $passwd;
$port = (int) ($arrayData["MESS_PORT"]);
$auth_required = (int) ($arrayData["MESS_RAUTH"]);
$port = (int)($arrayData["MESS_PORT"]);
$auth_required = (int)($arrayData["MESS_RAUTH"]);
$useSecureCon = $arrayData["SMTPSECURE"];
$sendTestMail = (int) ($arrayData["MESS_TRY_SEND_INMEDIATLY"]);
$sendTestMail = (int)($arrayData["MESS_TRY_SEND_INMEDIATLY"]);
$mailTo = $arrayData["MAIL_TO"];
$smtpSecure = $arrayData["SMTPSECURE"];
$serverNet = new Net($server);
$smtp = new SMTP();
$serverNet = new \Net($server);
$smtp = new \SMTP();
$timeout = 10;
$hostinfo = [];
$hostinfo = array();
$srv = $arrayData["MESS_SERVER"];
$arrayResult = [
"result" => false,
"message" => ""
];
$arrayResult = array();
switch ($step) {
case 1:
@@ -350,6 +348,7 @@ class EmailServer
break;
case 2:
$serverNet->scannPort($port);
$arrayResult["result"] = $serverNet->getErrno() == 0;
$arrayResult["message"] = $serverNet->error;
break;
@@ -358,10 +357,12 @@ class EmailServer
if (preg_match("/^(.+):([0-9]+)$/", $srv, $hostinfo)) {
$server = $hostinfo[1];
$port = $hostinfo[2];
} else {
$host = $srv;
}
$tls = strtolower($smtpSecure) === "tls";
$ssl = strtolower($smtpSecure) === "ssl";
$tls = (strtoupper($smtpSecure) == "tls");
$ssl = (strtoupper($smtpSecure) == "ssl");
$arrayResult["result"] = $smtp->Connect(($ssl ? "ssl://" : "") . $server, $port, $timeout);
$arrayResult["message"] = $serverNet->error;
@@ -373,12 +374,27 @@ class EmailServer
if (preg_match("/^(.+):([0-9]+)$/", $srv, $hostinfo)) {
$server = $hostinfo[1];
$port = $hostinfo[2];
} else {
$server = $srv;
}
if (strtoupper($useSecureCon)=="TLS") {
$tls = "tls";
}
$tls = strtolower($useSecureCon) === "tls";
$ssl = strtolower($useSecureCon) === "ssl";
if (strtoupper($useSecureCon)=="SSL") {
$tls = "ssl";
}
$resp = $smtp->Connect(($ssl ? "ssl://" : "") . $server, $port, $timeout);
$tls = (strtoupper($useSecureCon) == "tls");
$ssl = (strtoupper($useSecureCon) == "ssl");
$server = $arrayData["MESS_SERVER"];
if (strtoupper($useSecureCon) == "SSL") {
$resp = $smtp->Connect(("ssl://") . $server, $port, $timeout);
} else {
$resp = $smtp->Connect($server, $port, $timeout);
}
if ($resp) {
$hello = $_SERVER["SERVER_NAME"];
@@ -388,7 +404,7 @@ class EmailServer
$smtp->Hello($hello);
}
if ($smtp->Authenticate($user, $passwd)) {
if ($smtp->Authenticate($user, $passwd) ) {
$arrayResult["result"] = true;
} else {
if (strtoupper($useSecureCon) == "TLS") {
@@ -416,11 +432,11 @@ class EmailServer
case 5:
if ($sendTestMail == 1) {
try {
$arrayDataPhpMailer = [];
$arrayDataPhpMailer = array();
$eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
$arrayDataPhpMailer["FROM_EMAIL"] = ($fromMail != "" && preg_match($eregMail, $fromMail)) ? $fromMail : "";
$arrayDataPhpMailer["FROM_EMAIL"] = ($fromMail != "" && preg_match($eregMail, $fromMail))? $fromMail : "";
$arrayDataPhpMailer["FROM_NAME"] = $arrayData["MESS_FROM_NAME"] != "" ? $arrayData["MESS_FROM_NAME"] : G::LoadTranslation("ID_MESS_TEST_BODY");
$arrayDataPhpMailer["MESS_ENGINE"] = "PHPMAILER";
$arrayDataPhpMailer["MESS_SERVER"] = $server;
@@ -458,12 +474,19 @@ class EmailServer
break;
}
if (!isset($arrayResult["message"])) {
$arrayResult["message"] = "";
}
//Return
return $arrayResult;
} catch (Exception $e) {
$arrayResult = [
"result" => false,
"message" => $e->getMessage()
];
$arrayResult = array();
$arrayResult["result"] = false;
$arrayResult["message"] = $e->getMessage();
//Return
return $arrayResult;
}
}

View File

@@ -1253,6 +1253,7 @@ class System
* @access public
* @param string $globalIniFile
* @return array of execute query Black list
* @deprecated since version 3.6.4
*/
public static function getQueryBlackList($globalIniFile = '')
{

View File

@@ -1,480 +0,0 @@
<?php
namespace ProcessMaker\EmailOAuth;
use AppMessage;
use Bootstrap;
use G;
use Google_Client;
use Google_Service_Gmail;
use Google_Service_Gmail_Message;
use Illuminate\Support\Facades\Log;
use ProcessMaker\BusinessModel\EmailServer;
use ProcessMaker\Core\System;
use TemplatePower;
use WsBase;
trait EmailBase
{
private $server;
private $port;
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 $server property.
* @param string $server
* @return void
*/
public function setServer($server): void
{
$this->server = $server;
}
/**
* Set $port property.
* @param string $port
* @return void
*/
public function setPort($port): void
{
$this->port = $port;
}
/**
* 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 int $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 $server property.
* @return string
*/
public function getServer()
{
return $this->server;
}
/**
* Get $port property.
* @return string
*/
public function getPort()
{
return $this->port;
}
/**
* 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 int
*/
public function getSetDefaultConfiguration()
{
return $this->setDefaultConfiguration;
}
/**
* Get $refreshToken property.
* @return string
*/
public function getRefreshToken()
{
return $this->refreshToken;
}
/**
* 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" => $this->server,
"MESS_PORT" => $this->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;
}
/**
* 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::getServerProtocol() . System::getServerHost());
$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.
* @param string $provider
* @return PHPMailerOAuth
*/
public function sendTestMailWithPHPMailerOAuth($provider = 'League\OAuth2\Client\Provider\Google'): PHPMailerOAuth
{
$phpMailerOAuth = new PHPMailerOAuth([
'provider' => new $provider([
'clientId' => $this->clientID,
'clientSecret' => $this->clientSecret,
'redirectUri' => $this->refreshToken,
'accessType' => 'offline'
]),
'clientId' => $this->clientID,
'clientSecret' => $this->clientSecret,
'refreshToken' => $this->refreshToken,
'userName' => $this->fromAccount
]);
if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth;
}
if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth;
}
if ($this->sendTestMail === 0) {
return $phpMailerOAuth;
}
$senderEmail = $this->senderEmail;
if (!filter_var($senderEmail, FILTER_VALIDATE_EMAIL)) {
$senderEmail = $this->fromAccount;
}
if (empty($this->senderName)) {
$this->senderName = "";
}
$phpMailerOAuth->isHTML(true);
$phpMailerOAuth->isSMTP();
$phpMailerOAuth->Host = $this->server;
$phpMailerOAuth->Port = $this->port;
$phpMailerOAuth->SMTPSecure = 'tls';
$phpMailerOAuth->SMTPAuth = true;
$phpMailerOAuth->AuthType = 'XOAUTH2';
$phpMailerOAuth->SetFrom($senderEmail, $this->senderName);
$phpMailerOAuth->Subject = G::LoadTranslation("ID_MESS_TEST_SUBJECT");
$phpMailerOAuth->Body = utf8_encode($this->getMessageBody());
$phpMailerOAuth->AddAddress($this->mailTo);
$status = $phpMailerOAuth->Send();
$this->saveIntoStandardLogs($status ? "sent" : "pending");
$this->saveIntoAppMessage($status ? "sent" : "pending");
return $phpMailerOAuth;
}
/**
* Register into APP_MESSAGE table.
* @param string $status
*/
public function saveIntoAppMessage(string $status = "")
{
$appMsgUid = G::generateUniqueID();
$spool = new AppMessage();
$spool->setAppMsgUid($appMsgUid);
$spool->setMsgUid("");
$spool->setAppUid("");
$spool->setDelIndex(0);
$spool->setAppMsgType(WsBase::MESSAGE_TYPE_TEST_EMAIL);
$spool->setAppMsgTypeId(isset(AppMessage::$app_msg_type_values[WsBase::MESSAGE_TYPE_TEST_EMAIL]) ? AppMessage::$app_msg_type_values[WsBase::MESSAGE_TYPE_TEST_EMAIL] : 0);
$spool->setAppMsgSubject(G::LoadTranslation("ID_MESS_TEST_SUBJECT"));
$spool->setAppMsgFrom($this->fromAccount);
$spool->setAppMsgTo($this->mailTo);
$spool->setAppMsgBody(utf8_encode($this->getMessageBody()));
$spool->setAppMsgDate(date('Y-m-d H:i:s'));
$spool->setAppMsgCc("");
$spool->setAppMsgBcc("");
$spool->setappMsgAttach(serialize([""]));
$spool->setAppMsgTemplate("");
$spool->setAppMsgStatus($status);
$spool->setAppMsgStatusId(AppMessage::$app_msg_status_values[$status] ? AppMessage::$app_msg_status_values[$status] : 0);
$spool->setAppMsgSendDate(date('Y-m-d H:i:s'));
$spool->setAppMsgShowMessage(1);
$spool->setAppMsgError("");
$spool->setAppNumber(0);
$spool->setTasId(0);
$spool->setProId(0);
$spool->save();
}
/**
* Register into standard logs.
* @param string $status
*/
public function saveIntoStandardLogs(string $status = "")
{
$message = "Email Server test has been sent";
$context = [
"emailServerUid" => $this->emailServerUid,
"emailEngine" => $this->emailEngine,
"from" => $this->fromAccount,
"senderAccount" => $this->mailTo,
"senderEmail" => $this->senderEmail,
"senderName" => $this->senderName,
"status" => $status
];
Log::channel(':' . $this->emailEngine)->info($message, Bootstrap::context($context));
}
}

View File

@@ -1,20 +0,0 @@
<?php
namespace ProcessMaker\EmailOAuth;
use PHPMailer\PHPMailer\OAuth;
use PHPMailer\PHPMailer\PHPMailer;
class PHPMailerOAuth extends PHPMailer
{
/**
* Constructor of the class.
* @param array $options
*/
public function __construct($options)
{
$oauth = new OAuth($options);
$this->setOAuth($oauth);
}
}

View File

@@ -2,23 +2,260 @@
namespace ProcessMaker\GmailOAuth;
use AppMessage;
use Bootstrap;
use G;
use Google_Client;
use Google_Service_Gmail;
use Google_Service_Gmail_Message;
use ProcessMaker\EmailOAuth\EmailBase;
use Illuminate\Support\Facades\Log;
use PHPMailerOAuth;
use ProcessMaker\BusinessModel\EmailServer;
use ProcessMaker\Core\System;
use TemplatePower;
use WsBase;
class GmailOAuth
{
use EmailBase;
private $emailServerUid;
private $emailEngine;
private $clientID;
private $clientSecret;
private $fromAccount;
private $senderEmail;
private $senderName;
private $sendTestMail;
private $mailTo;
private $setDefaultConfiguration;
private $redirectURI;
private $refreshToken;
/**
* Constructor of the class.
* Set $emailServerUid property.
* @param string $emailServerUid
* @return void
*/
public function __construct()
public function setEmailServerUid($emailServerUid): void
{
$this->setServer("smtp.gmail.com");
$this->setPort(587);
$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;
}
/**
@@ -37,6 +274,42 @@ class GmailOAuth
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.
@@ -69,4 +342,139 @@ class GmailOAuth
$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::getServerProtocol() . System::getServerHost());
$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->mailTo, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth;
}
if ($this->sendTestMail === 0) {
return $phpMailerOAuth;
}
$senderEmail = $this->senderEmail;
if (!filter_var($senderEmail, FILTER_VALIDATE_EMAIL)) {
$senderEmail = $this->fromAccount;
}
if (empty($this->senderName)) {
$this->senderName = "";
}
$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($senderEmail, $this->senderName);
$phpMailerOAuth->Subject = G::LoadTranslation("ID_MESS_TEST_SUBJECT");
$phpMailerOAuth->Body = utf8_encode($this->getMessageBody());
$phpMailerOAuth->AddAddress($this->mailTo);
$status = $phpMailerOAuth->Send();
$this->saveIntoStandardLogs($status ? "sent" : "pending");
$this->saveIntoAppMessage($status ? "sent" : "pending");
return $phpMailerOAuth;
}
/**
* Register into APP_MESSAGE table.
* @param string $status
*/
public function saveIntoAppMessage(string $status = "")
{
$appMsgUid = G::generateUniqueID();
$spool = new AppMessage();
$spool->setAppMsgUid($appMsgUid);
$spool->setMsgUid("");
$spool->setAppUid("");
$spool->setDelIndex(0);
$spool->setAppMsgType(WsBase::MESSAGE_TYPE_TEST_EMAIL);
$spool->setAppMsgTypeId(isset(AppMessage::$app_msg_type_values[WsBase::MESSAGE_TYPE_TEST_EMAIL]) ? AppMessage::$app_msg_type_values[WsBase::MESSAGE_TYPE_TEST_EMAIL] : 0);
$spool->setAppMsgSubject(G::LoadTranslation("ID_MESS_TEST_SUBJECT"));
$spool->setAppMsgFrom($this->fromAccount);
$spool->setAppMsgTo($this->mailTo);
$spool->setAppMsgBody(utf8_encode($this->getMessageBody()));
$spool->setAppMsgDate(date('Y-m-d H:i:s'));
$spool->setAppMsgCc("");
$spool->setAppMsgBcc("");
$spool->setappMsgAttach(serialize([""]));
$spool->setAppMsgTemplate("");
$spool->setAppMsgStatus($status);
$spool->setAppMsgStatusId(AppMessage::$app_msg_status_values[$status] ? AppMessage::$app_msg_status_values[$status] : 0);
$spool->setAppMsgSendDate(date('Y-m-d H:i:s'));
$spool->setAppMsgShowMessage(1);
$spool->setAppMsgError("");
$spool->setAppNumber(0);
$spool->setTasId(0);
$spool->setProId(0);
$spool->save();
}
/**
* Register into standard logs.
* @param string $status
*/
public function saveIntoStandardLogs(string $status = "")
{
$message = "Email Server test has been sent";
$context = [
"emailServerUid" => $this->emailServerUid,
"emailEngine" => $this->emailEngine,
"from" => $this->fromAccount,
"senderAccount" => $this->mailTo,
"senderEmail" => $this->senderEmail,
"senderName" => $this->senderName,
"status" => $status
];
Log::channel(':GmailOAuth')->info($message, Bootstrap::context($context));
}
}

View File

@@ -1,53 +0,0 @@
<?php
namespace ProcessMaker\Office365OAuth;
use League\OAuth2\Client\Provider\GenericProvider;
use ProcessMaker\EmailOAuth\EmailBase;
use ProcessMaker\GmailOAuth\GmailOAuth;
use Stevenmaguire\OAuth2\Client\Provider\Microsoft;
class Office365OAuth
{
use EmailBase;
private $options = [
'scope' => [
'wl.imap',
'wl.offline_access'
]
];
/**
* Constructor of the class.
*/
public function __construct()
{
$this->setServer("smtp.office365.com");
$this->setPort(587);
}
/**
* Get $options property.
* @return array
*/
public function getOptions()
{
return $this->options;
}
/**
* Get a Microsoft object, this may vary depending on the service provider.
* @return Google_Client
*/
public function getOffice365Client()
{
$provider = new Microsoft([
'clientId' => $this->getClientID(),
'clientSecret' => $this->getClientSecret(),
'redirectUri' => $this->getRedirectURI(),
'accessType' => 'offline'
]);
return $provider;
}
}

View File

@@ -0,0 +1,124 @@
<?php
namespace ProcessMaker\Validation;
use Exception;
use G;
use PhpMyAdmin\SqlParser\Parser;
class SqlBlacklist extends Parser
{
/**
* Define the statements to block, this is case sensitive.
* @var array
*/
private $statementsToBeBlocked = [
'SELECT',
'EXECUTE',
'EXEC',
'SHOW',
'DESCRIBE',
'EXPLAIN',
'BEGIN',
'INSERT',
'UPDATE',
'DELETE',
'REPLACE'
];
/**
* Constructor of class.
* @param string $list
* @param boolean $strict
*/
public function __construct($list = null, $strict = false)
{
parent::__construct($list, $strict);
}
/**
* Get information about the statements permitted and tables that can be modified.
* @return array
*/
public function getConfigValues(): array
{
$tables = [];
$statements = [];
$pmtables = [];
$path = PATH_CONFIG . 'system-tables.ini';
if (file_exists($path)) {
$values = @parse_ini_file($path);
$string = isset($values['tables']) ? $values['tables'] : '';
$tables = explode('|', $string);
$tables = array_filter($tables, function ($v) {
return !empty($v);
});
}
$path = PATH_CONFIG . 'execute-query-blacklist.ini';
if (file_exists($path)) {
$values = @parse_ini_file($path);
$string = isset($values['pmtables']) ? $values['pmtables'] : '';
$pmtables = explode('|', $string);
$pmtables = array_filter($pmtables, function ($v) {
return !empty($v);
});
$string = isset($values['queries']) ? $values['queries'] : '';
$string = strtoupper($string);
$statements = explode('|', $string);
//get only statements allowed for lock
$statements = array_filter($statements, function ($v) {
$toUpper = strtoupper($v);
return !empty($v) && in_array($toUpper, $this->statementsToBeBlocked);
});
}
return [
'tables' => $tables,
'statements' => $statements,
'pmtables' => $pmtables
];
}
/**
* Parse a sql string and check the blacklist, an exception is thrown if it contains a restricted item.
* @return void
* @throws Exception
*/
public function validate(): void
{
$config = $this->getConfigValues();
//verify statements
foreach ($this->statements as $statement) {
$signed = get_class($statement);
foreach (Parser::$STATEMENT_PARSERS as $key => $value) {
if ($signed === $value && in_array(strtoupper($key), $config['statements'])) {
throw new Exception(G::loadTranslation('ID_INVALID_QUERY'));
}
}
}
//verify tables
//tokens are formed multidimensionally, it is necessary to recursively traverse the multidimensional object.
$listTables = array_merge($config['tables'], $config['pmtables']);
$fn = function ($object) use (&$fn, $listTables) {
foreach ($object as $key => $value) {
if (is_array($value) || is_object($value)) {
$fn($value);
}
if ($key === 'table' && is_string($value)) {
if (in_array($value, $listTables)) {
throw new Exception(G::loadTranslation('ID_NOT_EXECUTE_QUERY', [$value]));
}
}
}
};
$fn($this->statements);
}
}

View File

@@ -275,15 +275,11 @@ emailServer.application = {
function emailServerSetEmailEngine(cboEmailEngine)
{
Ext.getCmp("txtServer").setValue("");
Ext.getCmp("txtPort").setValue("");
Ext.getCmp("frmEmailServer").getForm().clearInvalid();
Ext.getCmp("textClientId").setVisible(false);
Ext.getCmp("textClientSecret").setVisible(false);
Ext.getCmp("buttonContinue").setVisible(false);
Ext.getCmp("button2Continue").setVisible(false);
Ext.getCmp("btnTest").setVisible(true);
Ext.getCmp("btnSave").setVisible(true);
/*----------------------------------********---------------------------------*/
@@ -350,12 +346,8 @@ emailServer.application = {
Ext.getCmp("textClientSecret").allowBlank = true;
/*----------------------------------********---------------------------------*/
} else if (cboEmailEngine === "GMAILAPI") {
Ext.getCmp("txtServer").setVisible(true);
Ext.getCmp("txtServer").setValue("smtp.gmail.com");
Ext.getCmp("txtServer").label.update(_("ID_SERVER_API"));
Ext.getCmp("txtPort").setVisible(true);
Ext.getCmp("txtPort").setValue("587");
Ext.getCmp("txtPort").label.update(_("ID_EMAIL_SERVER_PORT"));
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);
@@ -370,35 +362,6 @@ emailServer.application = {
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;
Ext.getCmp("textClientId").allowBlank = false;
Ext.getCmp("textClientSecret").allowBlank = false;
} else if (cboEmailEngine === "OFFICE365API") {
Ext.getCmp("txtServer").setVisible(true);
Ext.getCmp("txtServer").setValue("smtp.office365.com");
Ext.getCmp("txtServer").label.update(_("ID_SERVER_API"));
Ext.getCmp("txtPort").setVisible(true);
Ext.getCmp("txtPort").setValue("587");
Ext.getCmp("txtPort").label.update(_("ID_EMAIL_SERVER_PORT"));
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("button2Continue").setVisible(true);
emailServerSetPassword(false);
Ext.getCmp("txtServer").allowBlank = true;
Ext.getCmp("txtPort").allowBlank = true;
Ext.getCmp("txtIncomingServer").allowBlank = true;
@@ -435,9 +398,7 @@ emailServer.application = {
function emailServerSetPassword(flagPassChecked)
{
if (flagPassChecked
&& Ext.getCmp("cboEmailEngine").getValue() !== 'GMAILAPI'
&& Ext.getCmp("cboEmailEngine").getValue() !== 'OFFICE365API') {
if (flagPassChecked && Ext.getCmp("cboEmailEngine").getValue() !== 'GMAILAPI') {
Ext.getCmp("txtPassword").setVisible(true);
Ext.getCmp("txtPassword").allowBlank = false;
} else {
@@ -635,8 +596,7 @@ emailServer.application = {
["IMAP", "SMTP - IMAP (PHPMailer)"],
/*----------------------------------********---------------------------------*/
["MAIL", "Mail (PHP)"],
["GMAILAPI", "GMAIL API (PHPMailer)"],
["OFFICE365API", "OFFICE 365 API (PHPMailer)"]
["GMAILAPI", "GMAIL API (PHPMailer)"]
]
});
@@ -866,76 +826,6 @@ emailServer.application = {
parameters = {
option: 'createAuthUrl',
emailEngine: Ext.getCmp("cboEmailEngine").getValue(),
server: Ext.getCmp("txtServer").getValue(),
port: Ext.getCmp("txtPort").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 button2Continue = new Ext.Action({
id: 'button2Continue',
text: _("ID_CONTINUE"),
width: 85,
handler: function () {
var frmEmailServer, parameters;
frmEmailServer = Ext.getCmp("frmEmailServer");
if (frmEmailServer.getForm().isValid()) {
winData.setDisabled(true);
parameters = {
option: 'createAuthUrlOffice365',
emailEngine: Ext.getCmp("cboEmailEngine").getValue(),
server: Ext.getCmp("txtServer").getValue(),
port: Ext.getCmp("txtPort").getValue(),
clientID: Ext.getCmp("textClientId").getValue(),
clientSecret: Ext.getCmp("textClientSecret").getValue(),
fromAccount: Ext.getCmp("txtAccountFrom").getValue(),
@@ -1035,7 +925,7 @@ emailServer.application = {
resizable: false,
closeAction: "hide",
items: [frmEmailServer],
buttons: [buttonContinue, button2Continue, btnTest, btnSave, btnCancel]
buttons: [buttonContinue, btnTest, btnSave, btnCancel]
});
winData.show();
winData.hide();