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;
}
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'] != '') {
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'];
}
} if ($_FILES['file_json']['error'] != 1) {
} 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']);
@@ -99,7 +99,6 @@ class pmGmail extends Controller
$result->typeAuth = empty($httpData->typeAuth) ? $pmGoogle->getTypeAuthentication() : $httpData->typeAuth;
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'];
} else {
$result->emailServiceAccount = empty($httpData->email_service_account) ? $pmGoogle->getServiceAccountEmail() : $httpData->email_service_account;

View File

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