Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-19122 Group Organization & parent default code should be the same #8751

Merged
merged 1 commit into from
Oct 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton I notice here that you are setting the default as having a parent group here, I am just wondering how that works with multisite given iirc in multisite extension we are looking at default being the domain org contact not the domain group

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - have I changed the behaviour? Wouldn't that still be overridden?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might but it was just a thought,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked & this behaviour is also in CRM_Group_Form_Edit - the multisite extension overrides it.

  • would be good to get this merged

}
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}