From 87de43d90acff22e56162da5b2e5c96eecaa2593 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Thu, 4 May 2017 10:59:38 -0400 Subject: [PATCH] HOR-3017 --- workflow/engine/classes/class.processMap.php | 4 +- .../processes/processes_webEntryGenerate.php | 24 +++++++++++- .../ProcessMaker/BusinessModel/WebEntry.php | 38 ++++++++++++++----- .../templates/processes/webentryPost.tpl | 19 ++-------- 4 files changed, 59 insertions(+), 26 deletions(-) diff --git a/workflow/engine/classes/class.processMap.php b/workflow/engine/classes/class.processMap.php index e25409106..b5546c23f 100644 --- a/workflow/engine/classes/class.processMap.php +++ b/workflow/engine/classes/class.processMap.php @@ -2916,13 +2916,15 @@ class processMap if ($archivo != '..') { $one = 0; $two = 0; + $three = 0; $alink = $link . $archivo; $one = count(explode('wsClient.php', $archivo)); $two = count(explode('Post.php', $archivo)); + $three = count(explode('Info.php', $archivo)); - if ($one == 1 && $two == 1) { + if ($one == 1 && $two == 1 && $three == 1) { $arlink = "" . $alink . ""; $linkdelete = sprintf("delete", $alink, $archivo, $sProcessUID); $row[] = array('W_LINK' => $arlink, 'W_FILENAME' => $archivo, 'W_PRO_UID' => $sProcessUID ); diff --git a/workflow/engine/methods/processes/processes_webEntryGenerate.php b/workflow/engine/methods/processes/processes_webEntryGenerate.php index 551c0cd87..7e42df04b 100644 --- a/workflow/engine/methods/processes/processes_webEntryGenerate.php +++ b/workflow/engine/methods/processes/processes_webEntryGenerate.php @@ -60,7 +60,28 @@ try { $sContent .= "\$G_PUBLISH->AddContent('dynaform', 'xmlform', '" . $sPRO_UID . '/' . $sDYNAFORM . "', '', array(), '" . $dynTitle . 'Post.php' . "');\n"; $sContent .= "G::RenderPage('publish', 'blank');"; file_put_contents( $pathProcess . $dynTitle . '.php', $sContent ); - //creating the second file, the post file who receive the post form. + + //Create file to display information and prevent resubmission data (Post/Redirect/Get). + $fileNamePreventResubmission = $pathProcess . $dynTitle . "Info.php"; + $filePreventResubmission = "" + . "AddContent(\"xmlform\", \"xmlform\", \$show, \"\", \$message);\n" + . "G::RenderPage(\"publish\", \"blank\");\n" + . "\n"; + file_put_contents($fileNamePreventResubmission, $filePreventResubmission); + +//creating the second file, the post file who receive the post form. $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl'; $template = new TemplatePower( $pluginTpl ); $template->prepare(); @@ -72,6 +93,7 @@ try { $template->assign( 'wsUser', $sWS_USER ); $template->assign( 'wsPass', Bootstrap::hashPassword($sWS_PASS, '', true) ); $template->assign( 'wsRoundRobin', $sWS_ROUNDROBIN ); + $template->assign( 'weTitle', $dynTitle); G::auditLog('WebEntry','Generate web entry with web services ('.$dynTitle.'.php) in process "'.$resultProcess['PRO_TITLE'].'"'); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index a87056233..91c5ef326 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -398,27 +398,46 @@ class WebEntry $weTitle = $this->sanitizeFilename($arrayWebEntryData["WE_TITLE"]); $fileName = $weTitle; - $fileContent = " \"" . $arrayWebEntryData["DYN_UID"] . "\"));\n"; - $fileContent .= "if (\$a->isResponsive()) {"; - $fileContent .= " \$a->printWebEntry(\"" . $fileName . "Post.php\");"; - $fileContent .= "} else {"; - $fileContent .= " \$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . PATH_SEP . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n"; - $fileContent .= " G::RenderPage(\"publish\", \"blank\");"; - $fileContent .= "}"; + $fileContent .= "if (\$a->isResponsive()) {\n"; + $fileContent .= " \$a->printWebEntry(\"" . $fileName . "Post.php\");\n"; + $fileContent .= "} else {\n"; + $fileContent .= " \$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . PATH_SEP . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n"; + $fileContent .= " G::RenderPage(\"publish\", \"blank\");\n"; + $fileContent .= "}\n"; file_put_contents($pathDataPublicProcess . PATH_SEP . $fileName . ".php", $fileContent); + //Create file to display information and prevent resubmission data (Post/Redirect/Get). + $fileNamePreventResubmission = $pathDataPublicProcess . PATH_SEP . $weTitle . "Info.php"; + $filePreventResubmission = "" + . "AddContent(\"xmlform\", \"xmlform\", \$show, \"\", \$message);\n" + . "G::RenderPage(\"publish\", \"blank\");\n" + . "\n"; + file_put_contents($fileNamePreventResubmission, $filePreventResubmission); + //Creating the second file, the post file who receive the post form. $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentryPost.tpl"; @@ -433,6 +452,7 @@ class WebEntry $template->assign("wsUser", $usrUsername); $template->assign("wsPass", \Bootstrap::getPasswordHashType() . ':' . $usrPassword); $template->assign("wsRoundRobin", $wsRoundRobin); + $template->assign("weTitle", $weTitle); if ($webEntryInputDocumentAccess == 0) { //Restricted to process permissions diff --git a/workflow/engine/templates/processes/webentryPost.tpl b/workflow/engine/templates/processes/webentryPost.tpl index 92785f237..ae6b5f0a2 100644 --- a/workflow/engine/templates/processes/webentryPost.tpl +++ b/workflow/engine/templates/processes/webentryPost.tpl @@ -16,13 +16,6 @@ define("WS_USER_PASS", "{wsPass}"); define("WS_ROUNDROBIN", "{wsRoundRobin}"); try { - if (isset($_SESSION["__submitFormWebEntry__"]) && $_SESSION["__submitFormWebEntry__"] === true) { - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $_SESSION["__submitFormWebEntryData__"]); - G::RenderPage("publish", "blank"); - exit(); - } - @include_once ("wsClient.php"); if (!function_exists("ws_open")){ @@ -200,15 +193,11 @@ try { exit( 0 ); } /*----------------------------------********---------------------------------*/ - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent("xmlform", "xmlform", "login/showInfo", "", $aMessage); - G::RenderPage("publish", "blank"); - $_SESSION["__submitFormWebEntry__"] = true; - $_SESSION["__submitFormWebEntryData__"] = $aMessage; + $_SESSION["__webEntrySuccess__"] = $aMessage; + header("location:{weTitle}Info.php"); } catch (Exception $e) { - $G_PUBLISH = new Publisher(); $suggest_message = "This web entry should be regenerated, please contact to your system administrator."; $aMessage["MESSAGE"] = "
" . $e->getMessage() . "
" . $suggest_message . "
"; - $G_PUBLISH->AddContent("xmlform", "xmlform", "login/showMessage", "", $aMessage); - G::RenderPage("publish", "blank"); + $_SESSION["__webEntryError__"] = $aMessage; + header("location:{weTitle}Info.php"); }