From 046cddc776b00520d13c635629ee4c27b0b4bc98 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Tue, 2 Oct 2012 14:32:32 -0400 Subject: [PATCH] BUG 5720 Can not send Next Task Assignment Notifications with grid SOLVED - Can not send Next Task Assignment Notifications with grid variables. - Added and changed function filter for AppData values. --- gulliver/system/class.g.php | 63 ++++++++++++++++++++++++++ workflow/engine/classes/class.case.php | 4 +- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index e32d94cd3..c18d1340c 100755 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -2044,6 +2044,69 @@ $output = $outputHeader.$output; return $__textoEval; } + /** + * Replace Grid Values + * The tag @>GRID-NAME to open the grid and @])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); + + if ($iOcurrences) { + $arrayGrid = array(); + for ($i = 0; $i <= $iOcurrences - 1; $i++) { + $arrayGrid[] = $arrayMatch1[2][$i][0]; + } + + $arrayGrid = array_unique($arrayGrid); + + foreach ($arrayGrid as $index => $value) { + $grdName = $value; + $strContentAux1 = $strContentAux; + $strContentAux = null; + $ereg = "/^(.*)@>" . $grdName . "(.*)@<" . $grdName . "(.*)$/"; + + while (preg_match($ereg, $strContentAux1, $arrayMatch2)) { + $strData = null; + + if (isset($aFields[$grdName]) && is_array($aFields[$grdName])) { + foreach ($aFields[$grdName] as $aRow) { + foreach ($aRow as $sKey => $vValue) { + if (!is_array($vValue)) { + $aRow[$sKey] = nl2br($aRow[$sKey]); + } + } + $strData = $strData . G::replaceDataField($arrayMatch2[2], $aRow); + } + } + $strContentAux1 = $arrayMatch2[1]; + $strContentAux = $strData . $arrayMatch2[3] . $strContentAux; + } + $strContentAux = $strContentAux1 . $strContentAux; + } + } + $strContentAux = str_replace($nrthtml, $nrt, $strContentAux); + $sContent = $strContentAux; + + foreach ($aFields as $sKey => $vValue) { + if (!is_array($vValue)) { + $aFields[$sKey] = nl2br($aFields[$sKey]); + } + } + $sContent = G::replaceDataField($sContent, $aFields); + + return $sContent; + } + + /* Load strings from a XMLFile. * @author David Callizaya * @parameter $languageFile An xml language file. diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 2dfa55a0b..be3323cc4 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -4585,9 +4585,9 @@ class Cases throw (new Exception("Template file \"$fileTemplate\" does not exist.")); } - $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); + $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields); } else { - $sBody = nl2br(G::replaceDataField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields)); + $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields)); } G::LoadClass("tasks");