PMC-1346 Changes in the email server creation
This commit is contained in:
@@ -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'],
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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') ,
|
||||
|
||||
@@ -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");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
419
workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuth.php
Normal file
419
workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuth.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user