From 62c69a41dda4df8a1223c929566eba62f728247c Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Sun, 25 Jun 2023 19:45:57 -0400 Subject: [PATCH] don't show reserved groups --- CRM/Custom/Form/DeleteField.php | 6 ++++++ CRM/Custom/Form/Field.php | 2 ++ .../managed/SavedSearch_Administer_Custom_Fields.mgd.php | 2 +- .../managed/SavedSearch_Administer_Custom_Groups.mgd.php | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CRM/Custom/Form/DeleteField.php b/CRM/Custom/Form/DeleteField.php index 7793b9ac39..fcef401c6b 100644 --- a/CRM/Custom/Form/DeleteField.php +++ b/CRM/Custom/Form/DeleteField.php @@ -47,6 +47,12 @@ class CRM_Custom_Form_DeleteField extends CRM_Core_Form { $params = ['id' => $this->_id]; CRM_Core_BAO_CustomField::retrieve($params, $defaults); + if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $defaults['custom_group_id'], 'is_reserved')) { + // I think this does not have ts() because the only time you would see + // this is if you manually made a url you weren't supposed to. + CRM_Core_Error::statusBounce("You cannot delete fields in a reserved custom field-set."); + } + $this->_title = $defaults['label'] ?? NULL; $this->assign('title', $this->_title); $this->setTitle(ts('Delete %1', [1 => $this->_title])); diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index d96d999ee4..9f829ac9dd 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -99,6 +99,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { } if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved')) { + // I think this does not have ts() because the only time you would see + // this is if you manually made a url you weren't supposed to. CRM_Core_Error::statusBounce("You cannot add or edit fields in a reserved custom field-set."); } diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Fields.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Fields.mgd.php index e9c234c837..e115dde287 100644 --- a/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Fields.mgd.php +++ b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Fields.mgd.php @@ -29,7 +29,7 @@ return [ 'option_group_id:label', ], 'orderBy' => [], - 'where' => [], + 'where' => [['custom_group_id.is_reserved', '=', FALSE]], 'groupBy' => [], 'join' => [], 'having' => [], diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Groups.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Groups.mgd.php index 8a8b96df21..1be5dafc78 100644 --- a/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Groups.mgd.php +++ b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Custom_Groups.mgd.php @@ -30,7 +30,7 @@ return [ 'GROUP_CONCAT(DISTINCT CustomGroup_CustomField_custom_group_id_01.label) AS GROUP_CONCAT_CustomGroup_CustomField_custom_group_id_01_label', ], 'orderBy' => [], - 'where' => [], + 'where' => [['is_reserved', '=', FALSE]], 'groupBy' => [ 'id', ], @@ -149,7 +149,7 @@ return [ 'text' => E::ts('Settings'), 'style' => 'default', 'path' => '', - 'condition' => ['is_reserved', '=', FALSE], + 'condition' => [], ], ], 'type' => 'buttons', -- 2.25.1