Merged in julceslau/processmaker/HOR-2167 (pull request #5158)
HOR-2167
This commit is contained in:
@@ -871,6 +871,24 @@ class Cases
|
||||
return $aReturn;
|
||||
}
|
||||
|
||||
public function array_key_intersect(&$a, &$b) {
|
||||
$array = array();
|
||||
while (list($key, $value) = each($a)) {
|
||||
if (isset($b[$key])) {
|
||||
if (is_object($b[$key]) && is_object($value)) {
|
||||
if (serialize($b[$key]) === serialize($value)) {
|
||||
$array[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
if ($b[$key] === $value) {
|
||||
$array[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update an existing case, this info is used in CaseResume
|
||||
*
|
||||
@@ -914,7 +932,7 @@ class Cases
|
||||
//only when that variable is set.. from Save
|
||||
$FieldsBefore = $this->loadCase($sAppUid);
|
||||
$FieldsDifference = $this->arrayRecursiveDiff($FieldsBefore['APP_DATA'], $aApplicationFields);
|
||||
$fieldsOnBoth = @array_intersect_assoc($FieldsBefore['APP_DATA'], $aApplicationFields);
|
||||
$fieldsOnBoth = $this->array_key_intersect($FieldsBefore['APP_DATA'], $aApplicationFields);
|
||||
//Add fields that weren't in previous version
|
||||
foreach ($aApplicationFields as $key => $value) {
|
||||
if (is_array($value) && isset($fieldsOnBoth[$key]) && is_array($fieldsOnBoth[$key])) {
|
||||
|
||||
@@ -127,6 +127,8 @@ class PMScript
|
||||
|
||||
public $scriptExecutionTime = 0;
|
||||
|
||||
public $sRegexp = '/\@(?:([\@\%\#\?\$\=\&])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+|\-\>([a-zA-Z\_]\w*))?/';
|
||||
|
||||
/**
|
||||
* Constructor of the class PMScript
|
||||
*
|
||||
@@ -228,7 +230,7 @@ class PMScript
|
||||
{
|
||||
$sScript = "";
|
||||
$iAux = 0;
|
||||
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||
$iOcurrences = preg_match_all( $this->sRegexp, $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||
if ($iOcurrences) {
|
||||
for ($i = 0; $i < $iOcurrences; $i ++) {
|
||||
$bEqual = false;
|
||||
@@ -249,10 +251,17 @@ class PMScript
|
||||
}
|
||||
if ($bEqual) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = null; }" );
|
||||
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = " . ($aMatch[1][$i][0] == "&" ? "new stdclass()" : "null") . "; }" );
|
||||
} else {
|
||||
if ($aMatch[1][$i][0] == "&") {
|
||||
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = new stdclass(); }" );
|
||||
}
|
||||
eval( "if (!isset(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")) { \$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . " = null; }" );
|
||||
}
|
||||
} else {
|
||||
if ($aMatch[1][$i][0] == "&") {
|
||||
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = new stdclass(); }" );
|
||||
}
|
||||
}
|
||||
$sScript .= $sAux;
|
||||
$iAux = $aMatch[0][$i][1] + strlen( $aMatch[0][$i][0] );
|
||||
@@ -333,6 +342,7 @@ class PMScript
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
case '&':
|
||||
if ($bEqual) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
@@ -383,21 +393,25 @@ class PMScript
|
||||
$iAux = 0;
|
||||
$bEqual = false;
|
||||
$variableIsDefined = true;
|
||||
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||
$iOcurrences = preg_match_all( $this->sRegexp, $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||
if ($iOcurrences) {
|
||||
for ($i = 0; $i < $iOcurrences; $i ++) {
|
||||
// if the variables for that condition has not been previously defined then $variableIsDefined
|
||||
// is set to false
|
||||
if (!isset($this->aFields[$aMatch[2][$i][0]]) && !isset($aMatch[5][$i][0])) {
|
||||
$this->aFields[$aMatch[2][$i][0]] = '';
|
||||
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = " . ($aMatch[1][$i][0] == "&" ? "new stdclass()" : "null") . "; }" );
|
||||
} else {
|
||||
if ($aMatch[1][$i][0] == "&") {
|
||||
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = new stdclass(); }" );
|
||||
}
|
||||
if (!isset($this->aFields[$aMatch[2][$i][0]])) {
|
||||
eval("\$this->aFields['" . $aMatch[2][$i][0] . "']" . $aMatch[5][$i][0] . " = '';");
|
||||
|
||||
} else {
|
||||
if (isset($aMatch[5][$i][0])) {
|
||||
eval("if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "']" . $aMatch[5][$i][0] . ")) {\$this->aFields['" . $aMatch[2][$i][0] . "']" . $aMatch[5][$i][0] . " = '';}");
|
||||
} else {
|
||||
eval("if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) {\$this->aFields['" . $aMatch[2][$i][0] . "'] = '';}");
|
||||
eval("if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) {\$this->aFields['" . $aMatch[2][$i][0] . "'] = " . ($aMatch[1][$i][0] == "&" ? "new stdclass()" : "''") . ";}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -491,6 +505,7 @@ class PMScript
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
case '&':
|
||||
if ($bEqual) {
|
||||
if (! isset( $aMatch[5][$i][0] )) {
|
||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||
|
||||
Reference in New Issue
Block a user