Skip to content

Commit

Permalink
Merge pull request #8751 from eileenmcnaughton/groupOrg
Browse files Browse the repository at this point in the history
CRM-19122 Group Organization & parent default code should be the same
  • Loading branch information
eileenmcnaughton authored Oct 14, 2016
2 parents 7a100ba + d44e3ae commit f3431cb
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
14 changes: 14 additions & 0 deletions CRM/Contact/Form/Task/SaveSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

}
23 changes: 17 additions & 6 deletions CRM/Group/Form/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?'));
Expand Down Expand Up @@ -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);
}
}

}
2 changes: 1 addition & 1 deletion templates/CRM/Contact/Form/Task/SaveSearch.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</table>

{*CRM-14190*}
{include file="CRM/Group/Form/ParentGroups.tpl"}
{include file="CRM/Group/Form/GroupsCommon.tpl"}

<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
14 changes: 1 addition & 13 deletions templates/CRM/Group/Form/Edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,7 @@
</table>

{*CRM-14190*}
{include file="CRM/Group/Form/ParentGroups.tpl"}

{if $form.organization_id}
<h3>{ts}Associated Organization{/ts} {help id="id-group-organization" file="CRM/Group/Page/Group.hlp"}</h3>
<table class="form-layout-compressed">
<tr class="crm-group-form-block-organization">
<td class="label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$form.organization_id.label}</td>
<td>{$form.organization_id.html|crmAddClass:huge}
</td>
</tr>
</table>
{/if}
{include file="CRM/Group/Form/GroupsCommon.tpl"}

<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
{if $action neq 1}
Expand All @@ -118,7 +107,6 @@
{/if}
</div>
{/if}
</fieldset>

{literal}
<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@
</tr>
</table>
{/if}
{if $form.organization_id}
<h3>{ts}Associated Organization{/ts} {help id="id-group-organization" file="CRM/Group/Page/Group.hlp"}</h3>
<table class="form-layout-compressed">
<tr class="crm-group-form-block-organization">
<td class="label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$form.organization_id.label}</td>
<td>{$form.organization_id.html|crmAddClass:huge}
</td>
</tr>
</table>
{/if}

0 comments on commit f3431cb

Please sign in to comment.