GI-168 Se quedan los datos cacheados cuando deshabilitas SOLVED

- Add validation to enable and disable gmail
This commit is contained in:
Marco A. Nina Mena
2015-11-30 12:41:32 -04:00
parent ea99bb3a32
commit abf98a8dc8
2 changed files with 74 additions and 53 deletions

View File

@@ -28,13 +28,13 @@ class pmGmail extends Controller
$message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->email_service_account; $message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->email_service_account;
} }
if (!empty($_FILES)) { if (!empty($_FILES)) {
if ($_FILES['file_p12']['error'] != 1) { if (!empty($_FILES['file_p12']) && $_FILES['file_p12']['error'] != 1) {
if ($_FILES['file_p12']['tmp_name'] != '') { if ($_FILES['file_p12']['tmp_name'] != '') {
G::uploadFile($_FILES['file_p12']['tmp_name'], PATH_DATA_SITE, $_FILES['file_p12']['name']); G::uploadFile($_FILES['file_p12']['tmp_name'], PATH_DATA_SITE, $_FILES['file_p12']['name']);
$pmGoogle->setServiceAccountP12($_FILES['file_p12']['name']); $pmGoogle->setServiceAccountP12($_FILES['file_p12']['name']);
$message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_p12']['name']; $message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_p12']['name'];
} }
} if ($_FILES['file_json']['error'] != 1) { } else if (!empty($_FILES['file_json']) && $_FILES['file_json']['error'] != 1) {
if ($_FILES['file_json']['tmp_name'] != '') { if ($_FILES['file_json']['tmp_name'] != '') {
G::uploadFile($_FILES['file_json']['tmp_name'], PATH_DATA_SITE, $_FILES['file_json']['name']); G::uploadFile($_FILES['file_json']['tmp_name'], PATH_DATA_SITE, $_FILES['file_json']['name']);
$pmGoogle->setAccountJson($_FILES['file_json']['name']); $pmGoogle->setAccountJson($_FILES['file_json']['name']);
@@ -99,7 +99,6 @@ class pmGmail extends Controller
$result->typeAuth = empty($httpData->typeAuth) ? $pmGoogle->getTypeAuthentication() : $httpData->typeAuth; $result->typeAuth = empty($httpData->typeAuth) ? $pmGoogle->getTypeAuthentication() : $httpData->typeAuth;
if ($result->typeAuth == 'webApplication') { if ($result->typeAuth == 'webApplication') {
$result->redirectUrl = $pmGoogle->getRedirectUrl();
$result->pathFileJson = empty($_FILES['file_json']['tmp_name']) ? PATH_DATA_SITE . $pmGoogle->getAccountJson() : $_FILES['file_json']['tmp_name']; $result->pathFileJson = empty($_FILES['file_json']['tmp_name']) ? PATH_DATA_SITE . $pmGoogle->getAccountJson() : $_FILES['file_json']['tmp_name'];
} else { } else {
$result->emailServiceAccount = empty($httpData->email_service_account) ? $pmGoogle->getServiceAccountEmail() : $httpData->email_service_account; $result->emailServiceAccount = empty($httpData->email_service_account) ? $pmGoogle->getServiceAccountEmail() : $httpData->email_service_account;

View File

@@ -1,6 +1,8 @@
var saveButton; var saveButton;
var testButton; var testButton;
var storeUsers; var storeUsers;
var disableAll;
var changeType;
Ext.onReady(function(){ Ext.onReady(function(){
Ext.QuickTips.init(); Ext.QuickTips.init();
@@ -16,6 +18,62 @@ Ext.onReady(function(){
handler : saveSettings handler : saveSettings
}); });
disableAll = function () {
Ext.getCmp('typeAuthentication').disable();
Ext.getCmp('email_service_account').disable();
Ext.getCmp('file_p12').disable();
Ext.getCmp('labelFileP12').disable();
Ext.getCmp('file_json').disable();
Ext.getCmp('fileJson').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('listUsers').hide();
Ext.getCmp('testPMGmail').hide();
};
var enableTypeP12 = function () {
Ext.getCmp('typeAuthentication').enable();
Ext.getCmp('email_service_account').enable();
Ext.getCmp('file_p12').enable();
Ext.getCmp('labelFileP12').enable();
Ext.getCmp('typeAuthentication').show();
Ext.getCmp('email_service_account').show();
Ext.getCmp('file_p12').show();
Ext.getCmp('labelFileP12').show();
testButton.enable();
};
var enableTypeJson = function () {
Ext.getCmp('typeAuthentication').enable();
Ext.getCmp('file_json').enable();
Ext.getCmp('fileJson').enable();
Ext.getCmp('typeAuthentication').show();
Ext.getCmp('file_json').show();
Ext.getCmp('fileJson').show();
testButton.enable();
};
changeType = function () {
var type = Ext.getCmp('typeAuthentication').getValue();
if (type == 'webApplication') {
enableTypeJson();
} else {
enableTypeP12();
}
};
var configurationPMGmail = new Ext.form.FieldSet({ var configurationPMGmail = new Ext.form.FieldSet({
title: _('ID_PMGMAIL_SETTINGS'), title: _('ID_PMGMAIL_SETTINGS'),
items: [ items: [
@@ -29,34 +87,19 @@ Ext.onReady(function(){
uncheckedValue: 0, uncheckedValue: 0,
listeners : { listeners : {
check : function(that, checked) { check : function(that, checked) {
changeSettings(); disableAll();
if (checked) { if (checked) {
Ext.getCmp('email_service_account').enable(); Ext.getCmp('typeAuthentication').enable();
Ext.getCmp('status_pmgmail').enable(); Ext.getCmp('typeAuthentication').show();
Ext.getCmp('file_p12').enable();
} 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") {
Ext.getCmp('email_service_account').disable();
Ext.getCmp('file_p12').disable();
Ext.getCmp('typeAuthentication').disable();
Ext.getCmp('file_json').disable();
Ext.getCmp('fileJson').disable();
Ext.getCmp('listUsers').hide();
testButton.disable();
saveButton.disable();
saveSettings(); saveSettings();
} else { } else {
Ext.getCmp('typeAuthentication').enable(); changeType();
Ext.getCmp('file_json').enable();
Ext.getCmp('fileJson').enable();
Ext.getCmp('status_pmgmail').enable();
Ext.getCmp('email_service_account').enable();
Ext.getCmp('file_p12').enable();
Ext.getCmp('status_pmgmail').setValue(1); Ext.getCmp('status_pmgmail').setValue(1);
return false; return false;
} }
@@ -89,36 +132,14 @@ Ext.onReady(function(){
editable: false, editable: false,
listeners:{ listeners:{
afterRender: function () { afterRender: function () {
Ext.getCmp('email_service_account').hide(); disableAll();
Ext.getCmp('file_p12').hide(); if (Ext.getCmp('status_pmgmail').checked) {
Ext.getCmp('labelFileP12').hide(); changeType();
Ext.getCmp('file_json').hide();
Ext.getCmp('fileJson').hide();
if (typeAuthentication == 'webApplication' ) {
Ext.getCmp('file_json').show();
Ext.getCmp('fileJson').show();
} else if (typeAuthentication == 'serviceAccount' ) {
Ext.getCmp('email_service_account').show();
Ext.getCmp('file_p12').show();
Ext.getCmp('labelFileP12').show();
} }
}, },
select: function(combo){ select: function(combo){
saveButton.disable(); disableAll();
var value = combo.getValue(); changeType();
if (value == 'webApplication' ) {
Ext.getCmp('email_service_account').hide();
Ext.getCmp('file_p12').hide();
Ext.getCmp('labelFileP12').hide();
Ext.getCmp('file_json').show();
Ext.getCmp('fileJson').show();
} else {
Ext.getCmp('email_service_account').show();
Ext.getCmp('file_p12').show();
Ext.getCmp('labelFileP12').show();
Ext.getCmp('file_json').hide();
Ext.getCmp('fileJson').hide();
}
} }
} }
}, },
@@ -341,6 +362,9 @@ Ext.onReady(function(){
Ext.getCmp('status_pmgmail').checked = enablePMGmail; Ext.getCmp('status_pmgmail').checked = enablePMGmail;
Ext.getCmp('status_pmgmail').setValue(enablePMGmail); Ext.getCmp('status_pmgmail').setValue(enablePMGmail);
if (enablePMGmail){
changeType();
}
}); });
var testSettings = function () var testSettings = function ()
@@ -406,10 +430,8 @@ var saveSettings = function ()
var changeSettings = function() var changeSettings = function()
{ {
Ext.getCmp('testPMGmail').hide(); disableAll();
Ext.getCmp('listUsers').hide();
if (Ext.getCmp('status_pmgmail').checked) { if (Ext.getCmp('status_pmgmail').checked) {
testButton.enable(); changeType();
} }
saveButton.disable();
}; };