From b3be82df67218c8b9a60246cf907a7df418c8b8c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 29 Mar 2023 20:45:53 -0400 Subject: [PATCH] Manage groups - add dedicated url for edit/delete group --- CRM/Contact/BAO/Group.php | 8 ++++---- CRM/Contact/DAO/Group.php | 6 +++--- CRM/Core/xml/Menu/Group.xml | 6 ++++++ CRM/Group/Form/Edit.php | 4 +++- CRM/Utils/Check/Component/Schema.php | 2 +- templates/CRM/Group/Form/Edit.tpl | 6 +++++- templates/CRM/Group/Page/Group.tpl | 4 +--- tests/phpunit/CRM/Group/Page/AjaxTest.php | 4 ++-- xml/schema/Contact/Group.xml | 4 ++-- 9 files changed, 27 insertions(+), 17 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 15ce4f712845..38131496c882 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -493,9 +493,9 @@ public static function create(&$params) { $recentOther = []; if (CRM_Core_Permission::check('edit groups')) { - $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=update&id=' . $group->id); + $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/group/edit', 'reset=1&action=update&id=' . $group->id); // currently same permission we are using for delete a group - $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=delete&id=' . $group->id); + $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/group/edit', 'reset=1&action=delete&id=' . $group->id); } // add the recently added group (unless hidden: CRM-6432) @@ -1304,7 +1304,7 @@ public static function actionLinks($params) { ], CRM_Core_Action::UPDATE => [ 'name' => ts('Settings'), - 'url' => 'civicrm/group', + 'url' => 'civicrm/group/edit', 'qs' => 'reset=1&action=update&id=%%id%%', 'title' => ts('Edit Group'), ], @@ -1320,7 +1320,7 @@ public static function actionLinks($params) { ], CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), - 'url' => 'civicrm/group', + 'url' => 'civicrm/group/edit', 'qs' => 'reset=1&action=delete&id=%%id%%', 'title' => ts('Delete Group'), ], diff --git a/CRM/Contact/DAO/Group.php b/CRM/Contact/DAO/Group.php index 31d6ce43cc82..2481edfcfd98 100644 --- a/CRM/Contact/DAO/Group.php +++ b/CRM/Contact/DAO/Group.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contact/Group.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:274a53bd3f45c01a13a3663e98d51768) + * (GenCodeChecksum:d9453f2a948783a20abc574cc0ba860a) */ /** @@ -52,8 +52,8 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO { protected static $_paths = [ 'add' => 'civicrm/group/add?reset=1', 'view' => 'civicrm/group/search?force=1&context=smog&gid=[id]&component_mode=1', - 'update' => 'civicrm/group?reset=1&action=update&id=[id]', - 'delete' => 'civicrm/group?reset=1&action=delete&id=[id]', + 'update' => 'civicrm/group/edit?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/group/edit?reset=1&action=delete&id=[id]', ]; /** diff --git a/CRM/Core/xml/Menu/Group.xml b/CRM/Core/xml/Menu/Group.xml index 1e5c262ab518..4bbc5d1c6737 100644 --- a/CRM/Core/xml/Menu/Group.xml +++ b/CRM/Core/xml/Menu/Group.xml @@ -23,6 +23,12 @@ edit groups CRM_Group_Controller + + civicrm/group/edit + Edit Group + edit groups + CRM_Group_Form_Edit + civicrm/ajax/grouplist CRM_Group_Page_AJAX::getGroupList diff --git a/CRM/Group/Form/Edit.php b/CRM/Group/Form/Edit.php index 735a19d3c64c..28d07afd9ded 100644 --- a/CRM/Group/Form/Edit.php +++ b/CRM/Group/Form/Edit.php @@ -99,7 +99,8 @@ public function preProcess() { 'parent_groups', 'editSmartGroupURL', ]); - $this->_id = $this->get('id'); + // current set id + $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); if ($this->_id) { $breadCrumb = array( array( @@ -156,6 +157,7 @@ public function preProcess() { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/group', 'reset=1')); } + $this->addExpectedSmartyVariables(['freezeMailingList', 'hideMailingList']); //build custom data CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Group', $this->_id); diff --git a/CRM/Utils/Check/Component/Schema.php b/CRM/Utils/Check/Component/Schema.php index 2911a9917d11..da26ccc5e2a1 100644 --- a/CRM/Utils/Check/Component/Schema.php +++ b/CRM/Utils/Check/Component/Schema.php @@ -154,7 +154,7 @@ public function checkSmartGroupCustomFieldCriteria() { } } $groupEdit = ' '; - $groupConfig = ' '; + $groupConfig = ' '; $html .= "{$id} - {$field['title']} {$groupEdit} {$groupConfig}{$fieldName}"; } diff --git a/templates/CRM/Group/Form/Edit.tpl b/templates/CRM/Group/Form/Edit.tpl index dc493bf44339..41576a9f5273 100644 --- a/templates/CRM/Group/Form/Edit.tpl +++ b/templates/CRM/Group/Form/Edit.tpl @@ -7,7 +7,10 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{* this template is used for adding/editing group (name and description only) *} +{* this template is used for adding/editing/deleting a group *} +{if $action eq 8} + {include file="CRM/Group/Form/Delete.tpl"} +{else}
{if $action eq 2} @@ -115,3 +118,4 @@ {/literal}
+{/if} diff --git a/templates/CRM/Group/Page/Group.tpl b/templates/CRM/Group/Page/Group.tpl index f36bfdc74312..134d2b10284e 100644 --- a/templates/CRM/Group/Page/Group.tpl +++ b/templates/CRM/Group/Page/Group.tpl @@ -23,10 +23,8 @@ {include file="CRM/Group/Form/Search.tpl"} {/if} -{if $action eq 1 or $action eq 2} +{if $action eq 1 or $action eq 2 or $action eq 8} {include file="CRM/Group/Form/Edit.tpl"} -{elseif $action eq 8} - {include file="CRM/Group/Form/Delete.tpl"} {/if} {if $action ne 1 and $action ne 2 and $action ne 8 and $groupPermission eq 1} diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index 23838240a514..acb7ad4bc73a 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -163,8 +163,8 @@ public function testGroupEditWithAndWithoutPermission() { $params = $this->_params; $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); $this->assertEquals(2, $groups['recordsTotal']); - $this->assertEquals('ContactsSettingsmore', $groups['data'][0]['links']); - $this->assertEquals('ContactsSettingsmore', $groups['data'][1]['links']); + $this->assertEquals('ContactsSettingsmore', $groups['data'][0]['links']); + $this->assertEquals('ContactsSettingsmore', $groups['data'][1]['links']); } /** diff --git a/xml/schema/Contact/Group.xml b/xml/schema/Contact/Group.xml index f66368a3a993..5af8a76aa382 100644 --- a/xml/schema/Contact/Group.xml +++ b/xml/schema/Contact/Group.xml @@ -12,8 +12,8 @@ civicrm/group/add?reset=1 civicrm/group/search?force=1&context=smog&gid=[id]&component_mode=1 - civicrm/group?reset=1&action=update&id=[id] - civicrm/group?reset=1&action=delete&id=[id] + civicrm/group/edit?reset=1&action=update&id=[id] + civicrm/group/edit?reset=1&action=delete&id=[id] id