From 7dcdb6fa7c6efdc57aec1c82fc06065896ec29a0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 2 Nov 2016 15:32:47 -0400 Subject: [PATCH] CRM-19593 - Hide edit/delete buttons for non-editable custom groups --- CRM/Core/BAO/CustomGroup.php | 7 +++++++ templates/CRM/Custom/Page/CustomDataView.tpl | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index c266b303b9..e59b0e6930 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -1973,6 +1973,13 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, 'field_value' => CRM_Core_BAO_CustomField::displayValue($values['data'], $properties['id'], $entityId), 'options_per_line' => CRM_Utils_Array::value('options_per_line', $properties), ); + // editable = whether this set contains any non-read-only fields + if (!isset($details[$groupID][$values['id']]['editable'])) { + $details[$groupID][$values['id']]['editable'] = FALSE; + } + if (empty($properties['is_view'])) { + $details[$groupID][$values['id']]['editable'] = TRUE; + } // also return contact reference contact id if user has view all or edit all contacts perm if ((CRM_Core_Permission::check('view all contacts') || CRM_Core_Permission::check('edit all contacts')) diff --git a/templates/CRM/Custom/Page/CustomDataView.tpl b/templates/CRM/Custom/Page/CustomDataView.tpl index 2877765a5a..ca9e600111 100644 --- a/templates/CRM/Custom/Page/CustomDataView.tpl +++ b/templates/CRM/Custom/Page/CustomDataView.tpl @@ -28,15 +28,14 @@ {assign var="rowCount" value=1} {foreach from=$viewCustomData item=customValues key=customGroupId} {foreach from=$customValues item=cd_edit key=cvID} - {assign var="customRegion" value='contact-custom-data-'|cat:$cd_edit.name} - {crmRegion name=$customRegion} + {crmRegion name="custom-data-view-`$cd_edit.name`"} {if $cd_edit.help_pre}
{$cd_edit.help_pre}
{/if} {if $multiRecordDisplay neq 'single'} {assign var='index' value=$groupId|cat:"_$cvID"} - {if ($editOwnCustomData and $showEdit) or ($showEdit and $editCustomData and $groupId)} + {if ($showEdit && $cd_edit.editable && $groupId) && ($editOwnCustomData or $editCustomData)}
{/if}
- {if $groupId and $cvID and $editCustomData} + {if $groupId and $cvID and $editCustomData and $cd_edit.editable}