Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#3503, dev/core#3492 Fix grant exports and relative dates #23904

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CRM/Contact/BAO/Query/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ public function &getFields() {
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is

$extFields = array_merge($extFields, $fields);
}
return $extFields;
}

/**
* @param $apiEntities
* @param $fieldOptions
Expand Down
5 changes: 4 additions & 1 deletion CRM/Core/BAO/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,10 @@ public static function getBasicFields($mappingType) {
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);
Expand Down
19 changes: 14 additions & 5 deletions ext/civigrant/CRM/Grant/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@
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 [];
}

/**
Expand Down