Merged in marcoAntonioNina/processmaker/GI-235 (pull request #3454)
GI-235
This commit is contained in:
@@ -30,7 +30,7 @@ class AppDocumentDrive
|
||||
public function __construct()
|
||||
{
|
||||
$this->drive = new PMDrive();
|
||||
$status = $this->drive->getStatusService();
|
||||
$status = $this->drive->getServiceDriveStatus();
|
||||
$status = !empty($status) ? ($status == 1 ? true : false): false;
|
||||
$this->usersDrive = '';
|
||||
$this->setStatusDrive($status);
|
||||
|
||||
@@ -20,7 +20,7 @@ class PMGoogleApi
|
||||
|
||||
private $scope = array();
|
||||
private $serviceAccountEmail;
|
||||
private $serviceAccountP12;
|
||||
private $serviceAccountCertificate;
|
||||
private $statusService;
|
||||
private $domain;
|
||||
private $user;
|
||||
@@ -35,7 +35,7 @@ class PMGoogleApi
|
||||
public function __construct()
|
||||
{
|
||||
$licensedFeatures = &PMLicensedFeatures::getSingleton();
|
||||
if (!$licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
||||
if (!($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09') || $licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M='))) {
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
@@ -95,17 +95,17 @@ class PMGoogleApi
|
||||
return $this->serviceAccountEmail;
|
||||
}
|
||||
|
||||
public function setServiceAccountP12($serviceAccountP12)
|
||||
public function setServiceAccountCertificate ($serviceAccountCertificate)
|
||||
{
|
||||
$this->configuration->aConfig['serviceAccountP12'] = $serviceAccountP12;
|
||||
$this->configuration->aConfig['serviceAccountCertificate'] = $serviceAccountCertificate;
|
||||
$this->configuration->saveConfig('GOOGLE_API_SETTINGS', '', '', '');
|
||||
|
||||
$this->serviceAccountP12 = $serviceAccountP12;
|
||||
$this->serviceAccountCertificate = $serviceAccountCertificate;
|
||||
}
|
||||
|
||||
public function getServiceAccountP12()
|
||||
public function getServiceAccountCertificate()
|
||||
{
|
||||
return $this->serviceAccountP12;
|
||||
return $this->serviceAccountCertificate;
|
||||
}
|
||||
|
||||
public function setDomain($domain)
|
||||
@@ -184,7 +184,7 @@ class PMGoogleApi
|
||||
$typeAuthentication = empty($this->configuration->aConfig['typeAuthentication']) ? '' : $this->configuration->aConfig['typeAuthentication'];
|
||||
$accountJson = empty($this->configuration->aConfig['accountJson']) ? '' : $this->configuration->aConfig['accountJson'];
|
||||
|
||||
$serviceAccountP12 = empty($this->configuration->aConfig['serviceAccountP12']) ? '' : $this->configuration->aConfig['serviceAccountP12'];
|
||||
$serviceAccountCertificate = empty($this->configuration->aConfig['serviceAccountCertificate']) ? '' : $this->configuration->aConfig['serviceAccountCertificate'];
|
||||
$serviceAccountEmail = empty($this->configuration->aConfig['serviceAccountEmail']) ? '' : $this->configuration->aConfig['serviceAccountEmail'];
|
||||
$statusService = empty($this->configuration->aConfig['statusService']) ? '' : $this->configuration->aConfig['statusService'];
|
||||
|
||||
@@ -196,7 +196,7 @@ class PMGoogleApi
|
||||
$this->typeAuthentication = $typeAuthentication;
|
||||
$this->accountJson = $accountJson;
|
||||
$this->serviceAccountEmail = $serviceAccountEmail;
|
||||
$this->serviceAccountP12 = $serviceAccountP12;
|
||||
$this->serviceAccountCertificate = $serviceAccountCertificate;
|
||||
$this->statusService = $statusService;
|
||||
$this->serviceGmailStatus = $serviceGmailStatus;
|
||||
$this->serviceDriveStatus = $serviceDriveStatus;
|
||||
@@ -210,67 +210,35 @@ class PMGoogleApi
|
||||
public function serviceClient()
|
||||
{
|
||||
$client = null;
|
||||
if ($this->typeAuthentication == 'webApplication') {
|
||||
if (file_exists(PATH_DATA_SITE . $this->accountJson)) {
|
||||
$credential = file_get_contents(PATH_DATA_SITE . $this->accountJson);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_JSON_ERROR'));
|
||||
}
|
||||
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setAuthConfig($credential);
|
||||
$client->addScope($this->scope);
|
||||
|
||||
if (!empty($_SESSION['google_token'])) {
|
||||
$client->setAccessToken($_SESSION['google_token']);
|
||||
if ($client->isAccessTokenExpired()) {
|
||||
$client->getRefreshToken();
|
||||
unset($_SESSION['google_token']);
|
||||
$_SESSION['google_token'] = $client->getAccessToken();
|
||||
}
|
||||
} else if (!empty($_SESSION['CODE_GMAIL'])) {
|
||||
$token = $client->authenticate($_SESSION['CODE_GMAIL']);
|
||||
$_SESSION['google_token'] = $client->getAccessToken();
|
||||
} else {
|
||||
$authUrl = $client->createAuthUrl();
|
||||
echo '<script type="text/javascript">
|
||||
var opciones = "width=450,height=480,scrollbars=NO, locatin=NO,toolbar=NO, status=NO, menumbar=NO, top=10%, left=25%";
|
||||
window.open("' . $authUrl . '","Gmail", opciones);
|
||||
</script>';
|
||||
die;
|
||||
}
|
||||
} else if ($this->typeAuthentication == 'serviceAccount') {
|
||||
|
||||
if (file_exists(PATH_DATA_SITE . $this->serviceAccountP12)) {
|
||||
$key = file_get_contents(PATH_DATA_SITE . $this->serviceAccountP12);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_P12_ERROR'));
|
||||
}
|
||||
|
||||
$data = json_decode($key);
|
||||
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
||||
$this->serviceAccountEmail,
|
||||
$this->scope,
|
||||
$data->private_key
|
||||
);
|
||||
|
||||
$assertionCredentials->sub = $this->user;
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setApplicationName("PMDrive");
|
||||
$client->setAssertionCredentials($assertionCredentials);
|
||||
if (file_exists(PATH_DATA_SITE . $this->serviceAccountCertificate)) {
|
||||
$key = file_get_contents(PATH_DATA_SITE . $this->serviceAccountCertificate);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_SERVER_COMMUNICATION_ERROR'));
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_CERTIFICATE_ERROR'));
|
||||
}
|
||||
|
||||
$data = json_decode($key);
|
||||
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
||||
$this->serviceAccountEmail,
|
||||
$this->scope,
|
||||
$data->private_key
|
||||
);
|
||||
|
||||
$assertionCredentials->sub = $this->user;
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setApplicationName("PMDrive");
|
||||
$client->setAssertionCredentials($assertionCredentials);
|
||||
|
||||
|
||||
return $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* New service client - Authentication google Api
|
||||
*
|
||||
* @return Google_Service_Client $service API service instance.
|
||||
* @param $credentials
|
||||
* @throws \Exception
|
||||
* @return \StdClass response.
|
||||
*/
|
||||
public function testService($credentials)
|
||||
{
|
||||
@@ -285,55 +253,22 @@ class PMGoogleApi
|
||||
static::DRIVE_PHOTOS_READONLY
|
||||
);
|
||||
|
||||
if ($credentials->typeAuth == 'webApplication') {
|
||||
|
||||
if (file_exists($credentials->pathFileJson)) {
|
||||
$credential = file_get_contents($credentials->pathFileJson);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_JSON_ERROR'));
|
||||
}
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setAuthConfig($credential);
|
||||
$client->addScope($scope);
|
||||
|
||||
if (!empty($_SESSION['google_token'])) {
|
||||
$client->setAccessToken($_SESSION['google_token']);
|
||||
if ($client->isAccessTokenExpired()) {
|
||||
unset($_SESSION['google_token']);
|
||||
}
|
||||
} else if (!empty($_SESSION['CODE_GMAIL'])) {
|
||||
$token = $client->authenticate($_SESSION['CODE_GMAIL']);
|
||||
$_SESSION['google_token'] = $client->getAccessToken();
|
||||
} else {
|
||||
$authUrl = $client->createAuthUrl();
|
||||
echo '<script type="text/javascript">
|
||||
var opciones = "width=450,height=480,scrollbars=NO, locatin=NO,toolbar=NO, status=NO, menumbar=NO, top=10%, left=25%";
|
||||
window.open("' . $authUrl . '","Gmail", opciones);
|
||||
</script>';
|
||||
die;
|
||||
}
|
||||
if (file_exists($credentials->pathServiceAccountCertificate)) {
|
||||
$key = file_get_contents($credentials->pathServiceAccountCertificate);
|
||||
} else {
|
||||
|
||||
if (file_exists($credentials->pathServiceAccountP12)) {
|
||||
$key = file_get_contents($credentials->pathServiceAccountP12);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_P12_ERROR'));
|
||||
}
|
||||
$data = json_decode($key);
|
||||
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
||||
$credentials->emailServiceAccount,
|
||||
$scope,
|
||||
$data->private_key
|
||||
);
|
||||
$assertionCredentials->sub = $this->user;
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setApplicationName("PMDrive");
|
||||
$client->setAssertionCredentials($assertionCredentials);
|
||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_CERTIFICATE_ERROR'));
|
||||
}
|
||||
$data = json_decode($key);
|
||||
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
||||
$credentials->emailServiceAccount,
|
||||
$scope,
|
||||
$data->private_key
|
||||
);
|
||||
$assertionCredentials->sub = $this->user;
|
||||
|
||||
|
||||
$client = new Google_Client();
|
||||
$client->setApplicationName("PMDrive");
|
||||
$client->setAssertionCredentials($assertionCredentials);
|
||||
|
||||
$service = new Google_Service_Drive($client);
|
||||
|
||||
|
||||
@@ -16,33 +16,26 @@ class pmGmail extends Controller
|
||||
$result = new StdClass();
|
||||
$result->success = true;
|
||||
|
||||
if (!empty($httpData->status_pmgmail)) {
|
||||
$httpData->status_pmgmail = $httpData->status_pmgmail == 1 ? true : false;
|
||||
//$httpData->seriveGmailStatus = $httpData->seriveGmailStatus == 1 ? true : false;
|
||||
//$httpData->seriveDriveStatus = $httpData->seriveDriveStatus == 1 ? true : false;
|
||||
$pmGoogle->setStatusService($httpData->status_pmgmail);
|
||||
//$pmGoogle->setServiceGmailStatus($httpData->seriveGmailStatus);
|
||||
//$pmGoogle->setServiceDriveStatus($httpData->seriveDriveStatus);
|
||||
$message = G::LoadTranslation('ID_ENABLE_PMGMAIL') . ': ' . ($httpData->status_pmgmail ? G::LoadTranslation('ID_ENABLE') : G::LoadTranslation('ID_DISABLE'));
|
||||
if (!(empty($httpData->serviceGmailStatus) || empty($httpData->serviceGmailStatus))) {
|
||||
$httpData->serviceGmailStatus = !empty($httpData->serviceGmailStatus) ? $httpData->serviceGmailStatus == 1 ? true : false : false;
|
||||
$httpData->serviceDriveStatus = !empty($httpData->serviceDriveStatus) ? $httpData->serviceDriveStatus == 1 ? true : false : false;
|
||||
|
||||
$pmGoogle->setTypeAuthentication($httpData->typeAuth);
|
||||
$pmGoogle->setServiceGmailStatus($httpData->serviceGmailStatus);
|
||||
$pmGoogle->setServiceDriveStatus($httpData->serviceDriveStatus);
|
||||
|
||||
if (!empty($httpData->email_service_account)) {
|
||||
$pmGoogle->setServiceAccountEmail($httpData->email_service_account);
|
||||
$message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->email_service_account;
|
||||
$message = G::LoadTranslation('ID_ENABLE_PMGMAIL') . ': ' . ($httpData->serviceGmailStatus ? G::LoadTranslation('ID_ENABLE') : G::LoadTranslation('ID_DISABLE'));
|
||||
$message .= G::LoadTranslation('ID_ENABLE_PMDRIVE') . ': ' . ($httpData->serviceDriveStatus ? G::LoadTranslation('ID_ENABLE') : G::LoadTranslation('ID_DISABLE'));
|
||||
|
||||
if (!empty($httpData->emailServiceAccount)) {
|
||||
$pmGoogle->setServiceAccountEmail($httpData->emailServiceAccount);
|
||||
$message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->emailServiceAccount;
|
||||
}
|
||||
if (!empty($_FILES)) {
|
||||
if (!empty($_FILES['file_p12']) && $_FILES['file_p12']['error'] != 1) {
|
||||
if ($_FILES['file_p12']['tmp_name'] != '') {
|
||||
G::uploadFile($_FILES['file_p12']['tmp_name'], PATH_DATA_SITE, $_FILES['file_p12']['name']);
|
||||
$pmGoogle->setServiceAccountP12($_FILES['file_p12']['name']);
|
||||
$message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_p12']['name'];
|
||||
}
|
||||
} else if (!empty($_FILES['file_json']) && $_FILES['file_json']['error'] != 1) {
|
||||
if ($_FILES['file_json']['tmp_name'] != '') {
|
||||
G::uploadFile($_FILES['file_json']['tmp_name'], PATH_DATA_SITE, $_FILES['file_json']['name']);
|
||||
$pmGoogle->setAccountJson($_FILES['file_json']['name']);
|
||||
$message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_json']['name'];
|
||||
if (!empty($_FILES['googleCertificate']) && $_FILES['googleCertificate']['error'] != 1) {
|
||||
if ($_FILES['googleCertificate']['tmp_name'] != '') {
|
||||
G::uploadFile($_FILES['googleCertificate']['tmp_name'], PATH_DATA_SITE, $_FILES['googleCertificate']['name']);
|
||||
$pmGoogle->setServiceAccountCertificate($_FILES['googleCertificate']['name']);
|
||||
$message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['googleCertificate']['name'];
|
||||
}
|
||||
} else {
|
||||
$result->success = false;
|
||||
@@ -68,20 +61,17 @@ class pmGmail extends Controller
|
||||
$this->setJSVar('__PMGMAIL_ERROR__', $_SESSION['__PMGMAIL_ERROR__']);
|
||||
unset($_SESSION['__PMGMAIL_ERROR__']);
|
||||
}
|
||||
G::LoadClass( "pmGoogleApi" );
|
||||
G::LoadClass("pmGoogleApi");
|
||||
$pmGoogle = new PMGoogleApi();
|
||||
$accountEmail = $pmGoogle->getServiceAccountEmail();
|
||||
$fileP12 = $pmGoogle->getServiceAccountP12();
|
||||
$fileJson = $pmGoogle->getAccountJson();
|
||||
$fileJson = $fileJson == null ? '' : $fileJson;
|
||||
$type = $pmGoogle->getTypeAuthentication();
|
||||
$enablePMGmail = $pmGoogle->getStatusService();
|
||||
$googleCertificate = $pmGoogle->getServiceAccountCertificate();
|
||||
$statusGmail = $pmGoogle->getServiceGmailStatus();
|
||||
$statusDrive = $pmGoogle->getServiceDriveStatus();
|
||||
|
||||
$this->setJSVar('accountEmail', $accountEmail);
|
||||
$this->setJSVar('fileP12', $fileP12);
|
||||
$this->setJSVar('enablePMGmail', $enablePMGmail);
|
||||
$this->setJSVar('fileJson', $fileJson);
|
||||
$this->setJSVar('typeAuthentication', $type);
|
||||
$this->setJSVar('googleCertificate', $googleCertificate);
|
||||
$this->setJSVar('statusGmail', $statusGmail);
|
||||
$this->setJSVar('statusDrive', $statusDrive);
|
||||
|
||||
|
||||
G::RenderPage('publish', 'extJs');
|
||||
@@ -101,13 +91,8 @@ class pmGmail extends Controller
|
||||
|
||||
$result = new stdClass();
|
||||
|
||||
$result->typeAuth = empty($httpData->typeAuth) ? $pmGoogle->getTypeAuthentication() : $httpData->typeAuth;
|
||||
if ($result->typeAuth == 'webApplication') {
|
||||
$result->pathFileJson = empty($_FILES['file_json']['tmp_name']) ? PATH_DATA_SITE . $pmGoogle->getAccountJson() : $_FILES['file_json']['tmp_name'];
|
||||
} else {
|
||||
$result->emailServiceAccount = empty($httpData->email_service_account) ? $pmGoogle->getServiceAccountEmail() : $httpData->email_service_account;
|
||||
$result->pathServiceAccountP12 = empty($_FILES['file_p12']['tmp_name']) ? PATH_DATA_SITE . $pmGoogle->getserviceAccountP12() : $_FILES['file_p12']['tmp_name'];
|
||||
}
|
||||
$result->emailServiceAccount = empty($httpData->emailServiceAccount) ? $pmGoogle->getServiceAccountEmail() : $httpData->emailServiceAccount;
|
||||
$result->pathServiceAccountCertificate = empty($_FILES['googleCertificate']['tmp_name']) ? PATH_DATA_SITE . $pmGoogle->getServiceAccountCertificate() : $_FILES['googleCertificate']['tmp_name'];
|
||||
|
||||
print(G::json_encode($pmGoogle->testService($result)));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ var saveButton;
|
||||
var testButton;
|
||||
var storeUsers;
|
||||
var disableAll;
|
||||
var changeType;
|
||||
Ext.onReady(function(){
|
||||
var enableInterfazCertificate;
|
||||
Ext.onReady(function() {
|
||||
Ext.QuickTips.init();
|
||||
|
||||
testButton = new Ext.Action({
|
||||
text : _('ID_TEST_CONNECTION'),
|
||||
disabled : !enablePMGmail,
|
||||
disabled : true,
|
||||
handler : testSettings
|
||||
});
|
||||
|
||||
@@ -19,58 +19,39 @@ Ext.onReady(function(){
|
||||
});
|
||||
|
||||
disableAll = function () {
|
||||
Ext.getCmp('email_service_account').disable();
|
||||
Ext.getCmp('file_p12').disable();
|
||||
Ext.getCmp('labelFileP12').disable();
|
||||
Ext.getCmp('file_json').disable();
|
||||
Ext.getCmp('fileJson').disable();
|
||||
Ext.getCmp('emailServiceAccount').disable();
|
||||
Ext.getCmp('googleCertificate').disable();
|
||||
Ext.getCmp('labelFileGoogleCertificate').disable();
|
||||
testButton.disable();
|
||||
saveButton.disable();
|
||||
|
||||
Ext.getCmp('typeAuthentication').hide();
|
||||
Ext.getCmp('email_service_account').hide();
|
||||
Ext.getCmp('file_p12').hide();
|
||||
Ext.getCmp('labelFileP12').hide();
|
||||
|
||||
Ext.getCmp('file_json').hide();
|
||||
Ext.getCmp('fileJson').hide();
|
||||
Ext.getCmp('emailServiceAccount').hide();
|
||||
Ext.getCmp('googleCertificate').hide();
|
||||
Ext.getCmp('labelFileGoogleCertificate').hide();
|
||||
|
||||
Ext.getCmp('listUsers').hide();
|
||||
Ext.getCmp('testPMGmail').hide();
|
||||
};
|
||||
|
||||
var enableTypeP12 = function () {
|
||||
Ext.getCmp('email_service_account').enable();
|
||||
Ext.getCmp('file_p12').enable();
|
||||
Ext.getCmp('labelFileP12').enable();
|
||||
enableInterfazCertificate = function () {
|
||||
Ext.getCmp('emailServiceAccount').enable();
|
||||
Ext.getCmp('googleCertificate').enable();
|
||||
Ext.getCmp('labelFileGoogleCertificate').enable();
|
||||
|
||||
Ext.getCmp('email_service_account').show();
|
||||
Ext.getCmp('file_p12').show();
|
||||
Ext.getCmp('labelFileP12').show();
|
||||
Ext.getCmp('emailServiceAccount').show();
|
||||
Ext.getCmp('googleCertificate').show();
|
||||
Ext.getCmp('labelFileGoogleCertificate').show();
|
||||
|
||||
testButton.enable();
|
||||
};
|
||||
|
||||
var enableTypeJson = function () {
|
||||
Ext.getCmp('file_json').enable();
|
||||
Ext.getCmp('fileJson').enable();
|
||||
|
||||
Ext.getCmp('file_json').show();
|
||||
Ext.getCmp('fileJson').show();
|
||||
testButton.enable();
|
||||
};
|
||||
|
||||
changeType = function () {
|
||||
enableTypeP12();
|
||||
};
|
||||
|
||||
var configurationPMGmail = new Ext.form.FieldSet({
|
||||
title: _('ID_PMGMAIL_SETTINGS'),
|
||||
items: [
|
||||
{
|
||||
xtype: 'checkbox',
|
||||
id: 'status_pmgmail',
|
||||
name: 'status_pmgmail',
|
||||
id: 'serviceGmailStatus',
|
||||
name: 'serviceGmailStatus',
|
||||
boxLabel: _('ID_ENABLE_PMGMAIL'),
|
||||
value: 0,
|
||||
inputValue: 1,
|
||||
@@ -79,18 +60,20 @@ Ext.onReady(function(){
|
||||
check : function(that, checked) {
|
||||
disableAll();
|
||||
if (checked) {
|
||||
enableTypeP12();
|
||||
enableInterfazCertificate();
|
||||
} else {
|
||||
Ext.MessageBox.confirm(
|
||||
_('ID_CONFIRM'),
|
||||
_('ID_PMGMAIL_DISABLE'),
|
||||
function (btn, text) {
|
||||
if (btn == "yes") {
|
||||
saveSettings();
|
||||
if (Ext.getCmp('serviceDriveStatus').getValue()) {
|
||||
enableInterfazCertificate();
|
||||
}
|
||||
saveButton.enable();
|
||||
} else {
|
||||
changeType();
|
||||
Ext.getCmp('status_pmgmail').setValue(1);
|
||||
return false;
|
||||
enableInterfazCertificate();
|
||||
Ext.getCmp('serviceGmailStatus').setValue(1);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -99,49 +82,60 @@ Ext.onReady(function(){
|
||||
}
|
||||
},
|
||||
{
|
||||
xtype : 'combo',
|
||||
id : 'typeAuthentication',
|
||||
name : 'typeAuthentication',
|
||||
xtype : 'combo',
|
||||
fieldLabel : _('GMAIL_TYPE_AUTH'),
|
||||
hiddenName: 'typeAuth',
|
||||
mode : 'local',
|
||||
triggerAction : 'all',
|
||||
forceSelection: true,
|
||||
store: new Ext.data.SimpleStore({
|
||||
fields: ['value','type'],
|
||||
data: [['webApplication', 'ID_WEB_APPLICATION'],['serviceAccount', 'ID_SERVICE_ACCOUNT']],
|
||||
autoLoad: true
|
||||
}),
|
||||
submitValue : true,
|
||||
value: typeAuthentication,
|
||||
hidden: true,
|
||||
valueField: 'value',
|
||||
displayField: 'type',
|
||||
width: 250,
|
||||
editable: false,
|
||||
listeners:{
|
||||
afterRender: function () {
|
||||
xtype : 'label',
|
||||
labelAlign : 'right',
|
||||
fieldLabel : '',
|
||||
text : _('ID_GMAIL_HELP_ENABLE'),
|
||||
style : "padding-left:180px; display: inline-block;"
|
||||
},
|
||||
{
|
||||
xtype: 'checkbox',
|
||||
id: 'serviceDriveStatus',
|
||||
name: 'serviceDriveStatus',
|
||||
boxLabel: _('ID_ENABLE_PMDRIVE'),
|
||||
value: 0,
|
||||
inputValue: 1,
|
||||
uncheckedValue: 0,
|
||||
listeners : {
|
||||
check : function(that, checked) {
|
||||
disableAll();
|
||||
if (Ext.getCmp('status_pmgmail').checked) {
|
||||
changeType();
|
||||
if (checked) {
|
||||
enableInterfazCertificate();
|
||||
} else {
|
||||
Ext.MessageBox.confirm(
|
||||
_('ID_CONFIRM'),
|
||||
_('ID_PMDRIVE_DISABLE'),
|
||||
function (btn, text) {
|
||||
if (btn == "yes") {
|
||||
if (Ext.getCmp('serviceGmailStatus').getValue()) {
|
||||
enableInterfazCertificate();
|
||||
}
|
||||
saveButton.enable();
|
||||
} else {
|
||||
enableInterfazCertificate();
|
||||
Ext.getCmp('serviceDriveStatus').setValue(1);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
select: function(combo){
|
||||
disableAll();
|
||||
changeType();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
xtype : 'label',
|
||||
labelAlign : 'right',
|
||||
fieldLabel : '',
|
||||
text : _('ID_DRIVE_HELP_ENABLE'),
|
||||
style : "padding-left:180px; display: inline-block;"
|
||||
},
|
||||
{
|
||||
xtype : 'textfield',
|
||||
id : 'email_service_account',
|
||||
name : 'email_service_account',
|
||||
id : 'emailServiceAccount',
|
||||
name : 'emailServiceAccount',
|
||||
fieldLabel : _('ID_PMG_EMAIL'),
|
||||
width : 400,
|
||||
allowBlank : false,
|
||||
value : accountEmail,
|
||||
disabled : !enablePMGmail,
|
||||
listeners : {
|
||||
change: function(){
|
||||
changeSettings();
|
||||
@@ -157,49 +151,12 @@ Ext.onReady(function(){
|
||||
},
|
||||
{
|
||||
xtype : 'fileuploadfield',
|
||||
id : 'file_p12',
|
||||
id : 'googleCertificate',
|
||||
emptyText : _('ID_PMG_SELECT_FILE'),
|
||||
fieldLabel : _('ID_PMG_FILE'),
|
||||
name : 'file_p12',
|
||||
name : 'googleCertificate',
|
||||
buttonText : '',
|
||||
width : 400,
|
||||
disabled : !enablePMGmail,
|
||||
buttonCfg : {
|
||||
iconCls : 'upload-icon'
|
||||
},
|
||||
listeners:{
|
||||
change : function(){
|
||||
changeSettings();
|
||||
},
|
||||
afterrender:function(cmp){
|
||||
changeSettings();
|
||||
cmp.fileInput.set({
|
||||
accept:'*/p12'
|
||||
});
|
||||
}
|
||||
},
|
||||
regex : /(.)+((\.json)(\w)?)$/i,
|
||||
regexText : _('ID_PMG_TYPE_ACCEPT')
|
||||
},
|
||||
{
|
||||
xtype : 'label',
|
||||
id : 'labelFileP12',
|
||||
name : 'labelFileP12',
|
||||
labelAlign : 'right',
|
||||
fieldLabel : '',
|
||||
text : fileP12,
|
||||
width : 400,
|
||||
style : "padding-left:180px;"
|
||||
},
|
||||
{
|
||||
xtype : 'fileuploadfield',
|
||||
id : 'file_json',
|
||||
emptyText : _('ID_PMG_SELECT_FILE_JSON'),
|
||||
fieldLabel : _('ID_PMG_FILE_JSON'),
|
||||
name : 'file_json',
|
||||
buttonText : '',
|
||||
width : 400,
|
||||
disabled : !enablePMGmail,
|
||||
buttonCfg : {
|
||||
iconCls : 'upload-icon'
|
||||
},
|
||||
@@ -219,11 +176,11 @@ Ext.onReady(function(){
|
||||
},
|
||||
{
|
||||
xtype : 'label',
|
||||
id : 'fileJson',
|
||||
name : 'fileJson',
|
||||
id : 'labelFileGoogleCertificate',
|
||||
name : 'labelFileGoogleCertificate',
|
||||
labelAlign : 'right',
|
||||
fieldLabel : '',
|
||||
text : fileJson,
|
||||
text : googleCertificate,
|
||||
width : 400,
|
||||
style : "padding-left:180px;"
|
||||
}
|
||||
@@ -350,12 +307,14 @@ Ext.onReady(function(){
|
||||
]
|
||||
});
|
||||
|
||||
Ext.getCmp('status_pmgmail').checked = enablePMGmail;
|
||||
Ext.getCmp('status_pmgmail').setValue(enablePMGmail);
|
||||
Ext.getCmp('typeAuthentication').setValue('serviceAccount');
|
||||
if (enablePMGmail){
|
||||
changeType();
|
||||
Ext.getCmp('serviceGmailStatus').checked = statusGmail;
|
||||
Ext.getCmp('serviceGmailStatus').setValue(statusGmail);
|
||||
Ext.getCmp('serviceDriveStatus').checked = statusDrive;
|
||||
Ext.getCmp('serviceDriveStatus').setValue(statusDrive);
|
||||
if (statusGmail || statusDrive){
|
||||
enableInterfazCertificate();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var testSettings = function ()
|
||||
@@ -422,7 +381,7 @@ var saveSettings = function ()
|
||||
var changeSettings = function()
|
||||
{
|
||||
disableAll();
|
||||
if (Ext.getCmp('status_pmgmail').checked) {
|
||||
changeType();
|
||||
if (Ext.getCmp('serviceGmailStatus').checked || Ext.getCmp('serviceDriveStatus').checked) {
|
||||
enableInterfazCertificate();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user