diff --git a/CRM/Group/Form/Edit.php b/CRM/Group/Form/Edit.php index 9e5f740a93ef..e9338fb2d019 100644 --- a/CRM/Group/Form/Edit.php +++ b/CRM/Group/Form/Edit.php @@ -190,12 +190,7 @@ public function setDefaultValues() { $defaults['is_active'] = 1; } - if (!((CRM_Core_Permission::check('access CiviMail')) || - (CRM_Mailing_Info::workflowEnabled() && - CRM_Core_Permission::check('create mailings') - ) - ) - ) { + if (!$this->isPermitMailingGroupAccess()) { $groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE); if ($defaults['group_type'][$groupTypes['Mailing List']] == 1) { $this->assign('freezeMailingList', $groupTypes['Mailing List']); @@ -471,4 +466,13 @@ public static function buildGroupOrganizations(&$form) { } } + /** + * Does the user have permissions allowing them to create groups with option_type set to mailing? + * + * @return bool + */ + protected function isPermitMailingGroupAccess(): bool { + return CRM_Core_Permission::check('access CiviMail') || (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')); + } + }