fix resolving of customfield record values
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 8 Aug 2017 15:23:15 +0000 (17:23 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 9 Aug 2017 09:21:02 +0000 (11:21 +0200)
... when using :id filter

Change-Id: Ia24e94951e90ddb890d231f73a492559d1f4b124
Reviewed-on: http://gerrit.tine20.com/customers/5425
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Model/Filter/CustomField.php

index ee51a23..e59d38b 100644 (file)
@@ -195,10 +195,17 @@ class Tinebase_Model_Filter_CustomField extends Tinebase_Model_Filter_Abstract
         $result = parent::toArray($valueToJson);
         if (strtolower($this->_cfRecord->definition['type']) == 'record') {
             try {
-                if (! is_array($result['value']['value'])) {
-                    $modelName = Tinebase_CustomField::getModelNameFromDefinition($this->_cfRecord->definition);
-                    $controller = Tinebase_Core::getApplicationInstance($modelName);
+                $modelName = Tinebase_CustomField::getModelNameFromDefinition($this->_cfRecord->definition);
+                $controller = Tinebase_Core::getApplicationInstance($modelName);
+                if (is_string($result['value']['value'])) {
                     $result['value']['value'] = $controller->get($result['value']['value'])->toArray();
+                } else if (is_array($result['value']['value'])) {
+                    //  this is very bad - @refactor
+                    foreach ($result['value']['value'] as $key => $subfilter) {
+                        if (isset($result['value']['value'][$key]['value']) && is_string($result['value']['value'][$key]['value']))
+                        $result['value']['value'][$key]['value'] = $controller->get($result['value']['value'][$key]['value'])->toArray();
+                    }
+
                 } else {
                     // TODO do we need to do something in this case?
                 }