PMC-1312 Suggest fields on a grid form with MSSQL connection created in ProcessMaker2.x is displaying an alert in preview mode and when running cases in ProcessMaker 3.3.x.

This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-11-05 12:16:40 -04:00
parent 7edc2674fe
commit 652a5b21c5
7 changed files with 327 additions and 34 deletions

View File

@@ -1,28 +1,4 @@
<?php <?php
/**
* defaultAjax.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
/*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/
use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Plugins\PluginRegistry;
@@ -30,8 +6,6 @@ if (isset($_SESSION['CURRENT_PAGE_INITILIZATION'])) {
eval($_SESSION['CURRENT_PAGE_INITILIZATION']); eval($_SESSION['CURRENT_PAGE_INITILIZATION']);
} }
// $json=new Services_JSON();
if (!defined('XMLFORM_AJAX_PATH')) { if (!defined('XMLFORM_AJAX_PATH')) {
define('XMLFORM_AJAX_PATH', PATH_XMLFORM); define('XMLFORM_AJAX_PATH', PATH_XMLFORM);
} }
@@ -117,7 +91,11 @@ for ($r = 0; $r < count($newValues); $r++) {
} else { } else {
foreach ($v[$_POST['row']] as $k1 => $v1) { foreach ($v[$_POST['row']] as $k1 => $v1) {
$myDependentFields = subDependencies($k1, $G_FORM, $aux, $_POST['grid']); $myDependentFields = subDependencies($k1, $G_FORM, $aux, $_POST['grid']);
$_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1; $_SESSION[$G_FORM->id][$_POST['grid']] = [
$_POST['row'] => [
$k1 => $v1
]
];
$G_FORM->values[$_POST['grid']][$_POST['row']][$k1] = $v1; $G_FORM->values[$_POST['grid']][$_POST['row']][$k1] = $v1;
} }
} }

View File

@@ -28,6 +28,7 @@
<filter> <filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false"> <whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">./gulliver</directory>
<directory suffix=".php">./workflow/engine/classes</directory> <directory suffix=".php">./workflow/engine/classes</directory>
<directory suffix=".php">./workflow/engine/src</directory> <directory suffix=".php">./workflow/engine/src</directory>
</whitelist> </whitelist>

View File

@@ -53,6 +53,8 @@ define('PATH_HTML', PATH_HOME . 'public_html/');
define('PATH_SMARTY_C', PATH_TRUNK . '/shared/compiled/smarty/c'); define('PATH_SMARTY_C', PATH_TRUNK . '/shared/compiled/smarty/c');
define('PATH_SMARTY_CACHE', PATH_TRUNK . '/shared/compiled/smarty/cache'); define('PATH_SMARTY_CACHE', PATH_TRUNK . '/shared/compiled/smarty/cache');
define('PATH_THIRDPARTY', PATH_TRUNK . '/thirdparty/'); define('PATH_THIRDPARTY', PATH_TRUNK . '/thirdparty/');
define("URL_KEY", 'c0l0s40pt1mu59r1m3');
define("PATH_XMLFORM", PATH_CORE . "xmlform" . PATH_SEP);
// Set Time Zone // Set Time Zone
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int) (env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1; $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int) (env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;

View File

@@ -0,0 +1,8 @@
{
"function": "reloadField",
"form": "Wlp0bHBXS2tiR2FtcVpXaHBwbHcxV09tWlpObHBXaWphV2locDJpbHEyWm9wV1dlWkpabG4yQ2phWlNrcFpXbTFteHNvcGJSbUp0Z29tQ21iR1drcTJmTTZhS3BvbMKwbG9NOA______",
"fields": "[%7B%22suggest2%22%3A%22C%22%7D]",
"grid": "Grid",
"gridField": "%7B%22suggest1%22%3A%22BO%22%7D",
"row": "1"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<dynaForm type="xmlform" name="2859218665d41d7c2920598058137861/3411353005d41d9a730ede8060385476" width="500" enabletemplate="0" mode="" nextstepsave="prompt">
<BUG type="title" required="0" readonly="0" optgroup="0">
<en>BUG</en>
</BUG>
<TEST type="text" maxlength="64" validate="Any" required="0" readonly="0" size="15" mode="edit" optgroup="0">
<en>TEST</en>
</TEST>
<SUGGEST type="suggest" required="0" size="15" mode="edit" sqlconnection="4898432885d41d9921cea61001765691" maxresults="6" searchtype="*searchtype*" table="0" readonly="0" optgroup="0"><![CDATA[SELECT IC_UID, IC_NAME
FROM ISO_COUNTRY]]><en>SUGGEST</en></SUGGEST>
<SUBMIT type="submit" required="0" readonly="0" optgroup="0">
<en>SUBMIT</en>
</SUBMIT>
<Grid type="grid" xmlgrid="2859218665d41d7c2920598058137861/4923800155da71a732a4207031768424" addrow="1" deleterow="1" required="0" readonly="0" resizable="0" optgroup="0"/>
</dynaForm>

View File

@@ -0,0 +1,47 @@
<?php
namespace Tests\unit\gulliver\methods;
use Tests\TestCase;
class DefaultAjaxTest extends TestCase
{
/**
* This gets data from a json file.
* @param string $pathData
* @return array
*/
private function getDataFromFile(string $pathData): array
{
$pathData = PATH_TRUNK . "/tests/resources/{$pathData}";
$data = file_get_contents($pathData);
$result = json_decode($data, JSON_OBJECT_AS_ARRAY);
return $result;
}
/**
* This should get the data for control suggest in classic process.
* @test
*/
public function this_should_get_the_data_for_control_suggest_in_classic_process()
{
$_POST = $this->getDataFromFile("simpleClassicPostData.json");
$_SESSION = $this->getDataFromFile("simpleClassicSessionData.json");
$_SESSION["CURRENT_PAGE_INITILIZATION"] = "";
$pathName = PATH_XMLFORM . "2859218665d41d7c2920598058137861";
$pathFileName = "{$pathName}/3411353005d41d9a730ede8060385476_tmp0.xml";
if (!is_dir($pathName)) {
mkdir($pathName);
}
$data = file_get_contents(PATH_TRUNK . "/tests/resources/simpleClassicXmlFormData.xml");
file_put_contents($pathFileName, $data);
require_once PATH_TRUNK . '/gulliver/methods/defaultAjax.php';
$this->expectOutputString('[]');
unlink($pathFileName);
rmdir($pathName);
}
}