From 8d6ea0e6b9c7b7513dc054686a83fbaa68760a27 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 23 Sep 2022 13:08:38 +1200 Subject: [PATCH] Fix smarty e-notices on group settings form --- CRM/Group/Form/Edit.php | 21 ++++++++------------- templates/CRM/Group/Form/Edit.tpl | 6 +++--- templates/CRM/Group/Form/GroupsCommon.tpl | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/CRM/Group/Form/Edit.php b/CRM/Group/Form/Edit.php index 9e5f740a93ef..9ab52fc1cbf0 100644 --- a/CRM/Group/Form/Edit.php +++ b/CRM/Group/Form/Edit.php @@ -90,6 +90,8 @@ public function getDefaultEntity() { /** * Set up variables to build the form. + * + * @throws \CRM_Core_Exception */ public function preProcess() { $this->addOptionalQuickFormElement('parents'); @@ -127,12 +129,12 @@ public function preProcess() { $this->setTitle(ts('Confirm Group Delete')); } if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) { - CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved group.")); + CRM_Core_Error::statusBounce(ts('You do not have sufficient permission to delete this reserved group.')); } } else { if ($this->_id && $this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) { - CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to change settings for this reserved group.")); + CRM_Core_Error::statusBounce(ts('You do not have sufficient permission to change settings for this reserved group.')); } if (isset($this->_id)) { $groupValues = array( @@ -140,18 +142,11 @@ public function preProcess() { 'title' => $this->_title, 'saved_search_id' => $this->_groupValues['saved_search_id'] ?? '', ); - if (isset($this->_groupValues['saved_search_id'])) { - $this->assign('editSmartGroupURL', CRM_Contact_BAO_SavedSearch::getEditSearchUrl($this->_groupValues['saved_search_id'])); - } - if (!empty($this->_groupValues['created_id'])) { - $groupValues['created_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['created_id'], 'sort_name', 'id'); - } - - if (!empty($this->_groupValues['modified_id'])) { - $groupValues['modified_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['modified_id'], 'sort_name', 'id'); - } + $this->assign('editSmartGroupURL', isset($this->_groupValues['saved_search_id']) ? CRM_Contact_BAO_SavedSearch::getEditSearchUrl($this->_groupValues['saved_search_id']) : NULL); + $groupValues['created_by'] = empty($this->_groupValues['created_id']) ? NULL : CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_groupValues['created_id'], 'sort_name', 'id'); + $groupValues['modified_by'] = empty($this->_groupValues['modified_id']) ? NULL : CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_groupValues['modified_id'], 'sort_name', 'id'); - $this->assign_by_ref('group', $groupValues); + $this->assign('group', $groupValues); $this->setTitle(ts('Group Settings: %1', array(1 => $this->_title))); } diff --git a/templates/CRM/Group/Form/Edit.tpl b/templates/CRM/Group/Form/Edit.tpl index 912a9f88f449..dc493bf44339 100644 --- a/templates/CRM/Group/Form/Edit.tpl +++ b/templates/CRM/Group/Form/Edit.tpl @@ -69,7 +69,7 @@ {$form.is_active.html} - {if !empty($group.created_by)} + {if $group.created_by} {ts}Created By{/ts} {$group.created_by} @@ -105,10 +105,10 @@ {literal}