diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 88e10eace..6d708d59e 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -4218,6 +4218,19 @@ class Cases $oListPaused = new ListPaused(); $oListPaused->create($data); /*----------------------------------********---------------------------------*/ + + /*----------------------------------********---------------------------------*/ + $licensedFeatures = &PMLicensedFeatures::getSingleton(); + if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) { + G::LoadClass( "pmDrive" ); + $pmDrive = new PMDrive(); + $enablePMGmail = $pmDrive->getStatusService(); + if (!empty($enablePMGmail) && $enablePMGmail == 1) { + $pmGmail = new \ProcessMaker\BusinessModel\Pmgmail(); + $pmGmail->modifyMailToPauseCase($aData['APP_UID'], $aData['APP_DEL_INDEX']); + } + } + /*----------------------------------********---------------------------------*/ } /* @@ -4314,6 +4327,19 @@ class Cases $oListPaused = new ListPaused(); $oListPaused->remove($sApplicationUID, $iDelegation, $aData); /*----------------------------------********---------------------------------*/ + + /*----------------------------------********---------------------------------*/ + $licensedFeatures = &PMLicensedFeatures::getSingleton(); + if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) { + G::LoadClass( "pmDrive" ); + $pmDrive = new PMDrive(); + $enablePMGmail = $pmDrive->getStatusService(); + if (!empty($enablePMGmail) && $enablePMGmail == 1) { + $pmGmail = new \ProcessMaker\BusinessModel\Pmgmail(); + $pmGmail->modifyMailToUnpauseCase($aData['APP_UID'], $aData['DEL_INDEX']); + } + } + /*----------------------------------********---------------------------------*/ } /* @@ -7371,5 +7397,6 @@ class Cases } return $processList; } + } diff --git a/workflow/engine/classes/class.labelsGmail.php b/workflow/engine/classes/class.labelsGmail.php index 4ec9a240a..4b01ab94c 100644 --- a/workflow/engine/classes/class.labelsGmail.php +++ b/workflow/engine/classes/class.labelsGmail.php @@ -11,7 +11,7 @@ class labelsGmail $labels = array_merge($labels, $labelsResponse->getLabels()); } } catch (Exception $e) { - print 'An error occurred: ' . $e->getMessage(); + print G::LoadTranslation("ID_PMGMAIL_GENERAL_ERROR") . $e->getMessage(); } return $labels; } @@ -33,7 +33,7 @@ class labelsGmail try { $message = $service->users_messages->modify($userId, $messageId, $mods); } catch (Exception $e) { - print 'An error occurred: ' . $e->getMessage(); + print G::LoadTranslation("ID_PMGMAIL_GENERAL_ERROR") . $e->getMessage(); } } @@ -62,14 +62,116 @@ class labelsGmail $messages = array_merge($messages, $messagesResponse->getMessages()); } } catch (Exception $e) { - print 'An error occurred: ' . $e->getMessage(); + print G::LoadTranslation("ID_PMGMAIL_GENERAL_ERROR") . $e->getMessage(); } } while ($pageToken); return $messages; } - function setLabels($caseId, $index, $actualLastIndex, $unassigned=false){ + public function setLabelsToPauseCase ($caseId, $index) { + require_once PATH_TRUNK . 'vendor' . PATH_SEP . 'google' . PATH_SEP . 'apiclient' . PATH_SEP . 'src' . PATH_SEP . 'Google' . PATH_SEP . 'autoload.php'; + require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.pmGoogleApi.php"); + + $Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail(); + $appData = $Pmgmail->getDraftApp($caseId, $index); + + foreach ($appData as $application){ + $appNumber = $application['APP_NUMBER']; + $index = $application['DEL_INDEX']; + $threadUsr = $application['USR_UID']; + $proName = $application['APP_PRO_TITLE']; + $threadStatus = $application['DEL_THREAD_STATUS']; + $appStatus = $application['APP_STATUS']; + } + + //Getting the privious User email + $oUsers = new \Users(); + $usrData = $oUsers->loadDetails($threadUsr); + $mail = $usrData['USR_EMAIL']; + + //The Subject to search the email + $subject = "[PM] " .$proName. " Case: ". $appNumber; + + $pmGoogle = new PMGoogleApi(); + $pmGoogle->setUser($mail); + $pmGoogle->setScope('https://www.googleapis.com/auth/gmail.modify'); + $client = $pmGoogle->serviceClient(); + $service = new Google_Service_Gmail($client); + $labelsIds = $this->getLabelsIds($service); + + if($appStatus == 'DRAFT'){ + $labelsToRemove = $labelsIds['Draft']; + $labelsToSearch = "*-draft"; + $labelsToAdd = $labelsIds['Paused']; + } + + if($appStatus == 'TO_DO'){ + $labelsToRemove = $labelsIds['Inbox']; + $labelsToSearch = "*-inbox"; + $labelsToAdd = $labelsIds['Paused']; + } + + $q = "subject:('".preg_quote($subject, '-')."') label:('".$labelsToSearch."')"; + $messageList = $this->listMessages($service, $mail, $q, $labelsToRemove); + foreach ($messageList as $message) { + $messageId = $message->getId(); + $modifyResult = $this->modifyMessage($service, $mail, $messageId, array($labelsToAdd), array($labelsToRemove)); + } + } + + function setLabelsTounpauseCase ($caseId, $index) { + require_once PATH_TRUNK . 'vendor' . PATH_SEP . 'google' . PATH_SEP . 'apiclient' . PATH_SEP . 'src' . PATH_SEP . 'Google' . PATH_SEP . 'autoload.php'; + require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.pmGoogleApi.php"); + + $Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail(); + $appData = $Pmgmail->getDraftApp($caseId, $index); + + foreach ($appData as $application){ + $appNumber = $application['APP_NUMBER']; + $index = $application['DEL_INDEX']; + $threadUsr = $application['USR_UID']; + $proName = $application['APP_PRO_TITLE']; + $threadStatus = $application['DEL_THREAD_STATUS']; + $appStatus = $application['APP_STATUS']; + } + + //Getting the privious User email + $oUsers = new \Users(); + $usrData = $oUsers->loadDetails($threadUsr); + $mail = $usrData['USR_EMAIL']; + + //The Subject to search the email + $subject = "[PM] " .$proName. " Case: ". $appNumber; + + $pmGoogle = new PMGoogleApi(); + $pmGoogle->setUser($mail); + $pmGoogle->setScope('https://www.googleapis.com/auth/gmail.modify'); + $client = $pmGoogle->serviceClient(); + $service = new Google_Service_Gmail($client); + $labelsIds = $this->getLabelsIds($service); + + if($appStatus == 'DRAFT'){ + $labelsToRemove = $labelsIds['Paused']; + $labelsToSearch = "*-paused"; + $labelsToAdd = $labelsIds['Draft']; + } + + if($appStatus == 'TO_DO'){ + $labelsToRemove = $labelsIds['Paused']; + $labelsToSearch = "*-paused"; + $labelsToAdd = $labelsIds['Inbox']; + } + + $q = "subject:('".preg_quote($subject, '-')."') label:('".$labelsToSearch."')"; + $messageList = $this->listMessages($service, $mail, $q, $labelsToRemove); + foreach ($messageList as $message) { + $messageId = $message->getId(); + $modifyResult = $this->modifyMessage($service, $mail, $messageId, array($labelsToAdd), array($labelsToRemove)); + } + } + + public function setLabels($caseId, $index, $actualLastIndex, $unassigned=false){ //First getting the actual thread data $Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail(); $appData = $Pmgmail->getDraftApp($caseId, $index); @@ -80,9 +182,10 @@ class labelsGmail $threadUsr = $application['USR_UID']; $proName = $application['APP_PRO_TITLE']; $threadStatus = $application['DEL_THREAD_STATUS']; + $appStatus = $application['APP_STATUS']; } - if($threadStatus == 'CLOSED' || $unassigned == true){ + if($threadStatus == 'CLOSED' || $unassigned == true) { //Getting the privious User email $oUsers = new \Users(); @@ -102,44 +205,20 @@ class labelsGmail $client = $pmGoogle->serviceClient(); $service = new Google_Service_Gmail($client); - - //getting all the label's ids of the user's mail - $listlabels = $this->listLabels($service); - - foreach ($listlabels as $label) { - $labId = $label->getId(); - $labName = $label->getName(); - switch($labName){ - case "* Inbox": - $idLabInbox = $labId; - break; - case "* Participated": - $idLabParticipated = $labId; - break; - case "* Unassigned": - $idLabUnassigned = $labId; - break; - case "* Draft": - $idLabDraft = $labId; - break; - case "* Paused": - $idLabPaused = $labId; - break; - } - } + $labelsIds = $this->getLabelsIds($service); if($actualLastIndex == 0){ - $labelsToRemove = $idLabDraft; + $labelsToRemove = $labelsIds['Draft']; $labelsToSearch = "*-draft"; - $labelsToAdd = $idLabParticipated; + $labelsToAdd = $labelsIds['Participated']; } else if ( ($actualLastIndex == -1) && ($unassigned == true) ){ //Unassigned - $labelsToRemove = $idLabUnassigned; + $labelsToRemove = $labelsIds['Unassigned']; $labelsToSearch = "*-unassigned"; - $labelsToAdd = $idLabInbox; + $labelsToAdd = $labelsIds['Inbox']; } else if($actualLastIndex >= 1) { - $labelsToRemove = $idLabInbox; + $labelsToRemove = $labelsIds['Inbox']; $labelsToSearch = "*-inbox"; - $labelsToAdd = $idLabParticipated; + $labelsToAdd = $labelsIds['Participated']; } //Searching the email in the user's mail @@ -169,7 +248,7 @@ class labelsGmail try { $service->users_labels->delete($user, $labelId); } catch (Exception $e) { - error_log('An error deleting gmail labels occurred: '.$e->getMessage()); + error_log(G::LoadTranslation("ID_PMGMAIL_GENERAL_ERROR") . $e->getMessage()); } } @@ -207,5 +286,32 @@ class labelsGmail return $count . ' labels successfully deleted.'; } + + private function getLabelsIds($service) { + $result = array(); + $listlabels = $this->listLabels($service); + foreach ($listlabels as $label) { + $labId = $label->getId(); + $labName = $label->getName(); + switch($labName){ + case "* Inbox": + $result['Inbox'] = $labId; + break; + case "* Participated": + $result['Participated'] = $labId; + break; + case "* Unassigned": + $result['Unassigned'] = $labId; + break; + case "* Draft": + $result['Draft'] = $labId; + break; + case "* Paused": + $result['Paused'] = $labId; + break; + } + } + return $result; + } } diff --git a/workflow/engine/classes/class.pmDrive.php b/workflow/engine/classes/class.pmDrive.php index cc93ec542..398764aaa 100755 --- a/workflow/engine/classes/class.pmDrive.php +++ b/workflow/engine/classes/class.pmDrive.php @@ -144,7 +144,7 @@ class PMDrive extends PMGoogleApi $createdFolder = $service->files->insert($file); } catch (Exception $e) { $createdFolder = null; - error_log ( "An error occurred: " . $e->getMessage()); + error_log ( G::LoadTranslation("ID_MSG_AJAX_FAILURE") . $e->getMessage()); } return $createdFolder; } @@ -187,7 +187,7 @@ class PMDrive extends PMGoogleApi ); } catch (Exception $e) { - error_log( "An error occurred: " . $e->getMessage()); + error_log( G::LoadTranslation("ID_MSG_AJAX_FAILURE") . $e->getMessage()); } return $createdFile; } @@ -220,13 +220,13 @@ class PMDrive extends PMGoogleApi if ($httpRequest->getResponseHttpCode() == 200) { $response = $httpRequest->getResponseBody(); } else { - error_log( "An error occurred. "); + error_log(G::LoadTranslation("ID_MSG_AJAX_FAILURE")); } } else { - error_log( "The file doesn't have any content stored on Drive."); + error_log(G::LoadTranslation("ID_PMDRIVE_NO_CONTENT_IN_FILE")); } } catch (Exception $e) { - error_log( "An error occurred: " . $e->getMessage()); + error_log( G::LoadTranslation("ID_MSG_AJAX_FAILURE") . $e->getMessage()); } return $response; } @@ -262,7 +262,7 @@ class PMDrive extends PMGoogleApi ); } catch (Exception $e) { - error_log('permission error: ' . $e->getMessage()); + error_log(G::LoadTranslation("ID_MSG_AJAX_FAILURE") . $e->getMessage()); } return $permission; } diff --git a/workflow/engine/controllers/pmGmail.php b/workflow/engine/controllers/pmGmail.php index 6fabdc108..767640f98 100644 --- a/workflow/engine/controllers/pmGmail.php +++ b/workflow/engine/controllers/pmGmail.php @@ -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; diff --git a/workflow/engine/methods/cases/casesListExtJsRedirector.php b/workflow/engine/methods/cases/casesListExtJsRedirector.php index 5aaa016f6..660dd7ff7 100755 --- a/workflow/engine/methods/cases/casesListExtJsRedirector.php +++ b/workflow/engine/methods/cases/casesListExtJsRedirector.php @@ -18,7 +18,7 @@ if (isset( $_GET['ux'] )) { default: $url = 'casesListExtJs'; } -} else if( isset( $_GET['gmail']) && !empty($enablePMGmail) && $enablePMGmail==1 ){ +} else if( key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && !empty($enablePMGmail) && $enablePMGmail==1 ){ $url = 'derivatedGmail'; } else { $url = 'casesListExtJs'; diff --git a/workflow/engine/methods/cases/casesStartPage_Ajax.php b/workflow/engine/methods/cases/casesStartPage_Ajax.php index f5554f8cc..b98077be8 100755 --- a/workflow/engine/methods/cases/casesStartPage_Ajax.php +++ b/workflow/engine/methods/cases/casesStartPage_Ajax.php @@ -261,6 +261,23 @@ function startCase () $_SESSION['CASES_REFRESH'] = true; + /*----------------------------------********---------------------------------*/ + //sending the email for gmail integration if the option es available + $licensedFeatures = &PMLicensedFeatures::getSingleton(); + if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) { + + $enablePMGmail = false; + G::LoadClass( "pmDrive" ); + $pmDrive = new PMDrive(); + $enablePMGmail = $pmDrive->getStatusService(); + if(!empty($enablePMGmail) && $enablePMGmail==1){ + require_once 'src/ProcessMaker/BusinessModel/Pmgmail.php'; + $Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail(); + $response = $Pmgmail->sendEmail($aData['APPLICATION'], "", $aData['INDEX']); + } + } + /*----------------------------------********---------------------------------*/ + $oCase = new Cases(); $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index fd1d12e6a..6afaf0d2f 100755 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -5,24 +5,27 @@ if (!isset($_SESSION['USER_LOGGED'])) { try { var olink = document.location.href; - if(olink.search("gmail") == -1){ + olink = ( olink.search("gmail") == -1 ) ? parent.document.location.href : olink; + + if(olink.search("gmail") == -1 ){ prnt = parent.parent; top.location = top.location; } else { var data = olink.split("?"); var odata = data[1].split("&"); - var appUid = odata[1].split("="); - var proUid = odata[0].split("="); - + var appUid = odata[0].split("="); + var dataToSend = { "action": "credentials", "operation": "refreshPmSession", "type": "processCall", "funParams": [ appUid[1], - proUid[1] + "" ], + "expectReturn": false }; + var x = parent.postMessage(JSON.stringify(dataToSend), "*"); if (x == undefined){ x = parent.parent.postMessage(JSON.stringify(dataToSend), "*"); diff --git a/workflow/engine/methods/cases/derivatedGmail.php b/workflow/engine/methods/cases/derivatedGmail.php index a0b2cfab9..d2fbff684 100644 --- a/workflow/engine/methods/cases/derivatedGmail.php +++ b/workflow/engine/methods/cases/derivatedGmail.php @@ -38,8 +38,9 @@ $enablePMGmail = false; G::LoadClass( "pmDrive" ); $pmDrive = new PMDrive(); $enablePMGmail = $pmDrive->getStatusService(); -if( $_SESSION['gmail'] === 1 && !empty($enablePMGmail) && $enablePMGmail==1 ){ - //$_SESSION['gmail'] = 0; +if(key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && !empty($enablePMGmail) && $enablePMGmail==1 ){ + $_SESSION['gmail'] = 0; + unset($_SESSION['gmail']); //cleaning session $mUrl = '/sys'. $_SESSION['WORKSPACE'] .'/en/neoclassic/cases/cases_Open?APP_UID='.$caseId.'&DEL_INDEX='.$actualIndex.'&action=sent'; } else{ $mUrl = 'casesListExtJs'; diff --git a/workflow/engine/methods/cases/open.php b/workflow/engine/methods/cases/open.php index ce9e0ea62..06c064616 100755 --- a/workflow/engine/methods/cases/open.php +++ b/workflow/engine/methods/cases/open.php @@ -59,6 +59,25 @@ $conf = new Configurations(); $oHeadPublisher = & headPublisher::getSingleton(); +$urlToRedirectAfterPause = 'casesListExtJs'; + + /*----------------------------------********---------------------------------*/ +$licensedFeatures = &PMLicensedFeatures::getSingleton(); +if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) { + G::LoadClass( "pmDrive" ); + $pmDrive = new PMDrive(); + $enablePMGmail = $pmDrive->getStatusService(); + if (key_exists('gmail', $_SESSION) && $_SESSION['gmail'] == 1 && !empty($enablePMGmail) && $enablePMGmail == 1) { + $_SESSION['gmail'] = 0; + $urlToRedirectAfterPause = '/sys'. $_SESSION['WORKSPACE'] .'/en/neoclassic/cases/cases_Open?APP_UID='.$_SESSION['APPLICATION'].'&DEL_INDEX='.$_SESSION['INDEX'].'&action=sent'; + } +} + /*----------------------------------********---------------------------------*/ + + +$oHeadPublisher->assign( 'urlToRedirectAfterPause', $urlToRedirectAfterPause ); + + $oHeadPublisher->addExtJsScript( 'app/main', true ); $oHeadPublisher->addExtJsScript( 'cases/open', true ); $oHeadPublisher->assign( 'FORMATS', $conf->getFormats() ); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index ad5e69ee7..802cc7e5a 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -2469,7 +2469,7 @@ class Cases } if (count($processList) == 0) { $processList['success'] = 'failure'; - $processList['message'] = G::LoadTranslation('ID_USER_PROCESS_NOT_START'); + $processList['message'] = G::LoadTranslation('ID_NOT_HAVE_BOOKMARKED_PROCESSES'); } return $processList; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Pmgmail.php b/workflow/engine/src/ProcessMaker/BusinessModel/Pmgmail.php index 5e8b085c2..c20eadcac 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Pmgmail.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Pmgmail.php @@ -261,6 +261,19 @@ class Pmgmail { return $response; } + public function modifyMailToPauseCase($appUid, $appDelIndex) + { + require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.labelsGmail.php"); + $oLabels = new \labelsGmail(); + $oResponse = $oLabels->setLabelsToPauseCase($appUid, $appDelIndex); + } + + public function modifyMailToUnpauseCase($appUid, $appDelIndex) + { + require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.labelsGmail.php"); + $oLabels = new \labelsGmail(); + $oResponse = $oLabels->setLabelsToUnpauseCase($appUid, $appDelIndex); + } } diff --git a/workflow/engine/templates/admin/pmGmail.js b/workflow/engine/templates/admin/pmGmail.js index 3c92e8a3f..2f867d4b1 100644 --- a/workflow/engine/templates/admin/pmGmail.js +++ b/workflow/engine/templates/admin/pmGmail.js @@ -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,20 @@ 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(); + Ext.getCmp('typeAuthentication').clearValue(); } 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 +133,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 +363,9 @@ Ext.onReady(function(){ Ext.getCmp('status_pmgmail').checked = enablePMGmail; Ext.getCmp('status_pmgmail').setValue(enablePMGmail); + if (enablePMGmail){ + changeType(); + } }); var testSettings = function () @@ -406,10 +431,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(); }; diff --git a/workflow/engine/templates/cases/open.js b/workflow/engine/templates/cases/open.js index 0364c2734..1f7a4ee95 100755 --- a/workflow/engine/templates/cases/open.js +++ b/workflow/engine/templates/cases/open.js @@ -1256,7 +1256,7 @@ Ext.onReady(function(){ } catch (e) { } - location.href = 'casesListExtJs'; + location.href = urlToRedirectAfterPause; } else { PMExt.error(_('ID_ERROR'), req.result.msg); } diff --git a/workflow/public_html/pmGmail/lostSession.php b/workflow/public_html/pmGmail/lostSession.php index f9575a69e..b5bb6fa4e 100644 --- a/workflow/public_html/pmGmail/lostSession.php +++ b/workflow/public_html/pmGmail/lostSession.php @@ -4,7 +4,6 @@ if (!isset($_SESSION['USER_LOGGED'])) { die( ''); } -if($_GET['form']){ +if(key_exists('form', $_GET) && $_GET['form']){ header( 'location:' . $_SESSION['server'] . $_SESSION['PMCase'] ); -}else if($_GET['processmap']){ +}else if(key_exists('processmap', $_GET) && $_GET['processmap']){ header( 'location:' . $_SESSION['server'] . $_SESSION['PMProcessmap'] ); -}else if($_GET['uploaded']){ +}else if(key_exists('uploaded', $_GET) && $_GET['uploaded']){ header( 'location:' . $_SESSION['server'] . $_SESSION['PMUploadedDocuments'] ); -} else if($_GET['generated']){ +} else if(key_exists('generated', $_GET) && $_GET['generated']){ header( 'location:' . $_SESSION['server'] . $_SESSION['PMGeneratedDocuments'] ); } diff --git a/workflow/public_html/pmGmail/sso.php b/workflow/public_html/pmGmail/sso.php index 3250095af..06d8fe743 100644 --- a/workflow/public_html/pmGmail/sso.php +++ b/workflow/public_html/pmGmail/sso.php @@ -12,8 +12,8 @@ $proUid = $_GET['proUid']; $server = isset($_GET['server']) ? $_GET['server'] : ''; //We do need the server to continue. -if( !isset($_GET['server']) || $server == "" ){ - throw new \Exception(Bootstrap::LoadTranslation( 'ID_GMAIL_NEED_SERVER' )); +if( !isset($_GET['server']) || $server == "" ){ + throw new \Exception(Bootstrap::LoadTranslation( 'ID_GMAIL_NEED_SERVER' )); } //First check if the feature is enabled in the license. @@ -44,6 +44,10 @@ $curl_response = curl_exec( $curl ); curl_close($curl); $decodedResp = json_decode($curl_response); +if(!is_object($decodedResp) || property_exists($decodedResp,'error')) { + die($decodedResp->error->message); +} + //getting the enviroment $enviroment = $decodedResp->enviroment; @@ -51,7 +55,7 @@ if(count($decodedResp->user) > 1){ echo Bootstrap::LoadTranslation( 'ID_EMAIL_MORE_THAN_ONE_USER' ); die; } else if(count($decodedResp->user) < 1){ - echo Bootstrap::LoadTranslation( 'ID_USER_NOT_FOUND' ); + echo Bootstrap::LoadTranslation( 'ID_USER_NOT_FOUND' ); die; } @@ -79,8 +83,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->user['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) { @@ -89,17 +93,17 @@ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp setcookie("workspaceSkin", $enviroment, time() + (24 * 60 * 60), "/sys" . $enviroment, null, false, true); } - $_SESSION = array(); - $_SESSION['__EE_INSTALLATION__'] = 2; - $_SESSION['__EE_SW_PMLICENSEMANAGER__'] = 1; - $_SESSION['phpLastFileFound'] = ''; - $_SESSION['USERNAME_PREVIOUS1'] = $decodedResp->user['0']->USR_USERNAME; - $_SESSION['USERNAME_PREVIOUS2'] = $decodedResp->user['0']->USR_USERNAME; - $_SESSION['WORKSPACE'] = $pmws; - $_SESSION['USER_LOGGED'] = $decodedResp->user['0']->USR_UID; - $_SESSION['USR_USERNAME'] = $decodedResp->user['0']->USR_USERNAME; - $_SESSION['USR_FULLNAME'] = $decodedResp->user['0']->USR_FIRSTNAME. ' ' .$decodedResp->user['0']->USR_LASTNAME; - $_SESSION['__sw__'] = 1; + $_SESSION = array(); + $_SESSION['__EE_INSTALLATION__'] = 2; + $_SESSION['__EE_SW_PMLICENSEMANAGER__'] = 1; + $_SESSION['phpLastFileFound'] = ''; + $_SESSION['USERNAME_PREVIOUS1'] = $decodedResp->user['0']->USR_USERNAME; + $_SESSION['USERNAME_PREVIOUS2'] = $decodedResp->user['0']->USR_USERNAME; + $_SESSION['WORKSPACE'] = $pmws; + $_SESSION['USER_LOGGED'] = $decodedResp->user['0']->USR_UID; + $_SESSION['USR_USERNAME'] = $decodedResp->user['0']->USR_USERNAME; + $_SESSION['USR_FULLNAME'] = $decodedResp->user['0']->USR_FIRSTNAME. ' ' .$decodedResp->user['0']->USR_LASTNAME; + $_SESSION['__sw__'] = 1; //session created } else { echo Bootstrap::LoadTranslation( 'ID_USER_NOT_ACTIVE' ); @@ -125,6 +129,8 @@ if ($action == "draft"){ $mainUrl = '/sys'. $pmws .'/en/'. $enviroment .'/cases/open?APP_UID='.$appUid.'&DEL_INDEX='.$delIndex.'&action='.$action.'&gmail=1'; header( 'location:' . $mainUrl ); + $_SESSION['APPLICATION'] =$appUid ; + $_SESSION['INDEX'] = $delIndex; die; }