New changes to pmgmail integration
This commit is contained in:
jennydmz
2015-11-11 11:31:25 -04:00
parent 8115bc9376
commit 161e31847d
8 changed files with 222 additions and 73 deletions

View File

@@ -92,6 +92,8 @@ class labelsGmail
//The Subject to search the email //The Subject to search the email
$subject = "[PM] " .$proName. " Case: ". $appNumber; $subject = "[PM] " .$proName. " Case: ". $appNumber;
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");
$pmGoogle = new PMGoogleApi(); $pmGoogle = new PMGoogleApi();
$pmGoogle->setUser($mail); $pmGoogle->setUser($mail);

View File

@@ -914,7 +914,8 @@ class wsBase
$aAttachment = null, $aAttachment = null,
$showMessage = true, $showMessage = true,
$delIndex = 0, $delIndex = 0,
$config = array() $config = array(),
$gmail = 0
) { ) {
try { try {
if (!class_exists('System')) { if (!class_exists('System')) {
@@ -969,8 +970,11 @@ class wsBase
$oCase = new Cases(); $oCase = new Cases();
$oldFields = $oCase->loadCase( $caseId ); $oldFields = $oCase->loadCase( $caseId );
if($gmail == 1){
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP; $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP;
}else {
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP;
}
$fileTemplate = $pathEmail . $sTemplate; $fileTemplate = $pathEmail . $sTemplate;
G::mk_dir( $pathEmail, 0777, true ); G::mk_dir( $pathEmail, 0777, true );

View File

@@ -264,6 +264,7 @@ class AppDelegation extends BaseAppDelegation
$c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE ); $c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE ); $c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE ); $c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_PREVIOUS );
$c->add( AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN' ); $c->add( AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN' );
$c->add( AppDelegationPeer::APP_UID, $AppUid ); $c->add( AppDelegationPeer::APP_UID, $AppUid );
@@ -287,6 +288,7 @@ class AppDelegation extends BaseAppDelegation
$case['DEL_INIT_DATE'] = $row['DEL_INIT_DATE']; $case['DEL_INIT_DATE'] = $row['DEL_INIT_DATE'];
$case['DEL_TASK_DUE_DATE'] = $row['DEL_TASK_DUE_DATE']; $case['DEL_TASK_DUE_DATE'] = $row['DEL_TASK_DUE_DATE'];
$case['DEL_FINISH_DATE'] = $row['DEL_FINISH_DATE']; $case['DEL_FINISH_DATE'] = $row['DEL_FINISH_DATE'];
$case['DEL_PREVIOUS'] = $row['DEL_PREVIOUS'];
$aCases[] = $case; $aCases[] = $case;
$rs->next(); $rs->next();
$row = $rs->getRow(); $row = $rs->getRow();

View File

@@ -1,5 +1,28 @@
<?php <?php
class EmailServer extends BaseEmailServer class EmailServer extends BaseEmailServer
{ {
/**
* Get the evn_description column value.
*
* @return string
*/
public function loadDefaultAccount ()
{
$c = new Criteria( 'workflow' );
$del = DBAdapter::getStringDelimiter();
$c->clearSelectColumns();
$c->addSelectColumn( EmailServerPeer::MESS_ACCOUNT );
$c->add( EmailServerPeer::MESS_DEFAULT, 1 );
$rs = EmailServerPeer::doSelectRS( $c, Propel::getDBConnection('workflow_ro') );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next();
$row = $rs->getRow();
$response=$row;
return $response;
}
} }

View File

@@ -1,19 +1,14 @@
<?php <?php
use Gulliver\core\ServiceContainer;
$sc = ServiceContainer::getInstance();
$session = $sc->make('session.store');
$licensedFeatures = & PMLicensedFeatures::getSingleton(); $licensedFeatures = & PMLicensedFeatures::getSingleton();
if (!$licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) { if (!$licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
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;
} }
$caseId = $session->get('APPLICATION'); $caseId = $_SESSION['APPLICATION'];
$usrUid = $session->get('USER_LOGGED'); $usrUid = $_SESSION['USER_LOGGED'];
$usrName = $session->get('USR_FULLNAME'); $usrName = $_SESSION['USR_FULLNAME'];
$actualIndex = $session->get('INDEX'); $actualIndex = $_SESSION['INDEX'];
$cont = 0; $cont = 0;
use \ProcessMaker\Services\Api; use \ProcessMaker\Services\Api;
@@ -23,6 +18,7 @@ $actualThread = $appDel->Load($caseId, $actualIndex);
$actualLastIndex = $actualThread['DEL_PREVIOUS']; $actualLastIndex = $actualThread['DEL_PREVIOUS'];
$appDelPrev = $appDel->LoadParallel($caseId); $appDelPrev = $appDel->LoadParallel($caseId);
if($appDelPrev == array()){ if($appDelPrev == array()){
$appDelPrev['0'] = $actualThread; $appDelPrev['0'] = $actualThread;
} }
@@ -34,11 +30,12 @@ foreach ($appDelPrev as $app){
} }
} }
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.labelsGmail.php");
$oLabels = new labelsGmail(); $oLabels = new labelsGmail();
$oResponse = $oLabels->setLabels($caseId, $actualIndex, $actualLastIndex, false); $oResponse = $oLabels->setLabels($caseId, $actualIndex, $actualLastIndex, false);
if( $session->get('gmail') === 1 ){ if( $_SESSION['gmail'] === 1 ){
//$session->set('gmail', 0); //$_SESSION['gmail'] = 0;
$mUrl = '/sys'. $session->get('WORKSPACE') .'/en/neoclassic/cases/cases_Open?APP_UID='.$caseId.'&DEL_INDEX='.$actualIndex.'&action=sent'; $mUrl = '/sys'. $_SESSION['WORKSPACE'] .'/en/neoclassic/cases/cases_Open?APP_UID='.$caseId.'&DEL_INDEX='.$actualIndex.'&action=sent';
} else{ } else{
$mUrl = 'casesListExtJs'; $mUrl = 'casesListExtJs';
} }

