$processor->setHouseholdMergeReturnProperties(array_diff_key($returnProperties, array_fill_keys(['location_type', 'im_provider'], 1)));
}
+ // This perhaps only needs calling when $mergeSameHousehold == 1
self::buildRelatedContactArray($selectAll, $ids, $processor, $componentTable);
// make sure the groups stuff is included only if specifically specified
*/
protected $exportedHouseholds = [];
+ /**
+ * Households to skip during export as they will be exported via their relationships anyway.
+ *
+ * @var array
+ */
+ protected $householdsToSkip = [];
+
/**
* Get return properties by relationship.
* @return array
*/
public function setRelationshipValue($relationshipType, $contactID, $field, $value) {
$this->relatedContactValues[$relationshipType][$contactID][$field] = $value;
+ if ($field === 'id') {
+ $this->householdsToSkip[] = $value;
+ }
}
/**
* @return array|bool
*/
public function buildRow($query, $iterationDAO, $outputColumns, $metadata, $paymentDetails, $addPaymentHeader, $paymentTableId) {
+ if ($this->isHouseholdToSkip($iterationDAO->contact_id)) {
+ return FALSE;
+ }
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
}
}
+ /**
+ * Is this contact a household that is already set to be exported by virtue of it's household members.
+ *
+ * @param int $contactID
+ *
+ * @return bool
+ */
+ protected function isHouseholdToSkip($contactID) {
+ return in_array($contactID, $this->householdsToSkip);
+ }
+
}
*
* @param int $isPrimaryOnly
*
- * @dataProvider getPrimarySearchOptions
+ * @dataProvider getBooleanDataProvider
+ * @throws \CRM_Core_Exception
*/
public function testExportPrimaryAddress($isPrimaryOnly) {
\Civi::settings()->set('searchPrimaryDetailsOnly', $isPrimaryOnly);
\Civi::settings()->set('searchPrimaryDetailsOnly', FALSE);
}
- /**
- * Get the options for the primary search setting field.
- * @return array
- */
- public function getPrimarySearchOptions() {
- return [[TRUE], [FALSE]];
- }
-
/**
* Test that when exporting a pseudoField it is reset for NULL entries.
*
* Test exporting relationships.
*
* This is to ensure that CRM-13995 remains fixed.
+ *
+ * @dataProvider getBooleanDataProvider
+ *
+ * @param bool $includeHouseHold
+ *
+ * @throws \CRM_Core_Exception
*/
- public function testExportRelationshipsMergeToHousehold() {
+ public function testExportRelationshipsMergeToHousehold($includeHouseHold) {
list($householdID, $houseHoldTypeID) = $this->setUpHousehold();
+ if ($includeHouseHold) {
+ $this->contactIDs[] = $householdID;
+ }
$selectedFields = [
['Individual', $houseHoldTypeID . '_a_b', 'state_province', ''],
['Individual', $houseHoldTypeID . '_a_b', 'city', ''],
);
$dao = CRM_Core_DAO::executeQuery("SELECT * FROM {$tableName}");
while ($dao->fetch()) {
+ $this->assertEquals(1, $dao->N);
$this->assertEquals('Portland', $dao->city);
$this->assertEquals('ME', $dao->state_province);
$this->assertEquals($householdID, $dao->civicrm_primary_id);