CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • CiviContribute Suggestions »
  • Contribution receipt shows hidden custom fields
Pages: [1]

Author Topic: Contribution receipt shows hidden custom fields  (Read 733 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Contribution receipt shows hidden custom fields
May 18, 2015, 01:16:40 am
(This is a bug report rather than a suggestion. Please advise where these should go in future - I'm a bit confused by the new set up.)

I'm using 4.6.2 and have 2 groups of custom fields - one that I want to be visible to the public, and one that is hidden.

Donating via the front-office interface is fine - I can control what custom fields are displayed.

But the code that generates a receipt shows all the custom fields. So when a back-office person creates a contribution, using one of the hidden custom fields, and sends a receipt, the hidden field is included in the receipt.

I expected the logic to suppress hidden custom fields. I expected it to be like the Event Info page, which shows hidden custom fields to back-office staff, but not to the public.

The code to be fixed appears to be CRM_Contribute_Form_AdditionalInfo::emailreceipt().
« Last Edit: May 18, 2015, 01:35:44 am by ken »

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Contribution receipt shows hidden custom fields
May 18, 2015, 03:55:06 am
Here's a patch. I can create a PR if needed.

Code: [Select]
--- ../../civicrm/CRM/Contribute/Form/AdditionalInfo.php 2015-04-16 09:24:10.000000000 +1000
+++ CRM/Contribute/Form/AdditionalInfo.php 2015-05-18 20:39:21.824352364 +1000
@@ -446,10 +446,26 @@
       //retrieve custom data
       $customGroup = array();
 
+      // Assume this receipt is being sent to an anonymous user.
+      // This code emulates CRM_Core_Permission::customGroup() being called for an
+      // anonymous user. The result is used to filter the custom data that is presented.
+      $publicGroups = CRM_ACL_BAO_ACL::group(
+          CRM_Core_Permission::VIEW,
+          0,
+          'civicrm_custom_group',
+          CRM_Core_PseudoConstant::get(
+              'CRM_Core_DAO_CustomField',
+              'custom_group_id',
+              array('fresh' => FALSE)
+          )
+      );
+
       foreach ($form->_groupTree as $groupID => $group) {
         $customFields = $customValues = array();
         if ($groupID == 'info') {
           continue;
+        } elseif (in_array($groupID, $publicGroups) === FALSE) {
+          continue;
         }
         foreach ($group['fields'] as $k => $field) {
           $field['title'] = $field['label'];
« Last Edit: May 18, 2015, 04:24:38 am by ken »

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Contribution receipt shows hidden custom fields
May 18, 2015, 04:11:37 am
This PR assumes the permission 'access all custom data' is not given to anonymous users.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • CiviContribute Suggestions »
  • Contribution receipt shows hidden custom fields

This forum was archived on 2017-11-26.