View File

@@ -105,13 +105,33 @@ class Pmgmail {
*/ */
public function getDraftApp($app_uid, $index=1) public function getDraftApp($app_uid, $index=1)
{ {
$response = \AppCacheViewQuery::create() $c = new \Criteria( 'workflow' );
->filterByAppUid($app_uid)
->filterByDelIndex($index) $c->clearSelectColumns();
->find() $c->addSelectColumn( \AppCacheViewPeer::APP_NUMBER );
->toArray(null, false, \BasePeer::TYPE_FIELDNAME); $c->addSelectColumn( \AppCacheViewPeer::APP_STATUS );
$c->addSelectColumn( \AppCacheViewPeer::DEL_INDEX );
$c->addSelectColumn( \AppCacheViewPeer::APP_DEL_PREVIOUS_USER );
$c->addSelectColumn( \AppCacheViewPeer::DEL_DELEGATE_DATE );
$c->addSelectColumn( \AppCacheViewPeer::USR_UID );
$c->addSelectColumn( \AppCacheViewPeer::PRO_UID );
$c->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
$c->addSelectColumn( \AppCacheViewPeer::APP_TAS_TITLE );
$c->addSelectColumn( \AppCacheViewPeer::DEL_THREAD_STATUS );
$c->addSelectColumn( \AppCacheViewPeer::TAS_UID );
$c->addSelectColumn( \AppCacheViewPeer::DEL_LAST_INDEX );
$c->add( \AppCacheViewPeer::APP_UID, $app_uid );
$c->add( \AppCacheViewPeer::DEL_INDEX, $index );
return $response; $rs = \AppCacheViewPeer::doSelectRS( $c );
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$rows = Array ();
while ($rs->next()) {
$rows[] = $rs->getRow();
}
return $rows;
} }
/** /**

View File

@@ -1,26 +1,22 @@
<?php <?php
require_once(dirname(__FILE__) . '/../../../gulliver/init.php'); require_once (dirname(__FILE__) . '/../../../gulliver/system/class.bootstrap.php');
use Gulliver\core\ServiceContainer;
$sc = ServiceContainer::getInstance();
$session = $sc->make('session.store');
$request = $sc->make('request');
$gmailToken = $request->query->get('gmailToken'); $gmailToken = $_GET['gmailToken'];
$gmail = $request->query->get('gmail'); $gmail = $_GET['gmail'];
$pmtoken = $request->query->get('pmtoken'); $pmtoken = $_GET['pmtoken'];
$pmws = $request->query->get('pmws'); $pmws = $_GET['pmws'];
$appUid = $request->query->get('appUid'); $appUid = $_GET['appUid'];
$delIndex = $request->query->get('delIndex'); $delIndex = $_GET['delIndex'];
$action = $request->query->get('action'); $action = $_GET['action'];
$proUid = $request->query->has('proUid') ? $request->query->get('proUid') : ''; $proUid = $_GET['proUid'];
$server = $request->query->get('server'); $server = isset($_GET['server']) ? $_GET['server'] : '';
//First check if the feature is enabled in the license. //First check if the feature is enabled in the license.
$gCurl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/verifyGmailfeature/' ); $gCurl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/verifyGmailfeature/' );
curl_setopt( $gCurl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) ); curl_setopt( $gCurl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) );
curl_setopt( $gCurl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $gCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $gCurl, CURLOPT_SSL_VERIFYPEER,false); curl_setopt( $gCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $gCurl, CURLOPT_CONNECTTIMEOUT ,0); curl_setopt( $gCurl, CURLOPT_CONNECTTIMEOUT, 0);
$gCurl_response = curl_exec( $gCurl ); $gCurl_response = curl_exec( $gCurl );
curl_close($gCurl); curl_close($gCurl);
@@ -37,7 +33,7 @@ $curl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegrati
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) ); curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER,false); curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT ,0); curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0);
$curl_response = curl_exec( $curl ); $curl_response = curl_exec( $curl );
curl_close($curl); curl_close($curl);
@@ -49,7 +45,7 @@ if(count($decodedResp) > 1){
} }
//validationg if there is an actual PM session //validationg if there is an actual PM session
if( !$session->has('USER_LOGGED') || $session->get('USER_LOGGED') != $decodedResp['0']->USR_UID){ if( !isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp['0']->USR_UID){
$url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='.$gmailToken; $url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='.$gmailToken;
// init curl object // init curl object
@@ -72,32 +68,28 @@ if( !$session->has('USER_LOGGED') || $session->get('USER_LOGGED') != $decodedRes
//If the email corresponds I get the username and with the gmail user_id the session is created. //If the email corresponds I get the username and with the gmail user_id the session is created.
if($decodedResp['0']->USR_STATUS == "ACTIVE"){ if($decodedResp['0']->USR_STATUS == "ACTIVE"){
//User Active! lets create the Session //User Active! lets create the Session
$request = $sc->make('request'); @session_destroy();
$session = $sc->make('session.store'); session_start();
session_regenerate_id();
$session->setId($request->cookies->get($session->getName()));
$session->start();
setcookie($session->getName(), $session->getId(), 0, '/');
$request->setSession($session);
if (PHP_VERSION < 5.2) { if (PHP_VERSION < 5.2) {
setcookie("workspaceSkin", "neoclasic", time() + (24 * 60 * 60), "/sys" . "neoclasic", "; HttpOnly"); setcookie("workspaceSkin", "neoclasic", time() + (24 * 60 * 60), "/sys" . "neoclasic", "; HttpOnly");
} else { } else {
setcookie("workspaceSkin", "neoclasic", time() + (24 * 60 * 60), "/sys" . "neoclasic", null, false, true); setcookie("workspaceSkin", "neoclasic", time() + (24 * 60 * 60), "/sys" . "neoclasic", null, false, true);
} }
$session->set('__EE_INSTALLATION__', 2); $_SESSION = array();
$session->set('__EE_SW_PMLICENSEMANAGER__', 1); $_SESSION['__EE_INSTALLATION__'] = 2;
$session->set('phpLastFileFound', ''); $_SESSION['__EE_SW_PMLICENSEMANAGER__'] = 1;
$session->set('USERNAME_PREVIOUS1', 'admin'); $_SESSION['phpLastFileFound'] = '';
$session->set('USERNAME_PREVIOUS2', 'admin'); $_SESSION['USERNAME_PREVIOUS1'] = 'admin';
$session->set('WORKSPACE', $pmws); $_SESSION['USERNAME_PREVIOUS2'] = 'admin';
$session->set('USER_LOGGED', $decodedResp['0']->USR_UID); $_SESSION['WORKSPACE'] = $pmws;
$session->set('USR_USERNAME', $decodedResp['0']->USR_USERNAME); $_SESSION['USER_LOGGED'] = $decodedResp['0']->USR_UID;
$session->set('USR_FULLNAME', $decodedResp['0']->USR_FIRSTNAME. ' ' .$decodedResp['0']->USR_LASTNAME); $_SESSION['USR_USERNAME'] = $decodedResp['0']->USR_USERNAME;
$session->set('__sw__', 1); $_SESSION['USR_FULLNAME'] = $decodedResp['0']->USR_FIRSTNAME. ' ' .$decodedResp['0']->USR_LASTNAME;
$session->save(); $_SESSION['__sw__'] = 1;
//session created //session created
} else { } else {
echo Bootstrap::LoadTranslation( 'ID_USER_NOT_ACTIVE' ); echo Bootstrap::LoadTranslation( 'ID_USER_NOT_ACTIVE' );
die; die;
@@ -115,7 +107,7 @@ if ($action == "draft"){
curl_setopt( $curlApp, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt( $curlApp, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt( $curlApp, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curlApp, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $curlApp, CURLOPT_SSL_VERIFYPEER,false); curl_setopt( $curlApp, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt( $curlApp, CURLOPT_CONNECTTIMEOUT ,0); curl_setopt( $curlApp, CURLOPT_CONNECTTIMEOUT, 0);
$curl_response_app = curl_exec( $curlApp ); $curl_response_app = curl_exec( $curlApp );
curl_close( $curlApp ); curl_close( $curlApp );
@@ -124,20 +116,12 @@ if ($action == "draft"){
header( 'location:' . $mainUrl ); header( 'location:' . $mainUrl );
die; die;
} }
$session->set('server', 'https://' . $server . '/sys'. $pmws .'/en/neoclassic/');
$session->set('PMCase', 'cases/cases_Open?APP_UID='.$appUid.'&DEL_INDEX='.$delIndex.'&action='.$action.'&gmail=1'); $_SESSION['server'] = 'https://' . $server . '/sys'. $pmws .'/en/neoclassic/';
$_SESSION['PMCase'] = 'cases/cases_Open?APP_UID='.$appUid.'&DEL_INDEX='.$delIndex.'&action='.$action.'&gmail=1';
$_SESSION['PMProcessmap'] = 'designer?prj_uid=' . $proUid . '&prj_readonly=true&app_uid=' . $appUid;
$_SESSION['PMUploadedDocuments'] = 'cases/ajaxListener?action=uploadedDocuments';
$_SESSION['PMGeneratedDocuments'] = 'cases/casesGenerateDocumentPage_Ajax.php?actionAjax=casesGenerateDocumentPage';
$session->set('PMProcessmap', 'designer?prj_uid=' . $proUid . '&prj_readonly=true&app_uid=' . $appUid);
$session->set('PMCasesHistory', 'cases/ajaxListener?action=caseHistory');
$session->set('PMHistoryDynaform', 'cases/casesHistoryDynaformPage_Ajax?actionAjax=historyDynaformPage');
$session->set('PMUploadedDocuments', 'cases/ajaxListener?action=uploadedDocuments');
$session->set('PMGeneratedDocuments', 'cases/casesGenerateDocumentPage_Ajax.php?actionAjax=casesGenerateDocumentPage');
ob_end_flush();
$session->save();
header( 'location:' . 'templateForm.php' ); header( 'location:' . 'templateForm.php' );

View File

@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Interface Processmaker</title>
<script type="text/javascript" src="/lib/js/jquery-1.10.2.min.js"></script>
<link rel="stylesheet" href="/lib/pmUI/pmui.min.css">
<script type="text/javascript" >
jQuery(document).ready(function() {
var tid;
var addLoading = function (host, panel, message) {
panel = panel || 'PMContent';
message = message || 'Loading...';
var divLoading = document.createElement('div');
var span = document.createElement('span');
var text = document.createTextNode(message);
divLoading.setAttribute('id', 'PMGmailLoad');
divLoading.setAttribute('style', 'position:absolute; left: 0px;top: 0px;width: 100%;height: 100%;z-index: 9999;background: url('+host+'../../../lib/img/loading.gif) 50% 50% no-repeat #f9f9f9;');
span.setAttribute('style', ' margin-top: 50%; margin-left: 44%; position: absolute; font-weight: bold; font-size: 12px; margin-right: auto;');
span.appendChild(text);
divLoading.appendChild(span);
document.getElementById(panel).appendChild(divLoading);
};
var removeLoading = function () {
document.getElementById('PMGmailLoad').remove();
};
var resizePMDynadorm = function () {
var iframe = document.getElementById('iframePM');
var content = iframe.contentDocument;
if (content != null){
clearInterval(tid);
}
};
jQuery('.pmui-tab-ref').on('click', function(e) {
var currentAttrValue = jQuery(this).attr('href');
jQuery(this).parent('li').addClass('pmui-active').siblings().removeClass('pmui-active');
//url iframe
currentAttrValue = jQuery(this).attr('linkPM');
addLoading(jQuery(this).attr('PMServer'));
$('#iframePM').attr('src', currentAttrValue);
e.preventDefault();
});
$('#iframePM').load( function () {
tid = setInterval(function(){ resizePMDynadorm() }, 500);
removeLoading();
});
var currentAttrValue = jQuery('.pmui-tab-ref');
addLoading(currentAttrValue[0].attributes[3].value);
$('#iframePM').attr('src',currentAttrValue[0].attributes[2].value);
});
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
eventer(messageEvent,function(e) {
parent.parent.postMessage(e.data, 'https://mail.google.com');
},false);
</script>
</head>
<body>
<?php
session_start();
if (!defined('SYS_SYS')) {
define('SYS_SYS', 'jenws');
}
?>
<div class="pmui-tabpanel-tabs_container" style="display: block; height: 40px;">
<ul class="pmui-tabpanel-tabs" style="display:block; float:left;">
<li class="pmui pmui-tabitem pmui-active" style="left: 0px; top: 0px; width: auto; height: auto; position: relative; z-index: auto; display: inline-block;">
<i class="pmui-tab-icon"> </i>
<a class="pmui-tab-ref" href="#PMCases" linkPM="<?php echo $_SESSION['server'] . $_SESSION['PMCase'] ?>" PMServer="<?php echo $_SESSION['server'] ?>">
Form
</a>
</li>
<li class="pmui pmui-tabitem" style="left: 0px; top: 0px; width: auto; height: auto; position: relative; z-index: auto; display: inline-block;">
<i class="pmui-tab-icon"> </i>
<a class="pmui-tab-ref" href="#PMProcessmap" linkPM="<?php echo $_SESSION['server'] . $_SESSION['PMProcessmap'] ?>" PMServer="<?php echo $_SESSION['server'] ?>">
Processmap
</a>
</li>
<li class="pmui pmui-tabitem" style="left: 0px; top: 0px; width: auto; height: auto; position: relative; z-index: auto; display: inline-block;">
<i class="pmui-tab-icon"> </i>
<a class="pmui-tab-ref" href="#PMUploadedDocuments" linkPM="<?php echo $_SESSION['server'] . $_SESSION['PMUploadedDocuments'] ?>" PMServer="<?php echo $_SESSION['server'] ?>">
Uploaded
</a>
</li>
<li class="pmui pmui-tabitem" style="left: 0px; top: 0px; width: auto; height: auto; position: relative; z-index: auto; display: inline-block;">
<i class="pmui-tab-icon"> </i>
<a class="pmui-tab-ref" href="#PMGeneratedDocuments" linkPM="<?php echo $_SESSION['server'] . $_SESSION['PMGeneratedDocuments'] ?>" PMServer="<?php echo $_SESSION['server'] ?>">
Generated
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab active" id="PMContent">
<iframe id="iframePM" src="" width="100%" height="530" style="overflow:hidden;"></iframe>
</div>
</div>
</div>
</body>
</html>