Skip to content
Snippets Groups Projects
Unverified Commit 3cf2f2b0 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #23904 from eileenmcnaughton/grant

#3503, #3492 Fix grant exports and relative dates
parents 45aade24 fe822a6a
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,23 @@ class CRM_Contact_BAO_Query_Hook {
return $extFields;
}
/**
* Get the fields that are available in the 'contact context'.
*
* For example exporting contacts should not include fields for grants etc.
*
* @return array
*/
public function getContactFields(): array {
$extFields = [];
foreach ($this->getSearchQueryObjects() as $obj) {
// Get Fields is ambiguous about the
$fields = method_exists($obj, 'getContactFields') ? $obj->getContactFields() : $obj->getFields();
$extFields = array_merge($extFields, $fields);
}
return $extFields;
}
/**
* @param $apiEntities
* @param $fieldOptions
......
......@@ -611,7 +611,10 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping implements \Civi\Core\Ho
else {
$contactFields = CRM_Contact_BAO_Contact::exportableFields($contactType, FALSE, TRUE);
}
$contactFields = array_merge($contactFields, CRM_Contact_BAO_Query_Hook::singleton()->getFields());
// It's unclear when we would want this but.... see
// https://lab.civicrm.org/dev/core/-/issues/3069 for when we don't....
$contactFields = array_merge($contactFields, CRM_Contact_BAO_Query_Hook::singleton()
->getContactFields());
// Exclude the address options disabled in the Address Settings
$fields[$contactType] = CRM_Core_BAO_Address::validateAddressOptions($contactFields);
......
......@@ -17,16 +17,25 @@ use CRM_Grant_ExtensionUtil as E;
class CRM_Grant_BAO_Query extends CRM_Contact_BAO_Query_Interface {
/**
* Unused.
* Get available fields.
*
* This function is meant to return extra contact fields, but grants are not contacts.
* Important for exports & relative date filters.
*
* @return array
*/
public function &getFields() {
$fields = [];
return $fields;
// return CRM_Grant_BAO_Grant::exportableFields();
return CRM_Grant_BAO_Grant::exportableFields();
}
/**
* Get the fields that are available in the 'contact context'.
*
* For example exporting contacts should not include fields for grants etc.
*
* @return array
*/
public function getContactFields(): array {
return [];
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment