removing PMGmail

This commit is contained in:
Fernando Ontiveros
2025-07-11 06:36:38 -04:00
parent b0c0d8d70c
commit 3f8710b60e
27 changed files with 17 additions and 2573 deletions

View File

@@ -1,32 +0,0 @@
<?php
session_start();
if (!isset($_SESSION['USER_LOGGED'])) {
die( '<script type="text/javascript">
try
{
var dataToSend = {
"action": "credentials",
"operation": "refreshPmSession",
"type": "processCall",
"funParams": [
"",
""
],
"expectReturn": false
};
var x = parent.postMessage(JSON.stringify(dataToSend), "*");
}catch (err)
{
parent.location = parent.location;
}
</script>');
}
if(key_exists('form', $_GET) && $_GET['form']){
header( 'location:' . $_SESSION['server'] . $_SESSION['PMCase'] );
}else if(key_exists('processmap', $_GET) && $_GET['processmap']){
header( 'location:' . $_SESSION['server'] . $_SESSION['PMProcessmap'] );
}else if(key_exists('uploaded', $_GET) && $_GET['uploaded']){
header( 'location:' . $_SESSION['server'] . $_SESSION['PMUploadedDocuments'] );
} else if(key_exists('generated', $_GET) && $_GET['generated']){
header( 'location:' . $_SESSION['server'] . $_SESSION['PMGeneratedDocuments'] );
}

View File

@@ -1,132 +0,0 @@
<?php
session_start();
require_once __DIR__ . '/../../../bootstrap/autoload.php';
require_once (dirname(__FILE__) . '/../../../gulliver/system/class.bootstrap.php');
require_once (dirname(__FILE__) . '/../../../gulliver/system/class.g.php');
$gmailToken = $_GET['gmailToken'];
$gmail = $_GET['gmail'];
$pmtoken = $_GET['pmtoken'];
$pmws = $_GET['pmws'];
$appUid = $_GET['appUid'];
$delIndex = $_GET['delIndex'];
$action = $_GET['action'];
$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'));
}
//First check if the feature is enabled.
$gCurl = curl_init('https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/verifyGmailfeature/');
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_CONNECTTIMEOUT, 0);
curl_setopt($gCurl, CURLOPT_SSL_VERIFYHOST, false);
if (curl_exec($gCurl) === false) {
echo 'Curl error: ' . curl_error($gCurl);
error_log(Bootstrap::LoadTranslation('ID_SERVER_COMMUNICATION_ERROR'));
die();
} else {
$gCurl_response = curl_exec($gCurl);
curl_close($gCurl);
$gResp = G::json_decode($gCurl_response);
if ($gResp === false) {
echo Bootstrap::LoadTranslation('ID_NOT_ENABLED');
die();
}
}
set_time_limit(60);
$curl = curl_init('https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/userexist/' . $gmail);
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);
curl_close($curl);
$decodedResp = G::json_decode($curl_response);
if (!is_object($decodedResp) || property_exists($decodedResp, 'error')) {
die($decodedResp->error->message);
}
//getting the enviroment
$enviroment = $decodedResp->enviroment;
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');
die;
}
//validationg if there is an actual PM session
if (!isset($_SESSION['USER_LOGGED']) || $_SESSION['USER_LOGGED'] != $decodedResp->user['0']->USR_UID) {
$url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=' . $gmailToken;
// init curl object
$ch = curl_init();
// define options
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
);
// apply those options
curl_setopt_array($ch, $optArray);
// execute request and get response
$result = curl_exec($ch);
$response = (G::json_decode($result));
curl_close($ch);
//First validate if this user (mail) corresponds to a PM user
if (isset($response->email) && ($gmail == $response->email)) {
//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_regenerate_id();
$cookieOptions = Bootstrap::buildCookieOptions(['expires' => time() + (24 * 60 * 60), 'path' => '/sys' . $enviroment, 'httponly' => true]);
setcookie('workspaceSkin', $enviroment, $cookieOptions);
$_SESSION = array();
$_SESSION['phpLastFileFound'] = '';
$_SESSION['USERNAME_PREVIOUS1'] = $decodedResp->user['0']->USR_USERNAME;
$_SESSION['USERNAME_PREVIOUS2'] = $decodedResp->user['0']->USR_USERNAME;
$_SESSION['WORKSPACE'] = $pmws;
$_SESSION['USR_FULLNAME'] = $decodedResp->user['0']->USR_FIRSTNAME . ' ' . $decodedResp->user['0']->USR_LASTNAME;
$_SESSION['__sw__'] = 1;
initUserSession(
$decodedResp->user['0']->USR_UID, $decodedResp->user['0']->USR_USERNAME
);
//session created
} else {
echo Bootstrap::LoadTranslation('ID_USER_NOT_ACTIVE');
die;
}
} else {
echo Bootstrap::LoadTranslation('ID_USER_DOES_NOT_CORRESPOND');
die;
}
}
$_SESSION['server'] = 'https://' . $server . '/sys' . $pmws . '/en/' . $enviroment . '/';
$_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';
header('location:' . 'templateForm.php');

