CRM-19270 - show contact reference custom field only if accessible
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 30 Aug 2016 10:52:22 +0000 (16:22 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 30 Aug 2016 10:52:22 +0000 (16:22 +0530)
CRM/Core/BAO/CustomField.php

index 2f74319daa58c74178c86154a06fb518d61a5b35..77fe06bebf4793a281eb9f2d6ccbc3af54719d01 100644 (file)
@@ -1029,6 +1029,10 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
           }
         }
         if ($field->data_type == 'ContactReference') {
+          // break if contact does not have permission to access ContactReference
+          if (!CRM_Core_Permission::check('access contact reference fields')) {
+            break;
+          }
           $attributes['class'] = (isset($attributes['class']) ? $attributes['class'] . ' ' : '') . 'crm-form-contact-reference huge';
           $attributes['data-api-entity'] = 'Contact';
           $element = $qf->add('text', $elementName, $label, $attributes, $useRequired && !$search);