Merge branch '2017.11' into 2017.11-develop
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 9 Aug 2017 14:49:03 +0000 (16:49 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 9 Aug 2017 14:49:03 +0000 (16:49 +0200)
tine20/Addressbook/Export/List/Trait.php
tine20/Tinebase/Export/Doc.php
tine20/Tinebase/Record/Generic.php [new file with mode: 0644]

index 6059cda..ff74a81 100644 (file)
@@ -22,6 +22,10 @@ trait Addressbook_Export_List_Trait
         /** @noinspection PhpUndefinedMethodInspection */
         parent::_resolveRecords($_records);
 
+        if ($_records->getRecordClassName() != Addressbook_Model_List::class) {
+            return;
+        }
+
         if ('adb_list_doc' === $this->_config->name) {
             $this->_listDocResolveRecords($_records);
             return;
index c5890c9..7601c3c 100644 (file)
@@ -369,6 +369,8 @@ class Tinebase_Export_Doc extends Tinebase_Export_Abstract implements Tinebase_R
      */
     protected function _executeSubTemplate($_name, Tinebase_Export_Richtext_TemplateProcessor $_processor)
     {
+        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' starting sub tempalte: ' . $_name);
+
         $recordSet = $this->_currentRecord->{$_name};
         if (is_array($recordSet)) {
             if (count($recordSet) === 0) {
@@ -376,6 +378,23 @@ class Tinebase_Export_Doc extends Tinebase_Export_Abstract implements Tinebase_R
             }
             if (($record = reset($recordSet)) instanceof Tinebase_Record_Abstract) {
                 $recordSet = new Tinebase_Record_RecordSet(get_class($record), $recordSet);
+            } else {
+                $realRecordSet = new Tinebase_Record_RecordSet(Tinebase_Record_Generic::class, array());
+                $mergedRecords = array();
+                foreach($recordSet as $recordArray) {
+                    if (!is_array($recordArray)) {
+                        return;
+                    }
+                    $mergedRecords = array_merge($recordArray, $mergedRecords);
+                }
+                $validators = array_fill_keys(array_keys($mergedRecords), array(Zend_Filter_Input::ALLOW_EMPTY => true));
+                foreach($recordSet as $recordArray) {
+                    $record = new Tinebase_Record_Generic(array(), true);
+                    $record->setValidators($validators);
+                    $record->setFromArray($recordArray);
+                    $realRecordSet->addRecord($record);
+                }
+                $recordSet = $realRecordSet;
             }
         } elseif (is_object($recordSet)) {
             if ($recordSet instanceof Tinebase_Record_Abstract) {
diff --git a/tine20/Tinebase/Record/Generic.php b/tine20/Tinebase/Record/Generic.php
new file mode 100644 (file)
index 0000000..9e1b541
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Tine 2.0
+ *
+ * @package     Tinebase
+ * @subpackage  Record
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @copyright   Copyright (c) 2017-2017 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author      Paul Mehrer <p.mehrer@metaways.de>
+ */
+
+/**
+ * Generic implementation of Tinebase_Record_Abstract
+ *
+ * @package     Tinebase
+ * @subpackage  Record
+ */
+class Tinebase_Record_Generic extends Tinebase_Record_Abstract
+{
+    protected $_identifier = 'id';
+
+    public function setValidators(array $validators)
+    {
+        $this->_validators = $validators;
+    }
+}
\ No newline at end of file