Merged in feature/HOR-3214 (pull request #5712)
Feature/HOR-3214 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
801de49881
@@ -27785,6 +27785,18 @@ msgstr "View Response"
|
||||
msgid "Error Message"
|
||||
msgstr "Error Message"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_CASE_CREATED
|
||||
#: LABEL/ID_CASE_CREATED
|
||||
msgid "Case created"
|
||||
msgstr "Case created"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_CASE_ROUTED_TO
|
||||
#: LABEL/ID_CASE_ROUTED_TO
|
||||
msgid "Case routed to"
|
||||
msgstr "Case routed to"
|
||||
|
||||
# additionalTables/additionalTablesData.xml?ADD_TAB_NAME
|
||||
# additionalTables/additionalTablesData.xml
|
||||
#: text - ADD_TAB_NAME
|
||||
|
||||
@@ -6171,7 +6171,9 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_CASE_NUMBER_CAPITALIZED','en','Case Number','2017-02-22') ,
|
||||
( 'LABEL','ID_ANSWERED','en','Answered','2017-02-22') ,
|
||||
( 'LABEL','ID_VIEW_RESPONSE','en','View Response','2017-02-22') ,
|
||||
( 'LABEL','ID_ERROR_MESSAGE','en','Error Message','2017-02-22') ;
|
||||
( 'LABEL','ID_ERROR_MESSAGE','en','Error Message','2017-02-22') ,
|
||||
( 'LABEL','ID_CASE_CREATED','en','Case created','2017-06-02') ,
|
||||
( 'LABEL','ID_CASE_ROUTED_TO','en','Case routed to','2017-06-02');
|
||||
|
||||
INSERT INTO ISO_LOCATION (IC_UID,IL_UID,IL_NAME,IL_NORMAL_NAME,IS_UID) VALUES
|
||||
('AD','','',' ','') ,
|
||||
|
||||
@@ -161,6 +161,7 @@ $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower );
|
||||
|
||||
$oCase = new Cases();
|
||||
$oStep = new Step();
|
||||
$bmWebEntry = new \ProcessMaker\BusinessModel\WebEntry;
|
||||
|
||||
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
|
||||
$Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() );
|
||||
@@ -295,6 +296,9 @@ try {
|
||||
if (isset( $oProcessFieds['PRO_SHOW_MESSAGE'] )) {
|
||||
$noShowTitle = $oProcessFieds['PRO_SHOW_MESSAGE'];
|
||||
}
|
||||
if ($bmWebEntry->isTaskAWebEntry($_SESSION['TASK'])) {
|
||||
$noShowTitle = 1;
|
||||
}
|
||||
|
||||
switch ($_GET['TYPE']) {
|
||||
case 'DYNAFORM':
|
||||
@@ -1105,6 +1109,27 @@ try {
|
||||
$aFields["TASK"][$sKey]["NEXT_TASK"]["TAS_TITLE"] = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_MESSAGE_EVENT");
|
||||
}
|
||||
|
||||
//SKIP ASSIGN SCREEN
|
||||
if (!empty($aFields['TASK'][1])) {
|
||||
$currentTask = $aFields['TASK'][1];
|
||||
$isWebEntry = $bmWebEntry->isTaskAWebEntry($currentTask['TAS_UID']);
|
||||
if ($isWebEntry) {
|
||||
$tplFile = 'webentry/cases_ScreenDerivation';
|
||||
$caseId = $currentTask['APP_UID'];
|
||||
$delIndex = $currentTask['DEL_INDEX'];
|
||||
$derivationResponse = PMFDerivateCase($caseId, $delIndex, true);
|
||||
if ($derivationResponse) {
|
||||
$webEntryUrl = $bmWebEntry->getCallbackUrlByTask($currentTask['TAS_UID']);
|
||||
$delegationData = $Fields['APP_DATA'];
|
||||
$delegationData['_DELEGATION_DATA'] = $aFields['TASK'];
|
||||
$delegationData['_DELEGATION_MESSAGE'] = $bmWebEntry->getDelegationMessage($delegationData);
|
||||
$webEntryUrlEvaluated = \G::replaceDataField($webEntryUrl, $delegationData);
|
||||
}
|
||||
$aFields['derivationResponse'] = $derivationResponse;
|
||||
$aFields['webEntryUrlEvaluated'] = $webEntryUrlEvaluated;
|
||||
}
|
||||
}
|
||||
|
||||
$G_PUBLISH->AddContent( 'smarty', $tplFile, '', '', $aFields );
|
||||
/*
|
||||
if (isset( $aFields['TASK'][1]['NEXT_TASK']['USER_ASSIGNED'])){
|
||||
|
||||
44
workflow/engine/methods/services/webentry/anonymousLogin.php
Normal file
44
workflow/engine/methods/services/webentry/anonymousLogin.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* This service is to start PM with the anonymous user.
|
||||
*/
|
||||
|
||||
/* @var $RBAC RBAC */
|
||||
global $RBAC;
|
||||
G::LoadClass('pmFunctions');
|
||||
try {
|
||||
if (empty($_REQUEST['we_uid'])) {
|
||||
throw new \Exception('Missing required field "we_uid"');
|
||||
}
|
||||
|
||||
$weUid = $_REQUEST['we_uid'];
|
||||
|
||||
$webEntry = \WebEntryPeer::retrieveByPK($weUid);
|
||||
if (empty($webEntry)) {
|
||||
throw new \Exception('Undefined WebEntry');
|
||||
}
|
||||
|
||||
$userUid = $webEntry->getUsrUid();
|
||||
$userInfo = PMFInformationUser($userUid);
|
||||
if (empty($userInfo)) {
|
||||
throw new \Exception('WebEntry User not found');
|
||||
}
|
||||
|
||||
$_SESSION['USER_LOGGED'] = $userUid;
|
||||
$_SESSION['USR_USERNAME'] = $userInfo['username'];
|
||||
|
||||
$result = [
|
||||
'user_logged' => $userUid,
|
||||
'userName' => $userInfo['username'],
|
||||
'firstName' => $userInfo['firstname'],
|
||||
'lastName' => $userInfo['lastname'],
|
||||
'mail' => $userInfo['mail'],
|
||||
'image' => '../users/users_ViewPhoto?t='.microtime(true),
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
$result = [
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
http_response_code(500);
|
||||
}
|
||||
echo G::json_encode($result);
|
||||
35
workflow/engine/methods/services/webentry/checkCase.php
Normal file
35
workflow/engine/methods/services/webentry/checkCase.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* This service verify if the provided APP_UID and DEL_INDEX could be used
|
||||
* for the web entry.
|
||||
*/
|
||||
|
||||
/* @var $RBAC RBAC */
|
||||
global $RBAC;
|
||||
G::LoadClass('pmFunctions');
|
||||
try {
|
||||
if (empty($_REQUEST['app_uid'])) {
|
||||
throw new \Exception('Missing required field "app_uid"');
|
||||
}
|
||||
if (empty($_REQUEST['del_index'])) {
|
||||
throw new \Exception('Missing required field "del_index"');
|
||||
}
|
||||
if (empty($_SESSION['USER_LOGGED'])) {
|
||||
throw new \Exception('You are not logged');
|
||||
}
|
||||
|
||||
$appUid = $_REQUEST['app_uid'];
|
||||
$delIndex = $_REQUEST['del_index'];
|
||||
$delegation = \AppDelegationPeer::retrieveByPK($appUid, $delIndex);
|
||||
|
||||
$check = $delegation->getDelThreadStatus() === 'OPEN' &&
|
||||
$delegation->getUsrUid() === $_SESSION['USER_LOGGED'];
|
||||
|
||||
$result = ["check" => $check];
|
||||
} catch (\Exception $e) {
|
||||
$result = [
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
http_response_code(500);
|
||||
}
|
||||
echo G::json_encode($result);
|
||||
18
workflow/engine/methods/services/webentry/completed.php
Normal file
18
workflow/engine/methods/services/webentry/completed.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* This page displays a message when completed or if there is an error
|
||||
* during the execution.
|
||||
*/
|
||||
$G_PUBLISH = new Publisher();
|
||||
$show = "login/showMessage";
|
||||
$message = [];
|
||||
if (isset($_GET["message"])) {
|
||||
$show = "login/showInfo";
|
||||
$message['MESSAGE'] = nl2br($_GET["message"]);
|
||||
} elseif (isset($_GET["error"])) {
|
||||
$show = "login/showMessage";
|
||||
$message['MESSAGE'] = $_GET["error"];
|
||||
}
|
||||
$G_PUBLISH->AddContent("xmlform", "xmlform", $show, "", $message);
|
||||
G::RenderPage("publish", "blank");
|
||||
|
||||
480
workflow/engine/methods/webentry/access.php
Normal file
480
workflow/engine/methods/webentry/access.php
Normal file
@@ -0,0 +1,480 @@
|
||||
<?php
|
||||
/**
|
||||
* This page is the WebEntry Access Point.
|
||||
*/
|
||||
if (empty($weUid)) {
|
||||
http_response_code(403);
|
||||
return;
|
||||
}
|
||||
$conf = new Configurations();
|
||||
$configuration = $conf->getConfiguration(
|
||||
"ENVIRONMENT_SETTINGS",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
$outResult
|
||||
);
|
||||
$userInformationFormat = isset($outResult['format']) ? $outResult['format'] :
|
||||
'@lastName, @firstName (@userName)';
|
||||
$webEntryModel = \WebEntryPeer::retrieveByPK($weUid);
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="/lib/pmdynaform/libs/bootstrap-3.1.1/css/bootstrap.min.css">
|
||||
<title><?php echo htmlentities($webEntryModel->getWeCustomTitle()); ?></title>
|
||||
<?php
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
echo $oHeadPublisher->getExtJsStylesheets(SYS_SKIN);
|
||||
?>
|
||||
<style>
|
||||
html, body, iframe {
|
||||
border:none;
|
||||
width: 100%;
|
||||
top:0px;
|
||||
height:100%;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
iframe {
|
||||
position: absolute;
|
||||
border:none;
|
||||
width: 100%;
|
||||
top:60px;
|
||||
bottom:0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
.header {
|
||||
height: 60px;
|
||||
}
|
||||
.without-header .header {
|
||||
display:none;
|
||||
}
|
||||
.without-header #iframe {
|
||||
top:0px;
|
||||
}
|
||||
#avatar {
|
||||
background-color: buttonface;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid black;
|
||||
margin-left: 8px;
|
||||
margin-top: 4px;
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
#userInformation {
|
||||
display: inline-block;
|
||||
margin-top: 20px;
|
||||
position: absolute;
|
||||
margin-left: 64px;
|
||||
}
|
||||
#logout {
|
||||
margin-top: 20px;
|
||||
position: absolute;
|
||||
margin-left: 64px;
|
||||
right: 8px;
|
||||
}
|
||||
#messageBox{
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
margin-left: -260px;
|
||||
top: 96px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="without-header">
|
||||
<div class="header">
|
||||
<img id="avatar">
|
||||
<span class="logout"><a href="javascript:void(1)" id="userInformation"></a></span>
|
||||
<span class="logout"><a href="javascript:logout(1)" id="logout"><?php echo G::LoadTranslation('ID_LOGOUT'); ?></a></span>
|
||||
</div>
|
||||
<iframe id="iframe" ></iframe>
|
||||
<form id="messageBox" class="formDefault formWE" method="post" style="display: none;">
|
||||
<div class="borderForm" style="width:520px; padding-left:0; padding-right:0; border-width:1px;">
|
||||
<div class="boxTop"><div class="a"> </div><div class="b"> </div><div class="c"> </div></div>
|
||||
<div class="content" style="height:100%;">
|
||||
<table width="99%">
|
||||
<tbody><tr>
|
||||
<td valign="top">
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tbody><tr>
|
||||
<td class="FormTitle" colspan="2" align=""><span id="form[TITLE]" name="form[TITLE]" pmfieldtype="title"><?php echo G::LoadTranslation('ID_ERROR'); ?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="FormLabel" width="0"><label for="form[MESSAGE]"></label></td>
|
||||
<td class="FormFieldContent" width="520"><span id="errorMessage"></span></td>
|
||||
</tr>
|
||||
<tr id="messageBoxReset" style="display:none;">
|
||||
<td class="FormLabel" width="0"></td>
|
||||
<td class="FormFieldContent" width="520" style="text-align: right;"><button type="button" onclick="resetLocalData(true)"><?php echo G::LoadTranslation('ID_RESET'); ?></button></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
<div class="boxBottom"><div class="a"> </div><div class="b"> </div><div class="c"> </div></div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="/lib/js/jquery-1.10.2.min.js"></script>
|
||||
<script>
|
||||
var weData = {};
|
||||
var resetLocalData = function (reload) {
|
||||
localStorage.removeItem('weData');
|
||||
weData={};
|
||||
if (reload) {
|
||||
location.reload();
|
||||
}
|
||||
};
|
||||
var app = {
|
||||
$element:{
|
||||
avatar: $("#avatar").get(0),
|
||||
userInformation: $("#userInformation").get(0),
|
||||
errorMessage: $("#errorMessage").get(0)
|
||||
},
|
||||
setAvatar:function(src){
|
||||
this.$element.avatar.src=src;
|
||||
},
|
||||
getAvatar:function(){
|
||||
return this.$avatar.src;
|
||||
},
|
||||
setUserInformation:function(textContent){
|
||||
this.$element.userInformation.textContent=textContent;
|
||||
},
|
||||
getUserInformation:function(){
|
||||
return this.$element.userInformation.textContent;
|
||||
},
|
||||
loadUserInformation:function(userInformation) {
|
||||
var format = <?php echo G::json_encode($userInformationFormat); ?>;
|
||||
this.setAvatar(userInformation.image);
|
||||
for(var key in userInformation) {
|
||||
format = format.replace("@"+key, userInformation[key]);
|
||||
};
|
||||
this.setUserInformation(format);
|
||||
},
|
||||
setErrorMessage:function(textContent){
|
||||
this.$element.errorMessage.textContent=textContent;
|
||||
},
|
||||
getErrorMessage:function(){
|
||||
return this.$element.errorMessage.textContent;
|
||||
}
|
||||
};
|
||||
function logout(reload) {
|
||||
$.ajax({
|
||||
url: '../login/login',
|
||||
success: function () {
|
||||
if (reload) {
|
||||
resetLocalData();
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
!function () {
|
||||
var DEBUG_ENABLED = false;
|
||||
var processUid = <?php echo G::json_encode($webEntryModel->getProUid()); ?>;
|
||||
var tasUid = <?php echo G::json_encode($webEntryModel->getTasUid()); ?>;
|
||||
var weUid = <?php echo G::json_encode($webEntryModel->getWeUid()); ?>;
|
||||
var forceLogin = <?php echo G::json_encode($webEntryModel->getWeAuthentication()==='LOGIN_REQUIRED'); ?>;
|
||||
var isLogged = <?php echo G::json_encode(!empty($_SESSION['USER_LOGGED'])); ?>;
|
||||
var closeSession = <?php echo G::json_encode($webEntryModel->getWeCallback()==='CUSTOM_CLEAR'); ?>;
|
||||
var hideInformationBar = <?php echo G::json_encode(!!$webEntryModel->getWeHideInformationBar()); ?>;
|
||||
if (!forceLogin) {
|
||||
$("#logout").hide();
|
||||
}
|
||||
var onLoadIframe = function () {};
|
||||
var error = function(msg, showResetButton) {
|
||||
app.setErrorMessage(msg);
|
||||
if (showResetButton) {
|
||||
$('#messageBoxReset').show();
|
||||
} else {
|
||||
$('#messageBoxReset').hide();
|
||||
}
|
||||
$('#messageBox').show();
|
||||
};
|
||||
var log = function() {
|
||||
if (DEBUG_ENABLED) {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
};
|
||||
if (localStorage.weData) {
|
||||
try {
|
||||
weData = JSON.parse(localStorage.weData);
|
||||
if (weData.TAS_UID!==tasUid) {
|
||||
//TAS_UID is different, reset.
|
||||
resetLocalData();
|
||||
}
|
||||
} catch (e) {
|
||||
//corrupt weData, reset.
|
||||
resetLocalData();
|
||||
}
|
||||
}
|
||||
$("#iframe").load(function (event) {
|
||||
onLoadIframe(event);
|
||||
});
|
||||
var getContentDocument = function (iframe) {
|
||||
return (iframe.contentDocument) ?
|
||||
iframe.contentDocument :
|
||||
iframe.contentWindow.document;
|
||||
};
|
||||
var open = function (url, callback) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var iframe = document.getElementById("iframe");
|
||||
if (typeof callback === 'function') {
|
||||
iframe.style.opacity = 0;
|
||||
onLoadIframe = (function () {
|
||||
return function (event) {
|
||||
if (callback(event, resolve, reject)) {
|
||||
iframe.style.opacity = 1;
|
||||
}
|
||||
};
|
||||
})();
|
||||
} else {
|
||||
iframe.style.opacity = 1;
|
||||
onLoadIframe = function () {};
|
||||
}
|
||||
iframe.src = url;
|
||||
window.fullfill = function () {
|
||||
resolve.apply(this, arguments);
|
||||
};
|
||||
window.reject = function () {
|
||||
reject(this, arguments);
|
||||
};
|
||||
});
|
||||
};
|
||||
var verifyLogin = function () {
|
||||
if (forceLogin) {
|
||||
return login();
|
||||
} else {
|
||||
return anonymousLogin();
|
||||
}
|
||||
};
|
||||
var login = function () {
|
||||
return new Promise(function (logged, failure) {
|
||||
if (!isLogged) {
|
||||
log("login");
|
||||
open('../login/login?u=' + encodeURIComponent(location.pathname + '/../../webentry/logged'))
|
||||
.then(function (userInformation) {
|
||||
logged(userInformation);
|
||||
})
|
||||
.catch(function () {
|
||||
failure();
|
||||
});
|
||||
} else {
|
||||
log("logged");
|
||||
open('../webentry/logged')
|
||||
.then(function (userInformation) {
|
||||
logged(userInformation);
|
||||
})
|
||||
.catch(function () {
|
||||
failure();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
var anonymousLogin = function () {
|
||||
return new Promise(function (resolve, failure) {
|
||||
log("anonymousLogin");
|
||||
$.ajax({
|
||||
url: '../services/webentry/anonymousLogin',
|
||||
method: 'get',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
we_uid: weUid
|
||||
},
|
||||
success: function (userInformation) {
|
||||
resolve(userInformation);
|
||||
},
|
||||
error: function (data) {
|
||||
failure(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
var loadUserInformation = function (userInformation) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("userInformation:", userInformation);
|
||||
app.loadUserInformation(userInformation);
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
var checkWebEntryCase = function (userInformation) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (localStorage.weData) {
|
||||
log("checkWebEntryCase");
|
||||
$.ajax({
|
||||
url: '../services/webentry/checkCase',
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
app_uid: weData.APPLICATION,
|
||||
del_index: weData.INDEX
|
||||
},
|
||||
success: function (data) {
|
||||
log("check:", data);
|
||||
if (!data.check) {
|
||||
resetLocalData();
|
||||
}
|
||||
resolve();
|
||||
},
|
||||
error: function () {
|
||||
resetLocalData();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
};
|
||||
var initCase = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!hideInformationBar) {
|
||||
$("body").removeClass("without-header");
|
||||
}
|
||||
if (!localStorage.weData) {
|
||||
log("initCase");
|
||||
$.ajax({
|
||||
url: '../cases/casesStartPage_Ajax',
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'startCase',
|
||||
processId: processUid,
|
||||
taskId: tasUid
|
||||
},
|
||||
success: function (data) {
|
||||
data.TAS_UID = tasUid;
|
||||
localStorage.weData = JSON.stringify(data);
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log("openCase");
|
||||
resolve(weData);
|
||||
}
|
||||
});
|
||||
};
|
||||
var casesStep = function (data) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("casesStep");
|
||||
open(
|
||||
'../cases/cases_Open?APP_UID=' + encodeURIComponent(data.APPLICATION) +
|
||||
'&DEL_INDEX=' + encodeURIComponent(data.INDEX) +
|
||||
'&action=draft',
|
||||
function (event, resolve, reject) {
|
||||
var contentDocument = getContentDocument(event.target);
|
||||
var stepTitle = contentDocument.getElementsByTagName("title");
|
||||
if (!stepTitle || stepTitle[0].textContent === 'Runtime Exception.') {
|
||||
if (contentDocument.location.search.match(/&POSITION=10000&/)) {
|
||||
//Catch error if webentry was deleted.
|
||||
reject();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
).then(function (callbackUrl) {
|
||||
resolve(callbackUrl);
|
||||
})
|
||||
.catch(function () {
|
||||
reject();
|
||||
});
|
||||
});
|
||||
};
|
||||
var routeWebEntry = function (callbackUrl) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("routeWebEntry", callbackUrl);
|
||||
resolve(callbackUrl);
|
||||
});
|
||||
};
|
||||
var closeWebEntry = function (callbackUrl) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("closeWebEntry");
|
||||
resetLocalData();
|
||||
if (closeSession) {
|
||||
logout(false);
|
||||
}
|
||||
resolve(callbackUrl);
|
||||
});
|
||||
};
|
||||
var redirectCallback = function (callbackUrl) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("redirect");
|
||||
location.href = callbackUrl;
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
//Errors
|
||||
var errorLogin = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("errorLogin");
|
||||
var msg = <?php echo G::json_encode(G::LoadTranslation('ID_EXCEPTION_LOG_INTERFAZ')); ?>;
|
||||
msg = msg.replace("{0}", "LOGIN");
|
||||
error(msg);
|
||||
resetLocalData();
|
||||
});
|
||||
};
|
||||
var errorLoadUserInfo = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("errorLoadUserInfo");
|
||||
var msg = <?php echo G::json_encode(G::LoadTranslation('ID_EXCEPTION_LOG_INTERFAZ')); ?>;
|
||||
msg = msg.replace("{0}", "USR001");
|
||||
error(msg);
|
||||
resetLocalData();
|
||||
});
|
||||
};
|
||||
var errorCheckWebEntry = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("errorCheckWebEntry");
|
||||
var msg = <?php echo G::json_encode(G::LoadTranslation('ID_EXCEPTION_LOG_INTERFAZ')); ?>;
|
||||
msg = msg.replace("{0}", "WEE001");
|
||||
error(msg);
|
||||
resetLocalData();
|
||||
});
|
||||
};
|
||||
var errorInitCase = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("error Init case");
|
||||
var msg = <?php echo G::json_encode(G::LoadTranslation('ID_EXCEPTION_LOG_INTERFAZ')); ?>;
|
||||
msg = msg.replace("{0}", "INIT001");
|
||||
error(msg);
|
||||
resetLocalData();
|
||||
});
|
||||
};
|
||||
var errorStep = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("Step Error");
|
||||
var msg = <?php echo G::json_encode(G::LoadTranslation('ID_EXCEPTION_LOG_INTERFAZ')); ?>;
|
||||
msg = msg.replace("{0}", "STEP001");
|
||||
error(msg);
|
||||
resetLocalData();
|
||||
});
|
||||
};
|
||||
var errorRouting = function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
log("errorRouting");
|
||||
var msg = <?php echo G::json_encode(G::LoadTranslation('ID_EXCEPTION_LOG_INTERFAZ')); ?>;
|
||||
msg = msg.replace("{0}", "ROU001");
|
||||
error(msg);
|
||||
resetLocalData();
|
||||
});
|
||||
};
|
||||
//Execute WebEntry Flow
|
||||
verifyLogin().catch(errorLogin)
|
||||
.then(loadUserInformation).catch(errorLoadUserInfo)
|
||||
.then(checkWebEntryCase).catch(errorCheckWebEntry)
|
||||
.then(initCase).catch(errorInitCase)
|
||||
.then(casesStep).catch(errorStep)
|
||||
.then(routeWebEntry).catch(errorRouting)
|
||||
.then(closeWebEntry)
|
||||
.then(redirectCallback);
|
||||
}();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
23
workflow/engine/methods/webentry/logged.php
Normal file
23
workflow/engine/methods/webentry/logged.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
<?php
|
||||
/**
|
||||
* This page is redirected from the login page.
|
||||
*/
|
||||
G::LoadClass('pmFunctions');
|
||||
$userUid = $_SESSION['USER_LOGGED'];
|
||||
$userInfo = PMFInformationUser($userUid);
|
||||
$result = [
|
||||
'user_logged' => $userUid,
|
||||
'userName' => $userInfo['username'],
|
||||
'firstName' => $userInfo['firstname'],
|
||||
'lastName' => $userInfo['lastname'],
|
||||
'mail' => $userInfo['mail'],
|
||||
'image' => '../users/users_ViewPhoto?t='.microtime(true),
|
||||
];
|
||||
?>
|
||||
parent.fullfill(<?= G::json_encode($result) ?>);
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
@@ -321,9 +321,6 @@ class WebEntry
|
||||
//Verify if User is assigned to Task
|
||||
$projectUser = new \ProcessMaker\BusinessModel\ProjectUser();
|
||||
|
||||
if (!$projectUser->userIsAssignedToTask($arrayData["USR_UID"], $arrayDataMain["TAS_UID"])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_HAVE_ACTIVITY_ASSIGNED", array($arrayUserData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"])));
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
@@ -402,6 +399,12 @@ class WebEntry
|
||||
|
||||
$fileContent = "<?php\n\n";
|
||||
$fileContent .= "global \$_DBArray;\n";
|
||||
$fileContent .= '$webEntry = new ' . WebEntry::class . ";\n";
|
||||
$fileContent .= "\$processUid = \"" . $processUid . "\";\n";
|
||||
$fileContent .= "\$weUid = \"" . $arrayWebEntryData['WE_UID'] . "\";\n";
|
||||
$fileContent .= 'if (!$webEntry->isWebEntryOne($weUid)) {'."\n";
|
||||
$fileContent .= " return require(PATH_METHODS . 'webentry/access.php');\n";
|
||||
$fileContent .= "}\n";
|
||||
$fileContent .= "if (!isset(\$_DBArray)) {\n";
|
||||
$fileContent .= " \$_DBArray = array();\n";
|
||||
$fileContent .= "}\n";
|
||||
@@ -1067,5 +1070,56 @@ class WebEntry
|
||||
. "\n";
|
||||
file_put_contents($pathFileName, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if web entry is a single dynaform without login required.
|
||||
*
|
||||
* @param type $processUid
|
||||
* @param type $weUid
|
||||
* @return boolean
|
||||
*/
|
||||
public function isWebEntryOne($weUid)
|
||||
{
|
||||
$webEntry = \WebEntryPeer::retrieveByPK($weUid);
|
||||
return $webEntry->getWeType()==='SINGLE' && $webEntry->getWeAuthentication()==='ANONYMOUS';
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if a Task is and Web Entry auxiliar task.
|
||||
*
|
||||
* @param type $tasUid
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTaskAWebEntry($tasUid)
|
||||
{
|
||||
return substr($tasUid, 0, 4) === 'wee-';
|
||||
}
|
||||
|
||||
public function getCallbackUrlByTask($tasUid)
|
||||
{
|
||||
$criteria = new \Criteria;
|
||||
$criteria->add(\WebEntryPeer::TAS_UID, $tasUid);
|
||||
$webEntry = \WebEntryPeer::doSelectOne($criteria);
|
||||
if ($webEntry->getWeCallback()==='CUSTOM' || $webEntry->getWeCallback()==='CUSTOM_CLEAR') {
|
||||
return $webEntry->getWeCallbackUrl();
|
||||
} else {
|
||||
return '../services/webentry/completed?message=@%_DELEGATION_MESSAGE';
|
||||
}
|
||||
}
|
||||
|
||||
public function getDelegationMessage($data)
|
||||
{
|
||||
$appNumber = $data['APP_NUMBER'];
|
||||
$appUid = $data['APPLICATION'];
|
||||
$message = "\n".\G::LoadTranslation('ID_CASE_CREATED').
|
||||
"\n".\G::LoadTranslation('ID_CASE_NUMBER').": $appNumber".
|
||||
"\n".\G::LoadTranslation('ID_CASESLIST_APP_UID').": $appUid";
|
||||
foreach($data['_DELEGATION_DATA'] as $task) {
|
||||
$message.="\n".\G::LoadTranslation('ID_CASE_ROUTED_TO').": ".
|
||||
$task['NEXT_TASK']['TAS_TITLE'].
|
||||
"(".htmlentities($task['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME']).")";
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<script>
|
||||
if({$derivationResponse|@json_encode})
|
||||
parent.fullfill({$webEntryUrlEvaluated|@json_encode});
|
||||
else
|
||||
parent.reject();
|
||||
</script>
|
||||
Reference in New Issue
Block a user