From 13beb0166caa6aaf308ed0a8381d54cb5f30b983 Mon Sep 17 00:00:00 2001 From: davidcallizaya Date: Fri, 19 May 2017 13:38:37 -0400 Subject: [PATCH 1/6] HOR-3207 Change web entry model. --- tests/bootstrap.php | 2 +- workflow/engine/src/ProcessMaker/BusinessModel/Process.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 0930c334a..e6be9e86c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -236,4 +236,4 @@ require_once(PATH_CLASSES.'model/Task.php'); global $RBAC; $RBAC = \RBAC::getSingleton( PATH_DATA, session_id() ); $RBAC->sSystem = 'PROCESSMAKER'; -\G::LoadClass('pmFunctions'); +\G::LoadClass('pmFunctions'); \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Process.php b/workflow/engine/src/ProcessMaker/BusinessModel/Process.php index fc8ff59e3..51a0800e4 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Process.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Process.php @@ -171,6 +171,7 @@ class Process $fieldNameAux = (isset($arrayFieldNameForException[$arrayFieldDefinition[$fieldName]['fieldNameAux']]))? $arrayFieldNameForException[$arrayFieldDefinition[$fieldName]['fieldNameAux']] : $fieldName; if ($arrayFieldDefinition[$fieldName]["required"] && !isset($arrayData[$fieldName])) { + var_dump($fieldNameAux); throw new \Exception(\G::LoadTranslation('ID_UNDEFINED_VALUE_IS_REQUIRED', [$fieldNameAux])); } } From 4f6035a3b0f99fd695ed735c2005762cb5d6f536 Mon Sep 17 00:00:00 2001 From: davidcallizaya Date: Mon, 22 May 2017 11:26:15 -0400 Subject: [PATCH 2/6] HOR-3207 Complete tests, and check validations for WebEntry CRUD. --- tests/bootstrap.php | 2 +- workflow/engine/src/ProcessMaker/BusinessModel/Process.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e6be9e86c..0930c334a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -236,4 +236,4 @@ require_once(PATH_CLASSES.'model/Task.php'); global $RBAC; $RBAC = \RBAC::getSingleton( PATH_DATA, session_id() ); $RBAC->sSystem = 'PROCESSMAKER'; -\G::LoadClass('pmFunctions'); \ No newline at end of file +\G::LoadClass('pmFunctions'); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Process.php b/workflow/engine/src/ProcessMaker/BusinessModel/Process.php index 51a0800e4..fc8ff59e3 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Process.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Process.php @@ -171,7 +171,6 @@ class Process $fieldNameAux = (isset($arrayFieldNameForException[$arrayFieldDefinition[$fieldName]['fieldNameAux']]))? $arrayFieldNameForException[$arrayFieldDefinition[$fieldName]['fieldNameAux']] : $fieldName; if ($arrayFieldDefinition[$fieldName]["required"] && !isset($arrayData[$fieldName])) { - var_dump($fieldNameAux); throw new \Exception(\G::LoadTranslation('ID_UNDEFINED_VALUE_IS_REQUIRED', [$fieldNameAux])); } } From c9c49c276717c6808d0d68a53524f5ab7a2f5651 Mon Sep 17 00:00:00 2001 From: davidcallizaya Date: Fri, 2 Jun 2017 13:07:52 -0400 Subject: [PATCH 3/6] HOR-3214 WebEntry2 Execution Screen --- phpunit.xml | 4 +- tests/WorkflowTestCase.php | 4 +- workflow/engine/methods/cases/cases_Step.php | 26 + .../services/webentry/anonymous_login.php | 44 ++ .../methods/services/webentry/check_case.php | 35 ++ .../methods/services/webentry/completed.php | 18 + workflow/engine/methods/webentry/access.php | 481 ++++++++++++++++++ workflow/engine/methods/webentry/logged.php | 23 + .../ProcessMaker/BusinessModel/WebEntry.php | 60 ++- workflow/engine/templates/webentry/access.php | 322 ++++++++++++ .../webentry/cases_ScreenDerivation.html | 6 + 11 files changed, 1018 insertions(+), 5 deletions(-) create mode 100644 workflow/engine/methods/services/webentry/anonymous_login.php create mode 100644 workflow/engine/methods/services/webentry/check_case.php create mode 100644 workflow/engine/methods/services/webentry/completed.php create mode 100644 workflow/engine/methods/webentry/access.php create mode 100644 workflow/engine/methods/webentry/logged.php create mode 100644 workflow/engine/templates/webentry/access.php create mode 100644 workflow/engine/templates/webentry/cases_ScreenDerivation.html 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 From 6c316bf1616b2f8d4facdba0f3f3914c3cd24ced Mon Sep 17 00:00:00 2001 From: davidcallizaya Date: Fri, 2 Jun 2017 13:18:43 -0400 Subject: [PATCH 4/6] HOR-3214 Removed User validation to do not truncate importation process when the user does not exists in the target workspace. --- workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index 5df234297..05f3ef6b2 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -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; From 76427ca571bbb39f14a9bbbeed2011365dd2f70f Mon Sep 17 00:00:00 2001 From: davidcallizaya Date: Fri, 2 Jun 2017 18:27:50 -0400 Subject: [PATCH 5/6] HOR-3214 Fixed the code reviews. --- .../translations/english/processmaker.en.po | 12 + workflow/engine/data/mysql/insert.sql | 4 +- workflow/engine/methods/cases/cases_Step.php | 3 +- ...anonymous_login.php => anonymousLogin.php} | 0 .../{check_case.php => checkCase.php} | 0 workflow/engine/methods/webentry/access.php | 101 +++--- .../ProcessMaker/BusinessModel/WebEntry.php | 15 +- workflow/engine/templates/webentry/access.php | 322 ------------------ 8 files changed, 73 insertions(+), 384 deletions(-) rename workflow/engine/methods/services/webentry/{anonymous_login.php => anonymousLogin.php} (100%) rename workflow/engine/methods/services/webentry/{check_case.php => checkCase.php} (100%) delete mode 100644 workflow/engine/templates/webentry/access.php diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index c6f0c90f5..92858bd7d 100644 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -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 diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 2f96e7128..f7f6545cf 100644 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -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','','',' ','') , diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index e4c26d8ac..761160cf3 100644 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -1109,11 +1109,10 @@ try { $aFields["TASK"][$sKey]["NEXT_TASK"]["TAS_TITLE"] = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_MESSAGE_EVENT"); } - //SKIP ASSIGN SCRREN + //SKIP ASSIGN SCREEN 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']; diff --git a/workflow/engine/methods/services/webentry/anonymous_login.php b/workflow/engine/methods/services/webentry/anonymousLogin.php similarity index 100% rename from workflow/engine/methods/services/webentry/anonymous_login.php rename to workflow/engine/methods/services/webentry/anonymousLogin.php diff --git a/workflow/engine/methods/services/webentry/check_case.php b/workflow/engine/methods/services/webentry/checkCase.php similarity index 100% rename from workflow/engine/methods/services/webentry/check_case.php rename to workflow/engine/methods/services/webentry/checkCase.php diff --git a/workflow/engine/methods/webentry/access.php b/workflow/engine/methods/webentry/access.php index 4631cadb3..b25770a58 100644 --- a/workflow/engine/methods/webentry/access.php +++ b/workflow/engine/methods/webentry/access.php @@ -22,7 +22,7 @@ $webEntryModel = \WebEntryPeer::retrieveByPK($weUid); - <?= htmlentities($webEntryModel->getWeCustomTitle()) ?> + <?php echo htmlentities($webEntryModel->getWeCustomTitle()); ?> getExtJsStylesheets(SYS_SKIN); @@ -89,11 +89,11 @@ $webEntryModel = \WebEntryPeer::retrieveByPK($weUid);
- +