// Warning - this imProviders var is used in a somewhat fragile way - don't rename it
// without manually testing the export of IM provider still works.
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
- self::$relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(
- NULL,
- NULL,
- NULL,
- NULL,
- TRUE,
- 'name',
- FALSE
- );
+ self::$relationshipTypes = $processor->getRelationshipTypes();
//also merge Head of Household
self::$memberOfHouseholdRelationshipKey = CRM_Utils_Array::key('Household Member of', self::$relationshipTypes);
self::$headOfHouseholdRelationshipKey = CRM_Utils_Array::key('Head of Household for', self::$relationshipTypes);
continue;
}
- if (array_key_exists($fieldName, self::$relationshipTypes) && (!empty($value[2]) || !empty($value[4]))) {
+ if ($processor->isRelationshipTypeKey($fieldName) && (!empty($value[2]) || !empty($value[4]))) {
self::setRelationshipReturnProperties($value, $locationTypeFields, $fieldName);
// @todo we can later not add this to this array but maintain a separate array.
$returnProperties = array_merge($returnProperties, self::$relationshipReturnProperties);
}
foreach ($returnProperties as $key => $value) {
- if (!array_key_exists($key, self::$relationshipTypes)) {
+ if (!$processor->isRelationshipTypeKey($key)) {
$returnProperties[self::$memberOfHouseholdRelationshipKey][$key] = $value;
$returnProperties[self::$headOfHouseholdRelationshipKey][$key] = $value;
}
}
}
- if (array_key_exists($field, self::$relationshipTypes)) {
+ if ($processor->isRelationshipTypeKey($field)) {
$relDAO = CRM_Utils_Array::value($iterationDAO->contact_id, $allRelContactArray[$field]);
$relationQuery[$field]->convertToPseudoNames($relDAO);
self::fetchRelationshipDetails($relDAO, $value, $field, $row);
elseif ($field == 'provider_id') {
$headerRows[] = ts('IM Service Provider');
}
- elseif (array_key_exists($field, self::$relationshipTypes)) {
+ elseif ($processor->isRelationshipTypeKey($field)) {
foreach ($value as $relationField => $relationValue) {
// below block is same as primary block (duplicate)
if (isset($relationQuery[$field]->_fields[$relationField]['title'])) {
*/
protected $requestedFields;
+ /**
+ * Key representing the head of household in the relationship array.
+ *
+ * e.g. ['8_b_a' => 'Household Member Is', '8_a_b = 'Household Member Of'.....]
+ *
+ * @var
+ */
+ protected $relationshipTypes = [];
+
/**
* CRM_Export_BAO_ExportProcessor constructor.
*
$this->setQueryMode();
$this->setQueryOperator($queryOperator);
$this->setRequestedFields($requestedFields);
+ $this->setRelationshipTypes();
}
/**
$this->requestedFields = $requestedFields;
}
+ /**
+ * @return array
+ */
+ public function getRelationshipTypes() {
+ return $this->relationshipTypes;
+ }
+
+ /**
+ */
+ public function setRelationshipTypes() {
+ $this->relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ TRUE,
+ 'name',
+ FALSE
+ );
+ }
+
+
+ /**
+ * @param $fieldName
+ * @return bool
+ */
+ public function isRelationshipTypeKey($fieldName) {
+ return array_key_exists($fieldName, $this->relationshipTypes);
+ }
+
/**
* @return string
*/