diff --git a/gulliver/js/maborak/core/maborak.loader.js b/gulliver/js/maborak/core/maborak.loader.js index 130f00ce3..f6c5d0b92 100644 --- a/gulliver/js/maborak/core/maborak.loader.js +++ b/gulliver/js/maborak/core/maborak.loader.js @@ -66,15 +66,15 @@ if(this.options.control.resize) else {this.parent.dom.setStyle(this.elements.resize,{background:"transparent"});}};this.makeTab=function(dynamic) {if(this.loading===true){return false;} -var thm=this.tab.display==="vertical"?"":"H";var tb=this.elements.tabOptions[this.tabSelected];tb.className="panel_tabOptionSelected"+thm+"___"+this.getTheme("tabOptionSelected");tb.onmouseover=function(o,j){o=window.event?o:j;o.a.className=o.b;}.args({a:tb,b:"panel_tabOptionSelectedOver"+thm+"___"+this.getTheme("tabOptionSelectedOver")});tb.onmouseout=function(o,j){o=window.event?o:j;o.a.className=o.b;}.args({a:tb,b:"panel_tabOptionSelected"+thm+"___"+this.getTheme("tabOptionSelected")});var tc=(typeof this.tab.options[this.tabSelected].content);if(!dynamic) +var thm=this.tab.display==="vertical"?"":"H";var tb=this.elements.tabOptions[this.tabSelected];tb.className="panel_tabOptionSelected"+thm+"___"+this.getTheme("tabOptionSelected");tb.onmouseover=function(o,j){o=window.event?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?j:o):j;o.a.className=o.b;}.args({a:tb,b:"panel_tabOptionSelectedOver"+thm+"___"+this.getTheme("tabOptionSelectedOver")});tb.onmouseout=function(o,j){o=window.event?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?j:o):j;o.a.className=o.b;}.args({a:tb,b:"panel_tabOptionSelected"+thm+"___"+this.getTheme("tabOptionSelected")});var tc=(typeof this.tab.options[this.tabSelected].content);if(!dynamic) {if(this.tab.display==="vertical") -{var hj=(parseInt(this.parent.dom.getStyle(tb,"width"),10)-((!this.parent.browser.isIE)?3:0));this.parent.dom.setStyle(tb,{width:hj,borderLeftWidth:4});} +{var hj=(parseInt(this.parent.dom.getStyle(tb,"width"),10)-((!this.parent.browser.isIE)?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?0:3):0));this.parent.dom.setStyle(tb,{width:hj,borderLeftWidth:4});} else {this.parent.dom.setStyle(tb,{});}} tb.onmouseup=function(){return false;};if(this.tabLastSelected!==false) -{var tls=this.elements.tabOptions[this.tabLastSelected];tls.className="panel_tabOption"+thm+"___"+this.getTheme("tabOption");tls.onmouseover=function(o,j){o=window.event?o:j;o.a.className=o.b;}.args({a:tls,b:"panel_tabOptionOver"+thm+"___"+this.getTheme("tabOptionOver")});tls.onmouseout=function(o,j){o=window.event?o:j;o.a.className=o.b;}.args({a:tls,b:"panel_tabOption"+thm+"___"+this.getTheme("tabOption")});tls.onmouseup=function(event,tabID){if(this.tab.manualDisabled){return false;} -this.tabSelected=(this.parent.browser.isIE)?event:tabID;this.makeTab();return false;}.extend(this,this.tabLastSelected);if(this.tab.display==="vertical") -{this.parent.dom.setStyle(tls,{width:parseInt(this.parent.dom.getStyle(tb,"width"),10)+((!this.parent.browser.isIE)?3:0),borderLeftWidth:1});} +{var tls=this.elements.tabOptions[this.tabLastSelected];tls.className="panel_tabOption"+thm+"___"+this.getTheme("tabOption");tls.onmouseover=function(o,j){o=window.event?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?j:o):j;o.a.className=o.b;}.args({a:tls,b:"panel_tabOptionOver"+thm+"___"+this.getTheme("tabOptionOver")});tls.onmouseout=function(o,j){o=window.event?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?j:o):j;o.a.className=o.b;}.args({a:tls,b:"panel_tabOption"+thm+"___"+this.getTheme("tabOption")});tls.onmouseup=function(event,tabID){if(this.tab.manualDisabled){return false;} +this.tabSelected=(this.parent.browser.isIE)?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?tabID:event):tabID;this.makeTab();return false;}.extend(this,this.tabLastSelected);if(this.tab.display==="vertical") +{this.parent.dom.setStyle(tls,{width:parseInt(this.parent.dom.getStyle(tb,"width"),10)+((!this.parent.browser.isIE)?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?0:3):0),borderLeftWidth:1});} else {this.parent.dom.setStyle(tls,{});} this.parent.dom.setStyle(tls,this.setStyle.tabOption||{});} @@ -175,7 +175,7 @@ else if(this.options.strict_position) {this.options.position.x=(this.options.position.x<0)?0:this.options.position.x;this.options.position.y=(this.options.position.y<0)?0:this.options.position.y;} this.zIndex=this.options.zIndex||this.makezIndex();this.parent.dom.setStyle(this.elements.containerWindow,{width:this.options.size.w,height:this.options.size.h,position:"absolute",left:this.options.position.x,top:this.options.position.y,opacity:this.styles.fx.opacityPanel.Static/100,filter:"alpha(opacity="+this.styles.fx.opacityPanel.Static+")",zIndex:this.zIndex});this.parent.dom.setStyle(this.elements.containerWindow,this.setStyle.containerWindow||{});},frontend:function() -{this.parent.dom.setStyle(this.elements.frontend,{width:(this.parent.browser.isIE)?"auto":"100%"});this.parent.dom.setStyle(this.elements.frontend,this.setStyle.frontend||{});},backend:function() +{this.parent.dom.setStyle(this.elements.frontend,{width:(this.parent.browser.isIE)?((!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))?"100%":"auto"):"100%"});this.parent.dom.setStyle(this.elements.frontend,this.setStyle.frontend||{});},backend:function() {this.parent.dom.setStyle(this.elements.backend,{});this.parent.dom.setStyle(this.elements.backend,this.setStyle.backend||{});},loader:function() {this.parent.dom.setStyle(this.elements.loader,{background:"url('/images/classic/loader_B.gif')",backgroundRepeat:"no-repeat",width:32,height:32,position:"absolute",display:"none"});this.parent.dom.setStyle(this.elements.loader,this.setStyle.loader||{});},iframe:function() {this.parent.dom.setStyle(this.elements.iframe,{});this.parent.dom.setStyle(this.elements.iframe,this.setStyle.iframe||{});},titleBar:function() @@ -186,18 +186,19 @@ this.zIndex=this.options.zIndex||this.makezIndex();this.parent.dom.setStyle(this {this.parent.dom.setStyle(this.elements.close,{height:this.controlSize.h,right:this.controlPosition(),width:this.controlSize.w});this.parent.dom.setStyle(this.elements.close,this.setStyle.close||{});this.parent.event.add(this.elements.close,"mouseup",this.remove,false);},headerBar:function() {this.parent.dom.setStyle(this.elements.headerBar,{display:((!this.options.headerBar)?"none":"block")});this.parent.dom.setStyle(this.elements.headerBar,this.setStyle.headerBar||{});},shadow:function() {this.parent.dom.setStyle(this.elements.shadow,{width:this.elements.containerWindow.offsetWidth,height:this.elements.containerWindow.offsetHeight,top:(parseInt(this.parent.dom.getStyle(this.elements.containerWindow,"top"),10)+2),left:(parseInt(this.parent.dom.getStyle(this.elements.containerWindow,"left"),10)+2),opacity:this.styles.fx.opacityShadow.Static/100,filter:"alpha(opacity="+this.styles.fx.opacityShadow.Static+")",zIndex:this.zIndex-2});this.parent.dom.setStyle(this.elements.shadow,this.setStyle.shadow||{});},modal:function() -{var ps=[this.parent.dom.get_doc().scrollWidth,this.parent.dom.get_doc().scrollHeight];this.parent.dom.setStyle(this.elements.modal,{height:ps[1],width:ps[0],position:"absolute",zIndex:this.zIndex-3});if(this.options.fx.fadeIn===true) +{var ps=[this.parent.dom.get_doc().scrollWidth,this.parent.dom.get_doc().scrollHeight];this.parent.dom.setStyle(this.elements.modal,{height:ps[1],width:ps[0],position:"absolute",zIndex:this.zIndex-3});if(!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)){this.parent.dom.setStyle(this.elements.modal,{opacity:this.styles.fx.opacityShadow.Static/100});} +if(this.options.fx.fadeIn===true) {new this.parent.module.fx.fade().make({duration:1000,end:this.styles.fx.opacityModal.Static/100,dom:this.elements.modal});} else {this.parent.dom.opacity(this.elements.modal,this.styles.fx.opacityModal.Static);} this.parent.dom.setStyle(this.elements.modal,this.setStyle.modal||{});},tab:function() {this.tab={display:"horizontal",initIn:20,step:5,optHeight:20,widthFixed:true,optWidth:this.tab.width-4}.concatMaborak(this.tab);var thm=this.tab.display==="vertical"?"":"H";var heightContent=this.options.size.h-(this.elements.titleBar.offsetHeight+this.elements.statusBar.offsetHeight);var beginTop=this.elements.titleBar.offsetHeight+this.elements.headerBar.offsetHeight;var beginLeft=4;var space=this.spaceOutPanel();this.tab.width=(this.tab.display==="vertical")?((this.tab.options)?((this.tab.width)?this.tab.width:80):0):4;this.parent.dom.setStyle(this.elements.tab,this.setStyle.tab||{});if(this.tab.options) -{this.parent.dom.setStyle(this.elements.tab,{height:((this.tab.display==="vertical")?heightContent:this.tab.optHeight+4+(this.parent.browser.isIE?14:0)),width:((this.tab.display==="vertical")?this.tab.width:this.options.size.w-8),top:beginTop,left:((this.tab.display==="vertical")?0:4)});this.tabSelected=false;this.tabLastSelected=false;this.tab.diffWidthBugPadding=((this.parent.browser.isIE)?0:20);this.elements.tabOptions=[];var lastBul=0;for(var i=0;i-1)&&(window.location.href.indexOf('?TYPE=OUTPUT_DOCUMENT&UID=')>-1)&&(window.location.href.indexOf('&ACTION=VIEW&')>-1)&&(window.location.href.indexOf('&DOC='+APP_DOC_UID)>-1)){window.location=getField('DYN_FORWARD');} else{cases_AllOutputdocsList.refresh();}}.extend(this);oRPC.make();}.extend(this)});};var resendMessage=function(APP_UID,APP_MSG_UID) {new leimnud.module.app.confirm().make({label:G_STRINGS.ID_MSG_CONFIRM_RESENDMSG,action:function(){var oRPC=new leimnud.module.rpc.xmlhttp({url:'cases_Ajax',args:'action=resendMessage&APP_UID='+APP_UID+'&APP_MSG_UID='+APP_MSG_UID});oRPC.callback=function(rpc){messagesListPanel.clearContent();messagesListPanel.loader.show();var oRPC2=new leimnud.module.rpc.xmlhttp({url:'cases_Ajax',args:'action=showHistoryMessages'});oRPC2.callback=function(rpc){messagesListPanel.loader.hide();var scs=rpc.xmlhttp.responseText.extractScript();messagesListPanel.addContent(rpc.xmlhttp.responseText);scs.evalScript();}.extend(this);oRPC2.make();}.extend(this);oRPC.make();}.extend(this)});};function showdebug() -{if(typeof parent!='undefined'&&typeof parent.parent!='undefined'){if(typeof parent.parent.Ext!='undefined'){if(!parent.parent.PANEL_EAST_OPEN){var debugPanel=parent.parent.Ext.getCmp('debugPanel');parent.parent.PANEL_EAST_OPEN=true;debugPanel.show();debugPanel.ownerCt.doLayout();debugPanel.expand();} -parent.parent.propStore.load();parent.parent.triggerStore.load();}}} +{try{if(typeof(parent)!="undefined"&&typeof(parent.parent)!="undefined"&&typeof(parent.parent.Ext)!="undefined"){if(!parent.parent.PANEL_EAST_OPEN){var debugPanel=parent.parent.Ext.getCmp("debugPanel");parent.parent.PANEL_EAST_OPEN=true;debugPanel.show();debugPanel.ownerCt.doLayout();debugPanel.expand();} +parent.parent.propStore.load();parent.parent.triggerStore.load();}}catch(e){}} var uploadInputDocument=function(docID,appDocId,docVersion,actionType){if(actionType){if(actionType=="R"){windowTitle=G_STRINGS.ID_UPLOAD_REPLACE_INPUT;} if(actionType=="NV"){windowTitle=G_STRINGS.ID_UPLOAD_NEW_INPUT_VERSION;}}else{windowTitle=G_STRINGS.ID_UPLOAD_NEW_INPUT;docVersion=1;actionType="";appDocId="";} oPanel=new leimnud.module.panel();oPanel.options={size:{w:550,h:355},position:{x:0,y:0,center:true},title:windowTitle,theme:"processmaker",statusBar:false,control:{resize:true,roll:false},fx:{modal:true,opacity:true,blinkToFront:true,fadeIn:false}};oPanel.events={remove:function(){delete(oPanel);}.extend(this)};oPanel.make();oPanel.loader.show();var oRPC=new leimnud.module.rpc.xmlhttp({url:'cases_Ajax',args:"action=uploadInputDocument&docID="+docID+"&appDocId="+appDocId+"&docVersion="+docVersion+"&actionType="+actionType});oRPC.callback=function(rpc){oPanel.loader.hide();var scs=rpc.xmlhttp.responseText.extractScript();oPanel.addContent(rpc.xmlhttp.responseText);scs.evalScript();}.extend(this);oRPC.make();};var uploadToReviseInputDocument=function(docID,appDocId,docVersion,actionType){if(actionType){if(actionType=="R"){windowTitle=G_STRINGS.ID_UPLOAD_REPLACE_INPUT;} diff --git a/workflow/engine/classes/class.pmGoogleApi.php b/workflow/engine/classes/class.pmGoogleApi.php index e55212807..acfb115e0 100755 --- a/workflow/engine/classes/class.pmGoogleApi.php +++ b/workflow/engine/classes/class.pmGoogleApi.php @@ -16,6 +16,12 @@ class PMGoogleApi private $domain; private $user; + private $typeAuthentication; + private $clientId; + private $clientSecret; + private $redirectUrl = 'http://localhost/index.html'; + private $accountJson; + public function __construct() { $licensedFeatures = &PMLicensedFeatures::getSingleton(); @@ -114,6 +120,81 @@ class PMGoogleApi return $this->domain; } + public function setTypeAuthentication($type) + { + $conf = $this->getConfigGmail(); + + $conf->aConfig['typeAuthentication'] = $type; + $conf->saveConfig('GOOGLE_API_SETTINGS', '', '', ''); + + $this->typeAuthentication = $type; + } + + public function getTypeAuthentication() + { + return $this->typeAuthentication; + } + + public function setAccountJson($accountJson) + { + $conf = $this->getConfigGmail(); + + $conf->aConfig['accountJson'] = $accountJson; + $conf->saveConfig('GOOGLE_API_SETTINGS', '', '', ''); + + $this->accountJson = $accountJson; + } + + public function getAccountJson() + { + return $this->accountJson; + } + + public function setClientId($clientId) + { + $conf = $this->getConfigGmail(); + + $conf->aConfig['clientId'] = $clientId; + $conf->saveConfig('GOOGLE_API_SETTINGS', '', '', ''); + + $this->clientId = $clientId; + } + + public function getClientId() + { + return $this->clientId; + } + + public function setClientSecret($clientSecret) + { + $conf = $this->getConfigGmail(); + + $conf->aConfig['clientSecret'] = $clientSecret; + $conf->saveConfig('GOOGLE_API_SETTINGS', '', '', ''); + + $this->clientSecret = $clientSecret; + } + + public function getClientSecret() + { + return $this->clientSecret; + } + + public function setRedirectUrl($redirectUrl) + { + $conf = $this->getConfigGmail(); + + $conf->aConfig['redirectUrl'] = $redirectUrl; + $conf->saveConfig('GOOGLE_API_SETTINGS', '', '', ''); + + $this->redirectUrl = $redirectUrl; + } + + public function getRedirectUrl() + { + return $this->redirectUrl; + } + /** * load configuration gmail service account * @@ -122,11 +203,25 @@ class PMGoogleApi { $conf = $this->getConfigGmail(); - $serviceAccountP12 = empty($conf->aConfig['serviceAccountP12']) ? '' : $conf->aConfig['serviceAccountP12']; - $serviceAccountEmail = empty($conf->aConfig['serviceAccountEmail']) ? '' : $conf->aConfig['serviceAccountEmail']; - $statusService = empty($conf->aConfig['statusService']) ? '' : $conf->aConfig['statusService']; + $typeAuthentication = empty($conf->aConfig['typeAuthentication']) ? '' : $conf->aConfig['typeAuthentication']; + $clientId = empty($conf->aConfig['clientId']) ? '' : $conf->aConfig['clientId']; + $clientSecret = empty($conf->aConfig['clientSecret']) ? '' : $conf->aConfig['clientSecret']; + $redirectUrl = empty($conf->aConfig['redirectUrl']) ? 'http://localhost/index.html' : $conf->aConfig['redirectUrl']; + + $accountJson = empty($conf->aConfig['accountJson']) ? '' : $conf->aConfig['accountJson']; + $serviceAccountP12 = empty($conf->aConfig['serviceAccountP12']) ? '' : $conf->aConfig['serviceAccountP12']; + $serviceAccountEmail = empty($conf->aConfig['serviceAccountEmail']) ? '' : $conf->aConfig['serviceAccountEmail']; + $statusService = empty($conf->aConfig['statusService']) ? '' : $conf->aConfig['statusService']; $this->scope = array(); + + $this->setRedirectUrl($accountJson); + $this->setTypeAuthentication($typeAuthentication); + //$this->setClientId($clientId); + //$this->setClientSecret($clientSecret); + $this->setAccountJson($accountJson); + $this->setRedirectUrl($redirectUrl); + $this->setServiceAccountEmail($serviceAccountEmail); $this->setServiceAccountP12($serviceAccountP12); $this->setStatusService($statusService); @@ -139,18 +234,39 @@ class PMGoogleApi */ public function serviceClient() { - $key = file_get_contents(PATH_DATA_SITE . $this->serviceAccountP12); + $client = null; + if ($this->getTypeAuthentication == 'webApplication') { + $key = file_get_contents(PATH_DATA_SITE . $this->accountJson); - $assertionCredentials = new Google_Auth_AssertionCredentials( - $this->serviceAccountEmail, - $this->scope, - $key - ); - $assertionCredentials->sub = $this->user; + $client = new Google_Client(); + $client->setAuthConfig($key); + $client->setRedirectUri($this->redirectUrl); - $client = new Google_Client(); - $client->setApplicationName("PMDrive"); - $client->setAssertionCredentials($assertionCredentials); + if (!empty($_SESSION['google_token'])) { + $client->setAccessToken($_SESSION['google_token']); + if ($client->isAccessTokenExpired()) { + unset($_SESSION['google_token']); + } + } else { + $authUrl = $client->createAuthUrl(); + print_r($authUrl); + } + } else if ($this->getTypeAuthentication == 'serviceAccount') { + $key = file_get_contents(PATH_DATA_SITE . $this->serviceAccountP12); + + $assertionCredentials = new Google_Auth_AssertionCredentials( + $this->serviceAccountEmail, + $this->scope, + $key + ); + $assertionCredentials->sub = $this->user; + + $client = new Google_Client(); + $client->setApplicationName("PMDrive"); + $client->setAssertionCredentials($assertionCredentials); + } else { + throw new Exception(G::LoadTranslation('ID_SERVER_COMMUNICATION_ERROR')); + } return $client; } diff --git a/workflow/engine/controllers/pmGmail.php b/workflow/engine/controllers/pmGmail.php index fc4e088d1..3471c7859 100644 --- a/workflow/engine/controllers/pmGmail.php +++ b/workflow/engine/controllers/pmGmail.php @@ -20,6 +20,9 @@ class pmGmail extends Controller $httpData->status_pmgmail = $httpData->status_pmgmail == 1 ? true : false; $pmGoogle->setStatusService($httpData->status_pmgmail); $message = G::LoadTranslation('ID_ENABLE_PMGMAIL') . ': ' . ($httpData->status_pmgmail ? G::LoadTranslation('ID_ENABLE') : G::LoadTranslation('ID_DISABLE')); + + $pmGoogle->setTypeAuthentication($httpData->typeAuth); + if (!empty($httpData->email_service_account)) { $pmGoogle->setServiceAccountEmail($httpData->email_service_account); $message .= ', ' . G::LoadTranslation('ID_PMG_EMAIL') . ': ' . $httpData->email_service_account; @@ -31,6 +34,12 @@ class pmGmail extends Controller $pmGoogle->setServiceAccountP12($_FILES['file_p12']['name']); $message .= ', ' . G::LoadTranslation('ID_PMG_FILE') . ': ' . $_FILES['file_p12']['name']; } + } if ($_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 { $result->success = false; $result->fileError = true; @@ -59,11 +68,16 @@ class pmGmail extends Controller $pmGoogle = new PMGoogleApi(); $accountEmail = $pmGoogle->getServiceAccountEmail(); $fileP12 = $pmGoogle->getServiceAccountP12(); + $fileJson = $pmGoogle->getAccountJson(); + $fileJson = $fileJson == null ? '' : $fileJson; + $type = $pmGoogle->getTypeAuthentication(); $enablePMGmail = $pmGoogle->getStatusService(); $this->setJSVar('accountEmail', $accountEmail); $this->setJSVar('fileP12', $fileP12); $this->setJSVar('enablePMGmail', $enablePMGmail); + $this->setJSVar('fileJson', $fileJson); + $this->setJSVar('typeAuthentication', $type); G::RenderPage('publish', 'extJs'); diff --git a/workflow/engine/templates/admin/pmGmail.js b/workflow/engine/templates/admin/pmGmail.js index 40d900389..aa1482e68 100644 --- a/workflow/engine/templates/admin/pmGmail.js +++ b/workflow/engine/templates/admin/pmGmail.js @@ -43,11 +43,17 @@ Ext.onReady(function(){ 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(); @@ -60,6 +66,62 @@ Ext.onReady(function(){ } } }, + { + xtype : 'combo', + id : 'typeAuthentication', + name : 'typeAuthentication', + xtype : 'combo', + fieldLabel : _('GMAIL_TYPE_AUTH'), + //typeAhead : false, + hiddenName: 'typeAuth', + mode : 'local', + triggerAction : 'all', + forceSelection: true, + store: new Ext.data.SimpleStore({ + fields: ['value','type'], + data: [['webApplication','Web Application'],['serviceAccount', 'Service Account']], + autoLoad: true + }), + submitValue : true, + value: typeAuthentication, + valueField: 'value', + displayField: 'type', + width: 250, + 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(); + } + }, + select: function(combo){ + 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(); + } + } + } + }, { xtype : 'textfield', id : 'email_service_account', @@ -110,11 +172,49 @@ Ext.onReady(function(){ }, { 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' + }, + listeners:{ + change : function(){ + changeSettings(); + }, + afterrender:function(cmp){ + changeSettings(); + cmp.fileInput.set({ + accept:'*/json' + }); + } + }, + regex : /(.)+((\.json)(\w)?)$/i, + regexText : _('ID_PMG_TYPE_ACCEPT') + }, + { + xtype : 'label', + id : 'fileJson', + name : 'fileJson', + labelAlign : 'right', + fieldLabel : '', + text : fileJson, + width : 400, + style : "padding-left:180px;" } ] }); diff --git a/workflow/public_html/pmGmail/sso.php b/workflow/public_html/pmGmail/sso.php index 2d371bf64..65e88c50e 100644 --- a/workflow/public_html/pmGmail/sso.php +++ b/workflow/public_html/pmGmail/sso.php @@ -16,6 +16,7 @@ $gCurl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegrat curl_setopt( $gCurl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) ); curl_setopt( $gCurl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $gCurl, CURLOPT_SSL_VERIFYPEER, false); +curl_setopt( $gCurl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt( $gCurl, CURLOPT_CONNECTTIMEOUT, 0); $gCurl_response = curl_exec( $gCurl ); @@ -33,6 +34,7 @@ $curl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegrati curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER,false); +curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0); $curl_response = curl_exec( $curl ); @@ -54,6 +56,7 @@ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp $optArray = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYHOST, false, CURLOPT_SSL_VERIFYPEER => false ); // apply those options @@ -68,8 +71,8 @@ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp //If the email corresponds I get the username and with the gmail user_id the session is created. if($decodedResp['0']->USR_STATUS == "ACTIVE"){ //User Active! lets create the Session - @session_destroy(); - session_start(); + @session_destroy(); + session_start(); session_regenerate_id(); if (PHP_VERSION < 5.2) { @@ -78,17 +81,17 @@ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp setcookie("workspaceSkin", "neoclasic", time() + (24 * 60 * 60), "/sys" . "neoclasic", null, false, true); } - $_SESSION = array(); - $_SESSION['__EE_INSTALLATION__'] = 2; - $_SESSION['__EE_SW_PMLICENSEMANAGER__'] = 1; - $_SESSION['phpLastFileFound'] = ''; - $_SESSION['USERNAME_PREVIOUS1'] = 'admin'; - $_SESSION['USERNAME_PREVIOUS2'] = 'admin'; - $_SESSION['WORKSPACE'] = $pmws; - $_SESSION['USER_LOGGED'] = $decodedResp['0']->USR_UID; - $_SESSION['USR_USERNAME'] = $decodedResp['0']->USR_USERNAME; - $_SESSION['USR_FULLNAME'] = $decodedResp['0']->USR_FIRSTNAME. ' ' .$decodedResp['0']->USR_LASTNAME; - $_SESSION['__sw__'] = 1; + $_SESSION = array(); + $_SESSION['__EE_INSTALLATION__'] = 2; + $_SESSION['__EE_SW_PMLICENSEMANAGER__'] = 1; + $_SESSION['phpLastFileFound'] = ''; + $_SESSION['USERNAME_PREVIOUS1'] = 'admin'; + $_SESSION['USERNAME_PREVIOUS2'] = 'admin'; + $_SESSION['WORKSPACE'] = $pmws; + $_SESSION['USER_LOGGED'] = $decodedResp['0']->USR_UID; + $_SESSION['USR_USERNAME'] = $decodedResp['0']->USR_USERNAME; + $_SESSION['USR_FULLNAME'] = $decodedResp['0']->USR_FIRSTNAME. ' ' .$decodedResp['0']->USR_LASTNAME; + $_SESSION['__sw__'] = 1; //session created } else { echo Bootstrap::LoadTranslation( 'ID_USER_NOT_ACTIVE' ); @@ -107,6 +110,7 @@ if ($action == "draft"){ curl_setopt( $curlApp, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt( $curlApp, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curlApp, CURLOPT_SSL_VERIFYPEER,false); + curl_setopt( $curlApp, CURLOPT_SSL_VERIFYHOST, false); curl_setopt( $curlApp, CURLOPT_CONNECTTIMEOUT, 0); $curl_response_app = curl_exec( $curlApp );