$mappedFields[] = CRM_Core_BAO_Mapping::getMappingParams([], $field);
}
+ if (!$selectAll && $componentTable && !empty($exportParams['additional_group'])) {
+ // If an Additional Group is selected, then all contacts in that group are
+ // added to the export set (filtering out duplicates).
+ // Really - the calling function could do this ... just saying
+ // @todo take a whip to the calling function.
+ CRM_Core_DAO::executeQuery("
+INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_contact gc WHERE gc.group_id = {$exportParams['additional_group']} ON DUPLICATE KEY UPDATE {$componentTable}.contact_id = gc.contact_id"
+ );
+ }
+
$processor = new CRM_Export_BAO_ExportProcessor($exportMode, $mappedFields, $queryOperator, $mergeSameHousehold, $isPostalOnly, $mergeSameAddress);
if ($moreReturnProperties) {
$processor->setAdditionalRequestedReturnProperties($moreReturnProperties);
}
$paymentTableId = $processor->getPaymentTableID();
- if (!$selectAll && $componentTable && !empty($exportParams['additional_group'])) {
- // If an Additional Group is selected, then all contacts in that group are
- // added to the export set (filtering out duplicates).
- $query = "
-INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_contact gc WHERE gc.group_id = {$exportParams['additional_group']} ON DUPLICATE KEY UPDATE {$componentTable}.contact_id = gc.contact_id";
- CRM_Core_DAO::executeQuery($query);
- }
-
if ($processor->getRequestedFields() &&
$processor->isPostalableOnly()
) {
}
}
- /**
- * @param int $contactId
- * @param array $exportParams
- *
- * @return array
- */
- public static function _replaceMergeTokens($contactId, $exportParams) {
- $greetings = [];
- $contact = NULL;
-
- $greetingFields = [
- 'postal_greeting',
- 'addressee',
- ];
- foreach ($greetingFields as $greeting) {
- if (!empty($exportParams[$greeting])) {
- $greetingLabel = $exportParams[$greeting];
- if (empty($contact)) {
- $values = [
- 'id' => $contactId,
- 'version' => 3,
- ];
- $contact = civicrm_api('contact', 'get', $values);
-
- if (!empty($contact['is_error'])) {
- return $greetings;
- }
- $contact = $contact['values'][$contact['id']];
- }
-
- $tokens = ['contact' => $greetingLabel];
- $greetings[$greeting] = CRM_Utils_Token::replaceContactTokens($greetingLabel, $contact, NULL, $tokens);
- }
- }
- return $greetings;
- }
-
/**
* @param \CRM_Export_BAO_ExportProcessor $processor
* @param $sql
if (!$sharedAddress) {
if (!isset($contactGreetingTokens[$dao->master_contact_id])) {
- $contactGreetingTokens[$dao->master_contact_id] = self::_replaceMergeTokens($dao->master_contact_id, $exportParams);
+ $contactGreetingTokens[$dao->master_contact_id] = $processor->replaceMergeTokens($dao->master_contact_id, $exportParams);
}
$masterPostalGreeting = CRM_Utils_Array::value('postal_greeting',
$contactGreetingTokens[$dao->master_contact_id], $dao->master_postal_greeting
);
if (!isset($contactGreetingTokens[$dao->copy_contact_id])) {
- $contactGreetingTokens[$dao->copy_contact_id] = self::_replaceMergeTokens($dao->copy_contact_id, $exportParams);
+ $contactGreetingTokens[$dao->copy_contact_id] = $processor->replaceMergeTokens($dao->copy_contact_id, $exportParams);
}
$copyPostalGreeting = CRM_Utils_Array::value('postal_greeting',
$contactGreetingTokens[$dao->copy_contact_id], $dao->copy_postal_greeting
return $returnProperties;
}
+ /**
+ * @param int $contactId
+ * @param array $exportParams
+ *
+ * @return array
+ */
+ public function replaceMergeTokens($contactId, $exportParams) {
+ $greetings = [];
+ $contact = NULL;
+
+ $greetingFields = [
+ 'postal_greeting',
+ 'addressee',
+ ];
+ foreach ($greetingFields as $greeting) {
+ if (!empty($exportParams[$greeting])) {
+ $greetingLabel = $exportParams[$greeting];
+ if (empty($contact)) {
+ $values = [
+ 'id' => $contactId,
+ 'version' => 3,
+ ];
+ $contact = civicrm_api('contact', 'get', $values);
+
+ if (!empty($contact['is_error'])) {
+ return $greetings;
+ }
+ $contact = $contact['values'][$contact['id']];
+ }
+
+ $tokens = ['contact' => $greetingLabel];
+ $greetings[$greeting] = CRM_Utils_Token::replaceContactTokens($greetingLabel, $contact, NULL, $tokens);
+ }
+ }
+ return $greetings;
+ }
+
/**
* The function unsets static part of the string, if token is the dynamic part.
*
'groups' => 'contact groups',
];
foreach ($basicCaches as $cacheSvc => $cacheGrp) {
+ $definitionParams = [
+ 'name' => $cacheGrp,
+ 'type' => ['*memory*', 'SqlGroup', 'ArrayCache'],
+ ];
+ // For Caches that we don't really care about the ttl for and/or maybe accessed
+ // fairly often we use the fastArrayDecorator which improves reads and writes, these
+ // caches should also not have concurrency risk.
+ $fastArrayCaches = ['groups'];
+ if (in_array($cacheSvc, $fastArrayCaches)) {
+ $definitionParams['withArray'] = 'fast';
+ }
$container->setDefinition("cache.{$cacheSvc}", new Definition(
'CRM_Utils_Cache_Interface',
- [
- [
- 'name' => $cacheGrp,
- 'type' => ['*memory*', 'SqlGroup', 'ArrayCache'],
- ],
- ]
+ [$definitionParams]
))->setFactory('CRM_Utils_Cache::create');
}