diff --git a/phpunit.xml b/phpunit.xml index bdec9bbb5..6978f61fb 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -54,8 +54,8 @@ - - + + diff --git a/tests/WorkflowTestCase.php b/tests/WorkflowTestCase.php index aecfbd5a1..8551e5cc4 100644 --- a/tests/WorkflowTestCase.php +++ b/tests/WorkflowTestCase.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() diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index 6ff7859ba..e4c26d8ac 100644 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -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'])){ diff --git a/workflow/engine/methods/services/webentry/anonymous_login.php b/workflow/engine/methods/services/webentry/anonymous_login.php new file mode 100644 index 000000000..2b8387149 --- /dev/null +++ b/workflow/engine/methods/services/webentry/anonymous_login.php @@ -0,0 +1,44 @@ +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); diff --git a/workflow/engine/methods/services/webentry/check_case.php b/workflow/engine/methods/services/webentry/check_case.php new file mode 100644 index 000000000..4165522d8 --- /dev/null +++ b/workflow/engine/methods/services/webentry/check_case.php @@ -0,0 +1,35 @@ +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); diff --git a/workflow/engine/methods/services/webentry/completed.php b/workflow/engine/methods/services/webentry/completed.php new file mode 100644 index 000000000..eb920be82 --- /dev/null +++ b/workflow/engine/methods/services/webentry/completed.php @@ -0,0 +1,18 @@ +AddContent("xmlform", "xmlform", $show, "", $message); +G::RenderPage("publish", "blank"); + diff --git a/workflow/engine/methods/webentry/access.php b/workflow/engine/methods/webentry/access.php new file mode 100644 index 000000000..4631cadb3 --- /dev/null +++ b/workflow/engine/methods/webentry/access.php @@ -0,0 +1,481 @@ +getConfiguration( + "ENVIRONMENT_SETTINGS", + "", + "", + "", + "", + $outResult +); +$userInformationFormat = isset($outResult['format']) ? $outResult['format'] : + '@lastName, @firstName (@userName)'; +$webEntryModel = \WebEntryPeer::retrieveByPK($weUid); +?> + + + + <?= htmlentities($webEntryModel->getWeCustomTitle()) ?> + getExtJsStylesheets(SYS_SKIN); + ?> + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/workflow/engine/methods/webentry/logged.php b/workflow/engine/methods/webentry/logged.php new file mode 100644 index 000000000..b9e88309d --- /dev/null +++ b/workflow/engine/methods/webentry/logged.php @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index dc5daefea..5df234297 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -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 = "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; + } } diff --git a/workflow/engine/templates/webentry/access.php b/workflow/engine/templates/webentry/access.php new file mode 100644 index 000000000..4d0091e67 --- /dev/null +++ b/workflow/engine/templates/webentry/access.php @@ -0,0 +1,322 @@ + + + getExtJsStylesheets(SYS_SKIN)); + ?> + + + + getConfiguration("ENVIRONMENT_SETTINGS", "", "", "", "", $outResult); + ?> +
+ + + +
+ + + + + + \ No newline at end of file diff --git a/workflow/engine/templates/webentry/cases_ScreenDerivation.html b/workflow/engine/templates/webentry/cases_ScreenDerivation.html new file mode 100644 index 000000000..184e81476 --- /dev/null +++ b/workflow/engine/templates/webentry/cases_ScreenDerivation.html @@ -0,0 +1,6 @@ + \ No newline at end of file