From 25cdc89ef0513591ffe39abc669ab219cbad43fc Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Tue, 25 Sep 2018 11:41:30 +0100 Subject: [PATCH] Freeze custom data elements when viewing an entity --- CRM/Core/BAO/CustomGroup.php | 3 +++ CRM/Custom/Form/CustomDataByType.php | 1 + CRM/Utils/Request.php | 6 ++++-- templates/CRM/common/customData.tpl | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index f4b61a5777..cffdac62c0 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -1639,6 +1639,9 @@ ORDER BY civicrm_custom_group.weight, $fieldId = $field['id']; $elementName = $field['element_name']; CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, $required); + if ($form->getAction() == CRM_Core_Action::VIEW) { + $form->getElement($elementName)->freeze(); + } } } } diff --git a/CRM/Custom/Form/CustomDataByType.php b/CRM/Custom/Form/CustomDataByType.php index 64011b742b..e7be80e785 100644 --- a/CRM/Custom/Form/CustomDataByType.php +++ b/CRM/Custom/Form/CustomDataByType.php @@ -48,6 +48,7 @@ class CRM_Custom_Form_CustomDataByType extends CRM_Core_Form { $this->_entityId = CRM_Utils_Request::retrieve('entityID', 'Positive'); $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive'); $this->_onlySubtype = CRM_Utils_Request::retrieve('onlySubtype', 'Boolean'); + $this->_action = CRM_Utils_Request::retrieve('action', 'Alphanumeric'); $this->assign('cdType', FALSE); $this->assign('cgCount', $this->_groupCount); diff --git a/CRM/Utils/Request.php b/CRM/Utils/Request.php index 831947358e..9f0c5bc3eb 100644 --- a/CRM/Utils/Request.php +++ b/CRM/Utils/Request.php @@ -126,8 +126,10 @@ class CRM_Utils_Request { } // minor hack for action - if ($name == 'action' && is_string($value)) { - $value = CRM_Core_Action::resolve($value); + if ($name == 'action') { + if (!is_numeric($value) && is_string($value)) { + $value = CRM_Core_Action::resolve($value); + } } if (isset($value) && $store) { diff --git a/templates/CRM/common/customData.tpl b/templates/CRM/common/customData.tpl index bde7b87b91..80567d4688 100644 --- a/templates/CRM/common/customData.tpl +++ b/templates/CRM/common/customData.tpl @@ -61,6 +61,9 @@ {if $qfKey} dataUrl += '&qf=' + '{$qfKey}'; {/if} + {if $action} + dataUrl += '&action=' + '{$action}'; + {/if} {literal} if (!cgCount) { -- 2.25.1