Skip to content

Commit

Permalink
Merge pull request #25955 from colemanw/groupEdit
Browse files Browse the repository at this point in the history
Manage groups - add dedicated url for edit/delete group
  • Loading branch information
colemanw committed Mar 30, 2023
2 parents 5054b50 + b3be82d commit 2b9d36b
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 17 deletions.
8 changes: 4 additions & 4 deletions CRM/Contact/BAO/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'),
],
Expand All @@ -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'),
],
Expand Down
6 changes: 3 additions & 3 deletions CRM/Contact/DAO/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contact/Group.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:274a53bd3f45c01a13a3663e98d51768)
* (GenCodeChecksum:d9453f2a948783a20abc574cc0ba860a)
*/

/**
Expand Down Expand Up @@ -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]',
];

/**
Expand Down
6 changes: 6 additions & 0 deletions CRM/Core/xml/Menu/Group.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<access_arguments>edit groups</access_arguments>
<page_callback>CRM_Group_Controller</page_callback>
</item>
<item>
<path>civicrm/group/edit</path>
<title>Edit Group</title>
<access_arguments>edit groups</access_arguments>
<page_callback>CRM_Group_Form_Edit</page_callback>
</item>
<item>
<path>civicrm/ajax/grouplist</path>
<page_callback>CRM_Group_Page_AJAX::getGroupList</page_callback>
Expand Down
4 changes: 3 additions & 1 deletion CRM/Group/Form/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/Check/Component/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function checkSmartGroupCustomFieldCriteria() {
}
}
$groupEdit = '<a href="' . CRM_Utils_System::url('civicrm/contact/search/advanced', "reset=1&ssID={$field['ssid']}", TRUE) . '" title="' . ts('Edit search criteria', ['escape' => 'js']) . '"> <i class="crm-i fa-pencil" aria-hidden="true"></i> </a>';
$groupConfig = '<a href="' . CRM_Utils_System::url('civicrm/group', "reset=1&action=update&id={$id}", TRUE) . '" title="' . ts('Group settings', ['escape' => 'js']) . '"> <i class="crm-i fa-gear" aria-hidden="true"></i> </a>';
$groupConfig = '<a href="' . CRM_Utils_System::url('civicrm/group/edit', "reset=1&action=update&id={$id}", TRUE) . '" title="' . ts('Group settings', ['escape' => 'js']) . '"> <i class="crm-i fa-gear" aria-hidden="true"></i> </a>';
$html .= "<tr><td>{$id} - {$field['title']} </td><td>{$groupEdit} {$groupConfig}</td><td class='disabled'>{$fieldName}</td>";
}

Expand Down
6 changes: 5 additions & 1 deletion templates/CRM/Group/Form/Edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
<div class="crm-block crm-form-block crm-group-form-block">
<div class="help">
{if $action eq 2}
Expand Down Expand Up @@ -115,3 +118,4 @@
</script>
{/literal}
</div>
{/if}
4 changes: 1 addition & 3 deletions templates/CRM/Group/Page/Group.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Group/Page/AjaxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public function testGroupEditWithAndWithoutPermission() {
$params = $this->_params;
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
$this->assertEquals(2, $groups['recordsTotal']);
$this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&amp;reset=1&amp;force=1&amp;context=smog&amp;gid=4&amp;component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group&amp;reset=1&amp;action=update&amp;id=4" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group&amp;reset=1&amp;action=delete&amp;id=4" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][0]['links']);
$this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&amp;reset=1&amp;force=1&amp;context=smog&amp;gid=2&amp;component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group&amp;reset=1&amp;action=update&amp;id=2" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group&amp;reset=1&amp;action=delete&amp;id=2" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][1]['links']);
$this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&amp;reset=1&amp;force=1&amp;context=smog&amp;gid=4&amp;component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group/edit&amp;reset=1&amp;action=update&amp;id=4" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group/edit&amp;reset=1&amp;action=delete&amp;id=4" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][0]['links']);
$this->assertEquals('<span><a href="/index.php?q=civicrm/group/search&amp;reset=1&amp;force=1&amp;context=smog&amp;gid=2&amp;component_mode=1" class="action-item crm-hover-button" title=\'Group Contacts\' >Contacts</a><a href="/index.php?q=civicrm/group/edit&amp;reset=1&amp;action=update&amp;id=2" class="action-item crm-hover-button" title=\'Edit Group\' >Settings</a></span><span class=\'btn-slide crm-hover-button\'>more<ul class=\'panel\'><li><a href="#" class="action-item crm-hover-button crm-enable-disable" title=\'Disable Group\' >Disable</a></li><li><a href="/index.php?q=civicrm/group/edit&amp;reset=1&amp;action=delete&amp;id=2" class="action-item crm-hover-button small-popup" title=\'Delete Group\' >Delete</a></li></ul></span>', $groups['data'][1]['links']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions xml/schema/Contact/Group.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<paths>
<add>civicrm/group/add?reset=1</add>
<view>civicrm/group/search?force=1&amp;context=smog&amp;gid=[id]&amp;component_mode=1</view>
<update>civicrm/group?reset=1&amp;action=update&amp;id=[id]</update>
<delete>civicrm/group?reset=1&amp;action=delete&amp;id=[id]</delete>
<update>civicrm/group/edit?reset=1&amp;action=update&amp;id=[id]</update>
<delete>civicrm/group/edit?reset=1&amp;action=delete&amp;id=[id]</delete>
</paths>
<field>
<name>id</name>
Expand Down

0 comments on commit 2b9d36b

Please sign in to comment.