Merged in bugfix/HOR-3185 (pull request #6064)
HOR-3185 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\BusinessModel\DynaForm\SuggestTrait;
|
||||
use ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
/**
|
||||
* Implementing pmDynaform library in the running case.
|
||||
@@ -250,11 +251,6 @@ class PmDynaform
|
||||
$dtFields = $json->queryInputData;
|
||||
} else {
|
||||
$dtFields = $this->getValuesDependentFields($json);
|
||||
foreach ($dtFields as $keyF => $valueF) {
|
||||
if (isset($this->fields["APP_DATA"][$keyF])) {
|
||||
$dtFields[$keyF] = $this->fields["APP_DATA"][$keyF];
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = G::replaceDataField($json->sql, $dtFields);
|
||||
if ($value === "suggest") {
|
||||
@@ -610,7 +606,8 @@ class PmDynaform
|
||||
$json->dataGridEnvironment = "onDataGridEnvironment";
|
||||
if (isset($this->fields["APP_DATA"])) {
|
||||
$dataGridEnvironment = $this->fields["APP_DATA"];
|
||||
$this->fields["APP_DATA"] = [];
|
||||
//Grids only access the global variables of 'ProcessMaker', other variables are removed.
|
||||
$this->fields["APP_DATA"] = Cases::getGlobalVariables($this->fields["APP_DATA"]);
|
||||
//restore AppData with dataVariable definition, only for columns control
|
||||
foreach ($columnsDataVariable as $dge) {
|
||||
if (isset($dataGridEnvironment[$dge])) {
|
||||
@@ -691,7 +688,14 @@ class PmDynaform
|
||||
if (!isset($this->record["DYN_CONTENT"])) {
|
||||
return array();
|
||||
}
|
||||
$data = array();
|
||||
$data = [];
|
||||
if (isset($this->fields["APP_DATA"])) {
|
||||
foreach ($this->fields["APP_DATA"] as $keyF => $valueF) {
|
||||
if (!isset($data[$keyF]) && !is_array($valueF)) {
|
||||
$data[$keyF] = $valueF;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($json->dbConnection) && isset($json->sql)) {
|
||||
$result = array();
|
||||
preg_match_all('/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $json->sql, $result, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
@@ -708,18 +712,12 @@ class PmDynaform
|
||||
}
|
||||
}
|
||||
if ($json->dbConnection !== "" && $json->dbConnection !== "none" && $json->sql !== "") {
|
||||
if (isset($this->fields["APP_DATA"])) {
|
||||
foreach ($this->fields["APP_DATA"] as $keyA => $valueA) {
|
||||
if (!isset($data[$keyA]) && !is_array($valueA)) {
|
||||
$data[$keyA] = $valueA;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = G::replaceDataField($json->sql, $data);
|
||||
$dt = $this->getCacheQueryData($json->dbConnection, $sql, $json->type);
|
||||
$row = isset($dt[0]) ? $dt[0] : [];
|
||||
if (isset($row[0]) && $json->type !== "suggest" && $json->type !== "radio") {
|
||||
$data[$json->variable === "" ? $json->id : $json->variable] = $row[0];
|
||||
$index = $json->variable === "" ? $json->id : $json->variable;
|
||||
if (!isset($data[$index]) && isset($row[0]) && $json->type !== "suggest" && $json->type !== "radio") {
|
||||
$data[$index] = $row[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ use WsBase;
|
||||
use RBAC;
|
||||
use Applications;
|
||||
use PmDynaform;
|
||||
use ProcessMaker\Services\OAuth2\Server;
|
||||
use Users;
|
||||
|
||||
class Cases
|
||||
{
|
||||
@@ -1679,7 +1681,8 @@ class Cases
|
||||
$arrayCaseVariable = [];
|
||||
|
||||
if (!is_null($dynaFormUid)) {
|
||||
|
||||
$data = [];
|
||||
$data["APP_DATA"] = $fields['APP_DATA'];
|
||||
$data["CURRENT_DYNAFORM"] = $dynaFormUid;
|
||||
$pmDynaForm = new PmDynaform($data);
|
||||
$arrayDynaFormData = $pmDynaForm->getDynaform();
|
||||
@@ -3244,26 +3247,48 @@ class Cases
|
||||
$appData = array_change_key_case($appData, CASE_UPPER);
|
||||
$dataVariable = array_change_key_case($dataVariable, CASE_UPPER);
|
||||
|
||||
if (!isset($dataVariable['APPLICATION']) || empty($dataVariable['APPLICATION'])) {
|
||||
$dataVariable['APPLICATION'] = (isset($dataVariable['APP_UID']) && $dataVariable['APP_UID'] != '') ? $dataVariable['APP_UID'] : $appData['APPLICATION'];
|
||||
$result = [];
|
||||
//we get the appData parameters
|
||||
if (!empty($appData['APPLICATION'])) {
|
||||
$result['APPLICATION'] = $appData['APPLICATION'];
|
||||
}
|
||||
if (!isset($dataVariable['PROCESS']) || empty($dataVariable['PROCESS'])) {
|
||||
$dataVariable['PROCESS'] = (isset($dataVariable['PRO_UID']) && $dataVariable['PRO_UID'] != '') ? $dataVariable['PRO_UID'] : $appData['PROCESS'];
|
||||
if (!empty($appData['PROCESS'])) {
|
||||
$result['PROCESS'] = $appData['PROCESS'];
|
||||
}
|
||||
if (isset($appData['TASK']) && !empty($appData['TASK'])) {
|
||||
$dataVariable['TASK'] = $appData['TASK'];
|
||||
if (!empty($appData['TASK'])) {
|
||||
$result['TASK'] = $appData['TASK'];
|
||||
}
|
||||
if (isset($appData['INDEX']) && !empty($appData['INDEX'])) {
|
||||
$dataVariable['INDEX'] = $appData['INDEX'];
|
||||
}
|
||||
$dataVariable['USER_LOGGED'] = \ProcessMaker\Services\OAuth2\Server::getUserId();
|
||||
if (isset($dataVariable['USER_LOGGED']) && !empty($dataVariable['USER_LOGGED'])) {
|
||||
$oUserLogged = new \Users();
|
||||
$oUserLogged->load($dataVariable['USER_LOGGED']);
|
||||
$dataVariable['USR_USERNAME'] = $oUserLogged->getUsrUsername();
|
||||
if (!empty($appData['INDEX'])) {
|
||||
$result['INDEX'] = $appData['INDEX'];
|
||||
}
|
||||
|
||||
return $dataVariable;
|
||||
//we try to get the missing elements
|
||||
if (!empty($dataVariable['APP_UID']) && empty($result['APPLICATION'])) {
|
||||
$result['APPLICATION'] = $dataVariable['APP_UID'];
|
||||
}
|
||||
if (!empty($dataVariable['PRO_UID']) && empty($result['PROCESS'])) {
|
||||
$result['PROCESS'] = $dataVariable['PRO_UID'];
|
||||
}
|
||||
|
||||
$result['USER_LOGGED'] = '';
|
||||
$result['USR_USERNAME'] = '';
|
||||
global $RBAC;
|
||||
if (isset($RBAC) && isset($RBAC->aUserInfo)) {
|
||||
$result['USER_LOGGED'] = $RBAC->aUserInfo['USER_INFO']['USR_UID'];
|
||||
$result['USR_USERNAME'] = $RBAC->aUserInfo['USER_INFO']['USR_USERNAME'];
|
||||
}
|
||||
if (empty($result['USER_LOGGED'])) {
|
||||
$result['USER_LOGGED'] = Server::getUserId();
|
||||
if (!empty($result['USER_LOGGED'])) {
|
||||
$oUserLogged = new Users();
|
||||
$oUserLogged->load($result['USER_LOGGED']);
|
||||
$result['USR_USERNAME'] = $oUserLogged->getUsrUsername();
|
||||
}
|
||||
}
|
||||
|
||||
//the parameter dataVariable may contain additional elements
|
||||
$result = array_merge($dataVariable, $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ use G;
|
||||
use Exception;
|
||||
use AdditionalTables;
|
||||
use PmDynaform;
|
||||
use ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
class Variable
|
||||
{
|
||||
@@ -773,11 +774,14 @@ class Variable
|
||||
unset($params["limit"]);
|
||||
|
||||
//Get appData and system variables
|
||||
$paramsWithoutAppData = $params;
|
||||
$globalVariables = [];
|
||||
if ($appUid !== null) {
|
||||
$case = new \Cases();
|
||||
$fields = $case->loadCase($appUid, $delIndex);
|
||||
$appData = $fields["APP_DATA"];
|
||||
$appData = array_merge($appData, \ProcessMaker\BusinessModel\Cases::getGlobalVariables($appData));
|
||||
$globalVariables = Cases::getGlobalVariables($appData);
|
||||
$appData = array_merge($appData, $globalVariables);
|
||||
$params = array_merge($appData, $params);
|
||||
}
|
||||
|
||||
@@ -795,6 +799,14 @@ class Variable
|
||||
$field->queryFilter = $filter;
|
||||
$field->queryStart = $start;
|
||||
$field->queryLimit = $limit;
|
||||
//Grids only access the global variables of 'ProcessMaker', other variables are removed.
|
||||
//The property 'columnWidth' is only present in the controls of a grid,
|
||||
//in the current change there is no specific property that indicates
|
||||
//if the control is in the grid.
|
||||
if (isset($field->columnWidth)) {
|
||||
$pmDynaform->fields["APP_DATA"] = $globalVariables;
|
||||
$field->queryInputData = $paramsWithoutAppData;
|
||||
}
|
||||
|
||||
//Populate control data
|
||||
$pmDynaform->jsonr($field);
|
||||
|
||||
Reference in New Issue
Block a user