CRM-19593 - Hide edit/delete buttons for non-editable custom groups
authorColeman Watts <coleman@civicrm.org>
Wed, 2 Nov 2016 19:32:47 +0000 (15:32 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 8 Nov 2016 21:31:19 +0000 (16:31 -0500)
CRM/Core/BAO/CustomGroup.php
templates/CRM/Custom/Page/CustomDataView.tpl

index c266b303b91981e64e96038f01076b0613a54acb..e59b0e69301ede467e5191d2b628f9a82b688cd4 100644 (file)
@@ -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'))
index 2877765a5ad382bbc5af18e8232ef2bbc3099397..ca9e600111455cee62bfc0ff643356267ef408ee 100644 (file)
 {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}
       <div class="messages help">{$cd_edit.help_pre}</div>
     {/if}
     {if $multiRecordDisplay neq 'single'}
     <table class="no-border">
       {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)}
         <tr>
           <td>
             <a
@@ -55,7 +54,7 @@
               </div>
             {/if}
             <div class="crm-accordion-body">
-              {if $groupId and $cvID and $editCustomData}
+              {if $groupId and $cvID and $editCustomData and $cd_edit.editable}
                 <div class="crm-submit-buttons">
                   <a href="#" class="crm-hover-button crm-custom-value-del"
                      data-post='{ldelim}"valueID": "{$cvID}", "groupID": "{$customGroupId}", "contactId": "{$contactId}", "key": "{crmKey name='civicrm/ajax/customvalue'}"{rdelim}'