From: eileenmcnaugton Date: Mon, 25 Jul 2016 06:00:46 +0000 (+1200) Subject: CRM-19122 Group Organization & parent default code should be the same X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d44e3aea08ba657c9be82c9ca47a2799b8dfc3b3;p=civicrm-core.git CRM-19122 Group Organization & parent default code should be the same --- diff --git a/CRM/Contact/Form/Task/SaveSearch.php b/CRM/Contact/Form/Task/SaveSearch.php index 2e1f7a9e77..e8632ccdae 100644 --- a/CRM/Contact/Form/Task/SaveSearch.php +++ b/CRM/Contact/Form/Task/SaveSearch.php @@ -118,6 +118,7 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task { //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 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task { } } + /** + * 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 2537155e96..e3c97df4b6 100644 --- a/CRM/Group/Form/Edit.php +++ b/CRM/Group/Form/Edit.php @@ -254,12 +254,7 @@ class CRM_Group_Form_Edit extends CRM_Core_Form { //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 @@ WHERE title = %1 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 209303d93a..cb5218fe3e 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 04a0c91a02..8283067deb 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}