From d44e3aea08ba657c9be82c9ca47a2799b8dfc3b3 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Mon, 25 Jul 2016 18:00:46 +1200 Subject: [PATCH] CRM-19122 Group Organization & parent default code should be the same --- CRM/Contact/Form/Task/SaveSearch.php | 14 +++++++++++ CRM/Group/Form/Edit.php | 23 ++++++++++++++----- .../CRM/Contact/Form/Task/SaveSearch.tpl | 2 +- templates/CRM/Group/Form/Edit.tpl | 14 +---------- .../{ParentGroups.tpl => GroupsCommon.tpl} | 10 ++++++++ 5 files changed, 43 insertions(+), 20 deletions(-) rename templates/CRM/Group/Form/{ParentGroups.tpl => GroupsCommon.tpl} (85%) diff --git a/CRM/Contact/Form/Task/SaveSearch.php b/CRM/Contact/Form/Task/SaveSearch.php index 2e1f7a9e7730..e8632ccdaef7 100644 --- a/CRM/Contact/Form/Task/SaveSearch.php +++ b/CRM/Contact/Form/Task/SaveSearch.php @@ -118,6 +118,7 @@ public function buildQuickForm() { //CRM-14190 CRM_Group_Form_Edit::buildParentGroups($this); + CRM_Group_Form_Edit::buildGroupOrganizations($this); // get the group id for the saved search $groupID = NULL; @@ -240,4 +241,17 @@ public function postProcess() { } } + /** + * Set form defaults. + * + * return array + */ + public function setDefaultValues() { + $defaults = array(); + if (empty($defaults['parents'])) { + $defaults['parents'] = CRM_Core_BAO_Domain::getGroupId(); + } + return $defaults; + } + } diff --git a/CRM/Group/Form/Edit.php b/CRM/Group/Form/Edit.php index 2537155e9603..e3c97df4b6cf 100644 --- a/CRM/Group/Form/Edit.php +++ b/CRM/Group/Form/Edit.php @@ -254,12 +254,7 @@ public function buildQuickForm() { //CRM-14190 $parentGroups = self::buildParentGroups($this); - - if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) { - //group organization Element - $props = array('api' => array('params' => array('contact_type' => 'Organization'))); - $this->addEntityRef('organization_id', ts('Organization'), $props); - } + self::buildGroupOrganizations($this); // is_reserved property CRM-9936 $this->addElement('checkbox', 'is_reserved', ts('Reserved Group?')); @@ -484,4 +479,20 @@ public static function buildParentGroups(&$form) { return $parentGroups; } + /** + * Add the group organization checkbox to the form. + * + * Note this was traditionally a multisite thing - there is no particular reason why it is not available + * as a general field - it's historical use-case driven. + * + * @param CRM_Core_Form $form + */ + public static function buildGroupOrganizations(&$form) { + if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) { + //group organization Element + $props = array('api' => array('params' => array('contact_type' => 'Organization'))); + $form->addEntityRef('organization_id', ts('Organization'), $props); + } + } + } diff --git a/templates/CRM/Contact/Form/Task/SaveSearch.tpl b/templates/CRM/Contact/Form/Task/SaveSearch.tpl index 209303d93a03..cb5218fe3ec0 100644 --- a/templates/CRM/Contact/Form/Task/SaveSearch.tpl +++ b/templates/CRM/Contact/Form/Task/SaveSearch.tpl @@ -59,7 +59,7 @@ {*CRM-14190*} - {include file="CRM/Group/Form/ParentGroups.tpl"} + {include file="CRM/Group/Form/GroupsCommon.tpl"}
{include file="CRM/common/formButtons.tpl" location="bottom"}
diff --git a/templates/CRM/Group/Form/Edit.tpl b/templates/CRM/Group/Form/Edit.tpl index 04a0c91a02e6..8283067deb27 100644 --- a/templates/CRM/Group/Form/Edit.tpl +++ b/templates/CRM/Group/Form/Edit.tpl @@ -88,18 +88,7 @@ {*CRM-14190*} - {include file="CRM/Group/Form/ParentGroups.tpl"} - - {if $form.organization_id} -

{ts}Associated Organization{/ts} {help id="id-group-organization" file="CRM/Group/Page/Group.hlp"}

- - - - - -
      {$form.organization_id.label}{$form.organization_id.html|crmAddClass:huge} -
- {/if} + {include file="CRM/Group/Form/GroupsCommon.tpl"}
{include file="CRM/common/formButtons.tpl" location="bottom"}
{if $action neq 1} @@ -118,7 +107,6 @@ {/if} {/if} - {literal}