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:
@@ -1,28 +1,4 @@
|
||||
<?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;
|
||||
|
||||
@@ -30,8 +6,6 @@ if (isset($_SESSION['CURRENT_PAGE_INITILIZATION'])) {
|
||||
eval($_SESSION['CURRENT_PAGE_INITILIZATION']);
|
||||
}
|
||||
|
||||
|
||||
// $json=new Services_JSON();
|
||||
if (!defined('XMLFORM_AJAX_PATH')) {
|
||||
define('XMLFORM_AJAX_PATH', PATH_XMLFORM);
|
||||
}
|
||||
@@ -63,11 +37,11 @@ $G_FORM->values = isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array
|
||||
$newValues = (Bootstrap::json_decode(urlDecode(stripslashes($_POST['fields']))));
|
||||
|
||||
if (isset($_POST['grid'])) {
|
||||
$_POST['row'] = (int)$_POST['row'];
|
||||
$_POST['row'] = (int) $_POST['row'];
|
||||
$aAux = array();
|
||||
|
||||
foreach ($newValues as $sKey => $newValue) {
|
||||
$newValue = (array)$newValue;
|
||||
$newValue = (array) $newValue;
|
||||
$aKeys = array_keys($newValue);
|
||||
if (count($aKeys) > 0) {
|
||||
$aValues = array();
|
||||
@@ -88,7 +62,7 @@ if (count($newValues) > 1 && isset($_POST['grid'])) {
|
||||
for ($r2 = 1; $r2 <= $_POST['row']; $r2++) {
|
||||
foreach ($values as $class => $value) {
|
||||
if ($class == $_POST['grid']) {
|
||||
$value = (array)$value;
|
||||
$value = (array) $value;
|
||||
$arrayK = $value[$r2];
|
||||
foreach ($arrayK as $key2 => $val) {
|
||||
$fieldBase[$r2][$key2] = is_array($val) ? $val[$key2] : $val;
|
||||
@@ -107,7 +81,7 @@ if (count($newValues) > 1 && isset($_POST['grid'])) {
|
||||
$dependentFields = array();
|
||||
$aux = array();
|
||||
for ($r = 0; $r < count($newValues); $r++) {
|
||||
$newValues[$r] = (array)$newValues[$r];
|
||||
$newValues[$r] = (array) $newValues[$r];
|
||||
$G_FORM->setValues($newValues[$r]);
|
||||
//Search dependent fields
|
||||
foreach ($newValues[$r] as $k => $v) {
|
||||
@@ -117,7 +91,11 @@ for ($r = 0; $r < count($newValues); $r++) {
|
||||
} else {
|
||||
foreach ($v[$_POST['row']] as $k1 => $v1) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -142,12 +120,12 @@ $G_FORM->values = $newForm;
|
||||
$arrayFieldSubDependent = array();
|
||||
|
||||
if (isset($_POST["grid"])) {
|
||||
$arrayField = (array)(Bootstrap::json_decode(urlDecode(stripslashes($_POST["fields"]))));
|
||||
$arrayField = (array) (Bootstrap::json_decode(urlDecode(stripslashes($_POST["fields"]))));
|
||||
$arrayDependentField = array();
|
||||
$ereg = null;
|
||||
|
||||
foreach ($arrayField as $fieldData) {
|
||||
$arrayAux = (array)($fieldData);
|
||||
$arrayAux = (array) ($fieldData);
|
||||
|
||||
foreach ($arrayAux as $index => $value) {
|
||||
$ereg = $ereg . (($ereg != null) ? "|" : null) . $index; //Concatenate field
|
||||
@@ -185,7 +163,7 @@ if (isset($_POST["grid"])) {
|
||||
//Completed all fields of the grid
|
||||
if (isset($_POST["grid"]) && isset($_POST["gridField"])) {
|
||||
//Completed all fields of the grid
|
||||
$arrayGridField = (array)(Bootstrap::json_decode(urldecode(stripslashes($_POST["gridField"]))));
|
||||
$arrayGridField = (array) (Bootstrap::json_decode(urldecode(stripslashes($_POST["gridField"]))));
|
||||
|
||||
foreach ($arrayGridField as $index => $value) {
|
||||
$G_FORM->values[$_POST["grid"]][$_POST["row"]][$index] = $value;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
<filter>
|
||||
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false">
|
||||
<directory suffix=".php">./gulliver</directory>
|
||||
<directory suffix=".php">./workflow/engine/classes</directory>
|
||||
<directory suffix=".php">./workflow/engine/src</directory>
|
||||
</whitelist>
|
||||
|
||||
@@ -53,6 +53,8 @@ define('PATH_HTML', PATH_HOME . 'public_html/');
|
||||
define('PATH_SMARTY_C', PATH_TRUNK . '/shared/compiled/smarty/c');
|
||||
define('PATH_SMARTY_CACHE', PATH_TRUNK . '/shared/compiled/smarty/cache');
|
||||
define('PATH_THIRDPARTY', PATH_TRUNK . '/thirdparty/');
|
||||
define("URL_KEY", 'c0l0s40pt1mu59r1m3');
|
||||
define("PATH_XMLFORM", PATH_CORE . "xmlform" . PATH_SEP);
|
||||
|
||||
// Set Time Zone
|
||||
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int) (env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;
|
||||
|
||||
8
tests/resources/simpleClassicPostData.json
Normal file
8
tests/resources/simpleClassicPostData.json
Normal 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"
|
||||
}
|
||||
242
tests/resources/simpleClassicSessionData.json
Normal file
242
tests/resources/simpleClassicSessionData.json
Normal file
File diff suppressed because one or more lines are too long
15
tests/resources/simpleClassicXmlFormData.xml
Executable file
15
tests/resources/simpleClassicXmlFormData.xml
Executable 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>
|
||||
47
tests/unit/gulliver/methods/DefaultAjaxTest.php
Normal file
47
tests/unit/gulliver/methods/DefaultAjaxTest.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user