diff --git a/core/tabularbulkexport.class.inc.php b/core/tabularbulkexport.class.inc.php index 4446d204df..bd797cbccf 100644 --- a/core/tabularbulkexport.class.inc.php +++ b/core/tabularbulkexport.class.inc.php @@ -363,13 +363,13 @@ EOF } } foreach ($aAuthorizedClasses as $sAlias => $sClassName) { - foreach (MetaModel::GetZListItems($sClassName, 'details') as $sAttCode) { - //$oAttDef = Metamodel::GetAttributeDef($sClassName, $sAttCode); - if (utils::IsNullOrEmptyString($sAlias)) { - $aFields[] = "$sAttCode"; - } else { - $aFields[] = "$sAlias.$sAttCode"; + foreach (MetaModel::ListAttributeDefs($sClassName) as $oAttribute) { + $sAttCode = $oAttribute->GetCode(); + if (! $this->IsExportableField($sClassName, $sAttCode, $oAttribute)) { + continue; } + $sCurrentAlias = utils::IsNullOrEmptyString($sAlias) ? "" : "$sAlias."; + $aFields[] = "{$sCurrentAlias}{$sAttCode}"; } } diff --git a/tests/php-unit-tests/unitary-tests/webservices/ExportTest.php b/tests/php-unit-tests/unitary-tests/webservices/ExportTest.php index 4e07a9cc73..4eb5692079 100644 --- a/tests/php-unit-tests/unitary-tests/webservices/ExportTest.php +++ b/tests/php-unit-tests/unitary-tests/webservices/ExportTest.php @@ -56,7 +56,7 @@ HEADER; $sOutput = $this->performExportTesting($aParams, $this->sLogin); $sExpectedHeader = <<
Obsolete","Person->Organization","Person->Organization->Obsolete" HEADER; @@ -85,14 +85,20 @@ HEADER; $sExpectedHeader = <<
Person -Organization +Last name +First name Email +Organization Login Language Status -Profiles -Allowed Organizations log +Type of account +Full name +Person +Person->Obsolete +Person->Organization +Person->Organization->Obsolete HEADER; $this->assertStringContainsString("$sExpectedHeader", $sOutput, "Header ($sExpectedHeader)\n should be in export-v2 answer: \n$sOutput");