View File

@@ -1,114 +0,0 @@
<!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();
?>
<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'] . '../../../pmGmail/lostSession.php?form=1' ?>" 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'] . '../../../pmGmail/lostSession.php?processmap=1' ?>" 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'] . '../../../pmGmail/lostSession.php?uploaded=1' ?>" 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'] . '../../../pmGmail/lostSession.php?generated=1' ?>" 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>

View File

@@ -1,96 +0,0 @@
<!DOCTYPE html>
<html class="js js csstransitions" lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Open Source Workflow Software &amp; Business Process Management BPM</title>
<meta http-equiv="Content-Language" content="en"><meta name="description" content="Open source web based workflow software and Business Process Management software">
<meta name="keywords" content="workflow software"><meta name="googlebot" content="index, follow">
<meta name="robots" content="index, follow">
<meta name="Revisit-After" content="7 days">
<meta name="city" content="Brooklyn">
<meta name="country" content="United States of America (USA)">
<meta name="state" content="NY">
<meta name="zip code" content="11238">
<meta name="geo.region" content="US-NY">
<meta name="geo.placename" content="Brooklyn">
<meta name="DC.title" content="ProcessMaker Inc.">
<meta name="subject" content="Open Source Workflow, Business Process Management (BPM) Soft-ware.">
<meta name="author" content="ProcessMaker Inc.">
<meta name="copyright" content="ProcessMaker Inc.">
<link type="text/css" rel="stylesheet" href="../css/general.css" media="all">
<link type="text/css" rel="stylesheet" href="../css/sb-admin-2.css" media="all">
<link rel="shortcut icon" href="http://www.processmaker.com/favicon.ico" type="image/vnd.microsoft.icon">
<script>
document.onreadystatechange = function () {
var state = document.readyState
if (state == 'interactive') {
document.getElementById('main-content').style.visibility="hidden";
} else if (state == 'complete') {
document.getElementById('loading').style.visibility="hidden";
document.getElementById('loading').style.display="none";
document.getElementById('main-content').style.visibility="visible";
}
}
</script>
<body class="html front not-logged-in no-sidebars page-node" id="page-top" data-spy="scroll" data-target=".navbar-custom" style="background-color:white;">
<div id="main-content" class="container">
<div class="row">
<div class="col-lg-12" style="margin: 0 auto;">
<div style="margin: 0 auto; width:600px;padding:25px;">
<div style="margin: 0 auto; text-align:center;margin-top:40px;">
<img src = "../images/logo-processmaker-google.png">
</div>
<h2 style="margin: 0 auto; text-align:center; margin-top:40px;">ProcessMaker Google Integration</h2>
<p style="margin: 0 auto; text-align:center; margin-top:10px;">
The ProcessMaker Google Integration extension and components have been uninstalled from your Gmail Acccount.
</p>
</div>
</div>
</div>
</div>
<div id="loading" style="width:120px;margin:0 auto;margin-top:200px;text-align:center;">
<img id="loading-image" src="../images/ext/default/shared/large-loading.gif" alt="Uninstalling..." />
<div>Uninstalling ...</div>
</div>
</body>
</html>
<?php
/*
* Uninstall file to help in the uninstaling process of the PMGmail Extension.
* This deletes the labels created by the Extension in the user email.
*
*/
/**
* Call the end point to delete labels
*
* @param string $server
* @param string $pmws
* @param string $mail
* @param string $pmtoken
*/
function callEndPointDeleteLabels($server, $pmws, $mail, $pmtoken){
set_time_limit(60);
$curl = curl_init( 'https://' . $server . '/api/1.0/' . $pmws . '/gmailIntegration/deleteLabels/'. $mail );
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $pmtoken ) );
curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0);
$curl_response = curl_exec( $curl );
curl_close($curl);
}
$server = $_GET['server'];
$pmws = $_GET['pmws'];
$mail = $_GET['mail'];
$pmtoken = $_GET['pmtoken'];
callEndPointDeleteLabels($server, $pmws, $mail, $pmtoken);
?>