WebEntry2 Execution Screen
This commit is contained in:
davidcallizaya
2017-06-02 13:07:52 -04:00
parent 4f6035a3b0
commit c9c49c2767
11 changed files with 1018 additions and 5 deletions

View File

@@ -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>

View File

@@ -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()

View File

@@ -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'])){

View 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);

View 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);

View 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");

File diff suppressed because it is too large Load Diff

View 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>

View File

@@ -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;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
<script>
if({$derivationResponse|@json_encode})
parent.fullfill({$webEntryUrlEvaluated|@json_encode});
else
parent.reject();
</script>