HOR-3214
WebEntry2 Execution Screen
This commit is contained in:
@@ -54,8 +54,8 @@
|
||||
<var name="DB_NAME" value="wf_test" />
|
||||
<var name="DB_USER" value="root" />
|
||||
<var name="DB_PASS" value="" />
|
||||
<var name="PATH_DB" value="./test_shared/workflow_data/sites/" />
|
||||
<var name="PATH_DATA" value="./test_shared/workflow_data/sites/" />
|
||||
<var name="PATH_DB" value="./test_shared/sites/" />
|
||||
<var name="PATH_DATA" value="./test_shared/" />
|
||||
<var name="APP_HOST" value="localhost" />
|
||||
<var name="HTTPS" value="off" />
|
||||
</php>
|
||||
|
||||
@@ -40,7 +40,7 @@ class WorkflowTestCase extends TestCase
|
||||
|
||||
/**
|
||||
* Import a process to the database.
|
||||
*
|
||||
*
|
||||
* @param type $filename ProcessMaker file to be imported
|
||||
* @return string PRO_UID
|
||||
*/
|
||||
@@ -81,7 +81,7 @@ class WorkflowTestCase extends TestCase
|
||||
|
||||
/**
|
||||
* Clear all the translated messages loaded.
|
||||
*
|
||||
*
|
||||
* @global array $translation
|
||||
*/
|
||||
protected function clearTranslations()
|
||||
|
||||
@@ -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,28 @@ try {
|
||||
$aFields["TASK"][$sKey]["NEXT_TASK"]["TAS_TITLE"] = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_MESSAGE_EVENT");
|
||||
}
|
||||
|
||||
//SKIP ASSIGN SCRREN
|
||||
if (!empty($aFields['TASK'][1])) {
|
||||
$currentTask = $aFields['TASK'][1];
|
||||
$isWebEntry = $bmWebEntry->isTaskAWebEntry($currentTask['TAS_UID']);
|
||||
$skipRoutingScreen = $isWebEntry;
|
||||
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'])){
|
||||
|
||||
@@ -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/check_case.php
Normal file
35
workflow/engine/methods/services/webentry/check_case.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");
|
||||
|
||||
481
workflow/engine/methods/webentry/access.php
Normal file
481
workflow/engine/methods/webentry/access.php
Normal file
File diff suppressed because it is too large
Load Diff
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>
|
||||
@@ -322,7 +322,7 @@ class WebEntry
|
||||
$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"])));
|
||||
//throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_HAVE_ACTIVITY_ASSIGNED", array($arrayUserData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"])));
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -402,6 +402,13 @@ 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 .= "\$tasUid = \"" . $arrayWebEntryData['TAS_UID'] . "\";\n";
|
||||
$fileContent .= 'if (!$webEntry->isWebEntryOne($processUid, $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 +1074,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($processUid, $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 type
|
||||
*/
|
||||
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 = "\nCase created in ProcessMaker".
|
||||
"\nCase Number: $appNumber".
|
||||
"\nCase Id: $appUid";
|
||||
foreach($data['_DELEGATION_DATA'] as $task) {
|
||||
$message.="\nCase routed to: ".
|
||||
$task['NEXT_TASK']['TAS_TITLE'].
|
||||
"(".htmlentities($task['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME']).")";
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
322
workflow/engine/templates/webentry/access.php
Normal file
322
workflow/engine/templates/webentry/access.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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