GI-235 Modificar pantalla PmGmail Admin para seleccionar las 2 funcionalidades:Drive y Gmail
This commit is contained in:
@@ -30,7 +30,7 @@ class AppDocumentDrive
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->drive = new PMDrive();
|
$this->drive = new PMDrive();
|
||||||
$status = $this->drive->getStatusService();
|
$status = $this->drive->getServiceDriveStatus();
|
||||||
$status = !empty($status) ? ($status == 1 ? true : false): false;
|
$status = !empty($status) ? ($status == 1 ? true : false): false;
|
||||||
$this->usersDrive = '';
|
$this->usersDrive = '';
|
||||||
$this->setStatusDrive($status);
|
$this->setStatusDrive($status);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class PMGoogleApi
|
|||||||
|
|
||||||
private $scope = array();
|
private $scope = array();
|
||||||
private $serviceAccountEmail;
|
private $serviceAccountEmail;
|
||||||
private $serviceAccountP12;
|
private $serviceAccountCertificate;
|
||||||
private $statusService;
|
private $statusService;
|
||||||
private $domain;
|
private $domain;
|
||||||
private $user;
|
private $user;
|
||||||
@@ -35,7 +35,7 @@ class PMGoogleApi
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$licensedFeatures = &PMLicensedFeatures::getSingleton();
|
$licensedFeatures = &PMLicensedFeatures::getSingleton();
|
||||||
if (!$licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
if (!($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09') || $licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M='))) {
|
||||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||||
G::header('location: ../login/login');
|
G::header('location: ../login/login');
|
||||||
die;
|
die;
|
||||||
@@ -95,17 +95,17 @@ class PMGoogleApi
|
|||||||
return $this->serviceAccountEmail;
|
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->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)
|
public function setDomain($domain)
|
||||||
@@ -184,7 +184,7 @@ class PMGoogleApi
|
|||||||
$typeAuthentication = empty($this->configuration->aConfig['typeAuthentication']) ? '' : $this->configuration->aConfig['typeAuthentication'];
|
$typeAuthentication = empty($this->configuration->aConfig['typeAuthentication']) ? '' : $this->configuration->aConfig['typeAuthentication'];
|
||||||
$accountJson = empty($this->configuration->aConfig['accountJson']) ? '' : $this->configuration->aConfig['accountJson'];
|
$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'];
|
$serviceAccountEmail = empty($this->configuration->aConfig['serviceAccountEmail']) ? '' : $this->configuration->aConfig['serviceAccountEmail'];
|
||||||
$statusService = empty($this->configuration->aConfig['statusService']) ? '' : $this->configuration->aConfig['statusService'];
|
$statusService = empty($this->configuration->aConfig['statusService']) ? '' : $this->configuration->aConfig['statusService'];
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ class PMGoogleApi
|
|||||||
$this->typeAuthentication = $typeAuthentication;
|
$this->typeAuthentication = $typeAuthentication;
|
||||||
$this->accountJson = $accountJson;
|
$this->accountJson = $accountJson;
|
||||||
$this->serviceAccountEmail = $serviceAccountEmail;
|
$this->serviceAccountEmail = $serviceAccountEmail;
|
||||||
$this->serviceAccountP12 = $serviceAccountP12;
|
$this->serviceAccountCertificate = $serviceAccountCertificate;
|
||||||
$this->statusService = $statusService;
|
$this->statusService = $statusService;
|
||||||
$this->serviceGmailStatus = $serviceGmailStatus;
|
$this->serviceGmailStatus = $serviceGmailStatus;
|
||||||
$this->serviceDriveStatus = $serviceDriveStatus;
|
$this->serviceDriveStatus = $serviceDriveStatus;
|
||||||
@@ -210,42 +210,10 @@ class PMGoogleApi
|
|||||||
public function serviceClient()
|
public function serviceClient()
|
||||||
{
|
{
|
||||||
$client = null;
|
$client = null;
|
||||||
if ($this->typeAuthentication == 'webApplication') {
|
if (file_exists(PATH_DATA_SITE . $this->serviceAccountCertificate)) {
|
||||||
if (file_exists(PATH_DATA_SITE . $this->accountJson)) {
|
$key = file_get_contents(PATH_DATA_SITE . $this->serviceAccountCertificate);
|
||||||
$credential = file_get_contents(PATH_DATA_SITE . $this->accountJson);
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_JSON_ERROR'));
|
throw new Exception(G::LoadTranslation('ID_GOOGLE_CERTIFICATE_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);
|
$data = json_decode($key);
|
||||||
@@ -260,9 +228,7 @@ class PMGoogleApi
|
|||||||
$client = new Google_Client();
|
$client = new Google_Client();
|
||||||
$client->setApplicationName("PMDrive");
|
$client->setApplicationName("PMDrive");
|
||||||
$client->setAssertionCredentials($assertionCredentials);
|
$client->setAssertionCredentials($assertionCredentials);
|
||||||
} else {
|
|
||||||
throw new Exception(G::LoadTranslation('ID_SERVER_COMMUNICATION_ERROR'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
@@ -270,7 +236,9 @@ class PMGoogleApi
|
|||||||
/**
|
/**
|
||||||
* New service client - Authentication google Api
|
* 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)
|
public function testService($credentials)
|
||||||
{
|
{
|
||||||
@@ -285,40 +253,10 @@ class PMGoogleApi
|
|||||||
static::DRIVE_PHOTOS_READONLY
|
static::DRIVE_PHOTOS_READONLY
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($credentials->typeAuth == 'webApplication') {
|
if (file_exists($credentials->pathServiceAccountCertificate)) {
|
||||||
|
$key = file_get_contents($credentials->pathServiceAccountCertificate);
|
||||||
if (file_exists($credentials->pathFileJson)) {
|
|
||||||
$credential = file_get_contents($credentials->pathFileJson);
|
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(G::LoadTranslation('ID_GOOGLE_FILE_JSON_ERROR'));
|
throw new Exception(G::LoadTranslation('ID_GOOGLE_CERTIFICATE_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;
|
|
||||||
}
|
|
||||||
} 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);
|
$data = json_decode($key);
|
||||||
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
$assertionCredentials = new Google_Auth_AssertionCredentials(
|
||||||
@@ -331,9 +269,6 @@ class PMGoogleApi
|
|||||||
$client = new Google_Client();
|
$client = new Google_Client();
|
||||||
$client->setApplicationName("PMDrive");
|
$client->setApplicationName("PMDrive");
|
||||||
$client->setAssertionCredentials($assertionCredentials);
|
$client->setAssertionCredentials($assertionCredentials);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$service = new Google_Service_Drive($client);
|
$service = new Google_Service_Drive($client);
|
||||||
|
|
||||||
|
|||||||
@@ -16,33 +16,26 @@ class pmGmail extends Controller
|
|||||||
$result = new StdClass();
|
$result = new StdClass();
|
||||||
$result->success = true;
|
$result->success = true;
|
||||||
|
|
||||||
if (!empty($httpData->status_pmgmail)) {
|
if (!(empty($httpData->serviceGmailStatus) || empty($httpData->serviceGmailStatus))) {
|
||||||
$httpData->status_pmgmail = $httpData->status_pmgmail == 1 ? true : false;
|
$httpData->serviceGmailStatus = !empty($httpData->serviceGmailStatus) ? $httpData->serviceGmailStatus == 1 ? true : false : false;
|
||||||
//$httpData->seriveGmailStatus = $httpData->seriveGmailStatus == 1 ? true : false;
|
$httpData->serviceDriveStatus = !empty($httpData->serviceDriveStatus) ? $httpData->serviceDriveStatus == 1 ? true : false : 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'));
|
|
||||||
|
|
||||||
$pmGoogle->setTypeAuthentication($httpData->typeAuth);
|
$pmGoogle->setServiceGmailStatus($httpData->serviceGmailStatus);
|
||||||
|
$pmGoogle->setServiceDriveStatus($httpData->serviceDriveStatus);
|
||||||
|
|
||||||
if (!empty($httpData->email_service_account)) {
|
$message = G::LoadTranslation('ID_ENABLE_PMGMAIL') . ': ' . ($httpData->serviceGmailStatus ? G::LoadTranslation('ID_ENABLE') : G::LoadTranslation('ID_DISABLE'));
|
||||||
$pmGoogle->setServiceAccountEmail($httpData->email_service_account);
|
$message .= G::LoadTranslation('ID_ENABLE_PMDRIVE') . ': ' . ($httpData->serviceDriveStatus ? G::LoadTranslation('ID_ENABLE') : G::LoadTranslation('ID_DISABLE'));
|
||||||
$message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->email_service_account;
|
|
||||||
|
if (!empty($httpData->emailServiceAccount)) {
|
||||||
|
$pmGoogle->setServiceAccountEmail($httpData->emailServiceAccount);
|
||||||
|
$message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->emailServiceAccount;
|
||||||
}
|
}
|
||||||
if (!empty($_FILES)) {
|
if (!empty($_FILES)) {
|
||||||
if (!empty($_FILES['file_p12']) && $_FILES['file_p12']['error'] != 1) {
|
if (!empty($_FILES['googleCertificate']) && $_FILES['googleCertificate']['error'] != 1) {
|
||||||
if ($_FILES['file_p12']['tmp_name'] != '') {
|
if ($_FILES['googleCertificate']['tmp_name'] != '') {
|
||||||
G::uploadFile($_FILES['file_p12']['tmp_name'], PATH_DATA_SITE, $_FILES['file_p12']['name']);
|
G::uploadFile($_FILES['googleCertificate']['tmp_name'], PATH_DATA_SITE, $_FILES['googleCertificate']['name']);
|
||||||
$pmGoogle->setServiceAccountP12($_FILES['file_p12']['name']);
|
$pmGoogle->setServiceAccountCertificate($_FILES['googleCertificate']['name']);
|
||||||
$message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_p12']['name'];
|
$message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['googleCertificate']['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'];
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result->success = false;
|
$result->success = false;
|
||||||
@@ -68,20 +61,17 @@ class pmGmail extends Controller
|
|||||||
$this->setJSVar('__PMGMAIL_ERROR__', $_SESSION['__PMGMAIL_ERROR__']);
|
$this->setJSVar('__PMGMAIL_ERROR__', $_SESSION['__PMGMAIL_ERROR__']);
|
||||||
unset($_SESSION['__PMGMAIL_ERROR__']);
|
unset($_SESSION['__PMGMAIL_ERROR__']);
|
||||||
}
|
}
|
||||||
G::LoadClass( "pmGoogleApi" );
|
G::LoadClass("pmGoogleApi");
|
||||||
$pmGoogle = new PMGoogleApi();
|
$pmGoogle = new PMGoogleApi();
|
||||||
$accountEmail = $pmGoogle->getServiceAccountEmail();
|
$accountEmail = $pmGoogle->getServiceAccountEmail();
|
||||||
$fileP12 = $pmGoogle->getServiceAccountP12();
|
$googleCertificate = $pmGoogle->getServiceAccountCertificate();
|
||||||
$fileJson = $pmGoogle->getAccountJson();
|
$statusGmail = $pmGoogle->getServiceGmailStatus();
|
||||||
$fileJson = $fileJson == null ? '' : $fileJson;
|
$statusDrive = $pmGoogle->getServiceDriveStatus();
|
||||||
$type = $pmGoogle->getTypeAuthentication();
|
|
||||||
$enablePMGmail = $pmGoogle->getStatusService();
|
|
||||||
|
|
||||||
$this->setJSVar('accountEmail', $accountEmail);
|
$this->setJSVar('accountEmail', $accountEmail);
|
||||||
$this->setJSVar('fileP12', $fileP12);
|
$this->setJSVar('googleCertificate', $googleCertificate);
|
||||||
$this->setJSVar('enablePMGmail', $enablePMGmail);
|
$this->setJSVar('statusGmail', $statusGmail);
|
||||||
$this->setJSVar('fileJson', $fileJson);
|
$this->setJSVar('statusDrive', $statusDrive);
|
||||||
$this->setJSVar('typeAuthentication', $type);
|
|
||||||
|
|
||||||
|
|
||||||
G::RenderPage('publish', 'extJs');
|
G::RenderPage('publish', 'extJs');
|
||||||
@@ -101,13 +91,8 @@ class pmGmail extends Controller
|
|||||||
|
|
||||||
$result = new stdClass();
|
$result = new stdClass();
|
||||||
|
|
||||||
$result->typeAuth = empty($httpData->typeAuth) ? $pmGoogle->getTypeAuthentication() : $httpData->typeAuth;
|
$result->emailServiceAccount = empty($httpData->emailServiceAccount) ? $pmGoogle->getServiceAccountEmail() : $httpData->emailServiceAccount;
|
||||||
if ($result->typeAuth == 'webApplication') {
|
$result->pathServiceAccountCertificate = empty($_FILES['googleCertificate']['tmp_name']) ? PATH_DATA_SITE . $pmGoogle->getServiceAccountCertificate() : $_FILES['googleCertificate']['tmp_name'];
|
||||||
$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'];
|
|
||||||
}
|
|
||||||
|
|
||||||
print(G::json_encode($pmGoogle->testService($result)));
|
print(G::json_encode($pmGoogle->testService($result)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ var saveButton;
|
|||||||
var testButton;
|
var testButton;
|
||||||
var storeUsers;
|
var storeUsers;
|
||||||
var disableAll;
|
var disableAll;
|
||||||
var changeType;
|
var enableInterfazCertificate;
|
||||||
Ext.onReady(function(){
|
Ext.onReady(function() {
|
||||||
Ext.QuickTips.init();
|
Ext.QuickTips.init();
|
||||||
|
|
||||||
testButton = new Ext.Action({
|
testButton = new Ext.Action({
|
||||||
text : _('ID_TEST_CONNECTION'),
|
text : _('ID_TEST_CONNECTION'),
|
||||||
disabled : !enablePMGmail,
|
disabled : true,
|
||||||
handler : testSettings
|
handler : testSettings
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -19,58 +19,39 @@ Ext.onReady(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
disableAll = function () {
|
disableAll = function () {
|
||||||
Ext.getCmp('email_service_account').disable();
|
Ext.getCmp('emailServiceAccount').disable();
|
||||||
Ext.getCmp('file_p12').disable();
|
Ext.getCmp('googleCertificate').disable();
|
||||||
Ext.getCmp('labelFileP12').disable();
|
Ext.getCmp('labelFileGoogleCertificate').disable();
|
||||||
Ext.getCmp('file_json').disable();
|
|
||||||
Ext.getCmp('fileJson').disable();
|
|
||||||
testButton.disable();
|
testButton.disable();
|
||||||
saveButton.disable();
|
saveButton.disable();
|
||||||
|
|
||||||
Ext.getCmp('typeAuthentication').hide();
|
Ext.getCmp('emailServiceAccount').hide();
|
||||||
Ext.getCmp('email_service_account').hide();
|
Ext.getCmp('googleCertificate').hide();
|
||||||
Ext.getCmp('file_p12').hide();
|
Ext.getCmp('labelFileGoogleCertificate').hide();
|
||||||
Ext.getCmp('labelFileP12').hide();
|
|
||||||
|
|
||||||
Ext.getCmp('file_json').hide();
|
|
||||||
Ext.getCmp('fileJson').hide();
|
|
||||||
|
|
||||||
Ext.getCmp('listUsers').hide();
|
Ext.getCmp('listUsers').hide();
|
||||||
Ext.getCmp('testPMGmail').hide();
|
Ext.getCmp('testPMGmail').hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
var enableTypeP12 = function () {
|
enableInterfazCertificate = function () {
|
||||||
Ext.getCmp('email_service_account').enable();
|
Ext.getCmp('emailServiceAccount').enable();
|
||||||
Ext.getCmp('file_p12').enable();
|
Ext.getCmp('googleCertificate').enable();
|
||||||
Ext.getCmp('labelFileP12').enable();
|
Ext.getCmp('labelFileGoogleCertificate').enable();
|
||||||
|
|
||||||
Ext.getCmp('email_service_account').show();
|
Ext.getCmp('emailServiceAccount').show();
|
||||||
Ext.getCmp('file_p12').show();
|
Ext.getCmp('googleCertificate').show();
|
||||||
Ext.getCmp('labelFileP12').show();
|
Ext.getCmp('labelFileGoogleCertificate').show();
|
||||||
|
|
||||||
testButton.enable();
|
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({
|
var configurationPMGmail = new Ext.form.FieldSet({
|
||||||
title: _('ID_PMGMAIL_SETTINGS'),
|
title: _('ID_PMGMAIL_SETTINGS'),
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
id: 'status_pmgmail',
|
id: 'serviceGmailStatus',
|
||||||
name: 'status_pmgmail',
|
name: 'serviceGmailStatus',
|
||||||
boxLabel: _('ID_ENABLE_PMGMAIL'),
|
boxLabel: _('ID_ENABLE_PMGMAIL'),
|
||||||
value: 0,
|
value: 0,
|
||||||
inputValue: 1,
|
inputValue: 1,
|
||||||
@@ -79,18 +60,20 @@ Ext.onReady(function(){
|
|||||||
check : function(that, checked) {
|
check : function(that, checked) {
|
||||||
disableAll();
|
disableAll();
|
||||||
if (checked) {
|
if (checked) {
|
||||||
enableTypeP12();
|
enableInterfazCertificate();
|
||||||
} else {
|
} else {
|
||||||
Ext.MessageBox.confirm(
|
Ext.MessageBox.confirm(
|
||||||
_('ID_CONFIRM'),
|
_('ID_CONFIRM'),
|
||||||
_('ID_PMGMAIL_DISABLE'),
|
_('ID_PMGMAIL_DISABLE'),
|
||||||
function (btn, text) {
|
function (btn, text) {
|
||||||
if (btn == "yes") {
|
if (btn == "yes") {
|
||||||
saveSettings();
|
if (Ext.getCmp('serviceDriveStatus').getValue()) {
|
||||||
|
enableInterfazCertificate();
|
||||||
|
}
|
||||||
|
saveButton.enable();
|
||||||
} else {
|
} else {
|
||||||
changeType();
|
enableInterfazCertificate();
|
||||||
Ext.getCmp('status_pmgmail').setValue(1);
|
Ext.getCmp('serviceGmailStatus').setValue(1);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -99,49 +82,60 @@ Ext.onReady(function(){
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype : 'combo',
|
xtype : 'label',
|
||||||
id : 'typeAuthentication',
|
labelAlign : 'right',
|
||||||
name : 'typeAuthentication',
|
fieldLabel : '',
|
||||||
xtype : 'combo',
|
text : _('ID_GMAIL_HELP_ENABLE'),
|
||||||
fieldLabel : _('GMAIL_TYPE_AUTH'),
|
style : "padding-left:180px; display: inline-block;"
|
||||||
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 () {
|
|
||||||
disableAll();
|
|
||||||
if (Ext.getCmp('status_pmgmail').checked) {
|
|
||||||
changeType();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
select: function(combo){
|
{
|
||||||
|
xtype: 'checkbox',
|
||||||
|
id: 'serviceDriveStatus',
|
||||||
|
name: 'serviceDriveStatus',
|
||||||
|
boxLabel: _('ID_ENABLE_PMDRIVE'),
|
||||||
|
value: 0,
|
||||||
|
inputValue: 1,
|
||||||
|
uncheckedValue: 0,
|
||||||
|
listeners : {
|
||||||
|
check : function(that, checked) {
|
||||||
disableAll();
|
disableAll();
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
xtype : 'label',
|
||||||
|
labelAlign : 'right',
|
||||||
|
fieldLabel : '',
|
||||||
|
text : _('ID_DRIVE_HELP_ENABLE'),
|
||||||
|
style : "padding-left:180px; display: inline-block;"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
xtype : 'textfield',
|
xtype : 'textfield',
|
||||||
id : 'email_service_account',
|
id : 'emailServiceAccount',
|
||||||
name : 'email_service_account',
|
name : 'emailServiceAccount',
|
||||||
fieldLabel : _('ID_PMG_EMAIL'),
|
fieldLabel : _('ID_PMG_EMAIL'),
|
||||||
width : 400,
|
width : 400,
|
||||||
allowBlank : false,
|
allowBlank : false,
|
||||||
value : accountEmail,
|
value : accountEmail,
|
||||||
disabled : !enablePMGmail,
|
|
||||||
listeners : {
|
listeners : {
|
||||||
change: function(){
|
change: function(){
|
||||||
changeSettings();
|
changeSettings();
|
||||||
@@ -157,49 +151,12 @@ Ext.onReady(function(){
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype : 'fileuploadfield',
|
xtype : 'fileuploadfield',
|
||||||
id : 'file_p12',
|
id : 'googleCertificate',
|
||||||
emptyText : _('ID_PMG_SELECT_FILE'),
|
emptyText : _('ID_PMG_SELECT_FILE'),
|
||||||
fieldLabel : _('ID_PMG_FILE'),
|
fieldLabel : _('ID_PMG_FILE'),
|
||||||
name : 'file_p12',
|
name : 'googleCertificate',
|
||||||
buttonText : '',
|
buttonText : '',
|
||||||
width : 400,
|
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 : {
|
buttonCfg : {
|
||||||
iconCls : 'upload-icon'
|
iconCls : 'upload-icon'
|
||||||
},
|
},
|
||||||
@@ -219,11 +176,11 @@ Ext.onReady(function(){
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype : 'label',
|
xtype : 'label',
|
||||||
id : 'fileJson',
|
id : 'labelFileGoogleCertificate',
|
||||||
name : 'fileJson',
|
name : 'labelFileGoogleCertificate',
|
||||||
labelAlign : 'right',
|
labelAlign : 'right',
|
||||||
fieldLabel : '',
|
fieldLabel : '',
|
||||||
text : fileJson,
|
text : googleCertificate,
|
||||||
width : 400,
|
width : 400,
|
||||||
style : "padding-left:180px;"
|
style : "padding-left:180px;"
|
||||||
}
|
}
|
||||||
@@ -350,12 +307,14 @@ Ext.onReady(function(){
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.getCmp('status_pmgmail').checked = enablePMGmail;
|
Ext.getCmp('serviceGmailStatus').checked = statusGmail;
|
||||||
Ext.getCmp('status_pmgmail').setValue(enablePMGmail);
|
Ext.getCmp('serviceGmailStatus').setValue(statusGmail);
|
||||||
Ext.getCmp('typeAuthentication').setValue('serviceAccount');
|
Ext.getCmp('serviceDriveStatus').checked = statusDrive;
|
||||||
if (enablePMGmail){
|
Ext.getCmp('serviceDriveStatus').setValue(statusDrive);
|
||||||
changeType();
|
if (statusGmail || statusDrive){
|
||||||
|
enableInterfazCertificate();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var testSettings = function ()
|
var testSettings = function ()
|
||||||
@@ -422,7 +381,7 @@ var saveSettings = function ()
|
|||||||
var changeSettings = function()
|
var changeSettings = function()
|
||||||
{
|
{
|
||||||
disableAll();
|
disableAll();
|
||||||
if (Ext.getCmp('status_pmgmail').checked) {
|
if (Ext.getCmp('serviceGmailStatus').checked || Ext.getCmp('serviceDriveStatus').checked) {
|
||||||
changeType();
|
enableInterfazCertificate();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user