);
}
+ //CRM-14190
+ CRM_Group_Form_Edit::buildParentGroups($this);
+
// get the group id for the saved search
$groupID = NULL;
if (isset($this->_id)) {
$params['saved_search_id'] = $savedSearch->id;
$params['is_active'] = 1;
+ //CRM-14190
+ $params['parents'] = $formValues['parents'];
+
if ($this->_id) {
$params['id'] = CRM_Contact_BAO_SavedSearch::getName($this->_id, 'id');
}
// CRM-9464
$this->_id = $savedSearch->id;
+
+ //CRM-14190
+ if ( !empty($formValues['parents']) ) {
+ CRM_Contact_BAO_GroupNestingCache::update();
+ }
}
}
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::groupVisibility(), TRUE);
- $groupNames = CRM_Core_PseudoConstant::group();
+ //CRM-14190
+ $parentGroups = self::buildParentGroups($this);
- $parentGroups = $parentGroupElements = array();
- if (isset($this->_id) && !empty($this->_groupValues['parents'])) {
- $parentGroupIds = explode(',', $this->_groupValues['parents']);
- foreach ($parentGroupIds as $parentGroupId) {
- $parentGroups[$parentGroupId] = $groupNames[$parentGroupId];
- if (array_key_exists($parentGroupId, $groupNames)) {
- $parentGroupElements[$parentGroupId] = $groupNames[$parentGroupId];
- $this->addElement('checkbox', "remove_parent_group_$parentGroupId",
- $groupNames[$parentGroupId]
- );
- }
- }
- }
- $this->assign_by_ref('parent_groups', $parentGroupElements);
-
- if (isset($this->_id)) {
- $potentialParentGroupIds = CRM_Contact_BAO_GroupNestingCache::getPotentialCandidates($this->_id,
- $groupNames
- );
- }
- else {
- $potentialParentGroupIds = array_keys($groupNames);
- }
-
- $parentGroupSelectValues = array('' => '- ' . ts('select') . ' -');
- foreach ($potentialParentGroupIds as $potentialParentGroupId) {
- if (array_key_exists($potentialParentGroupId, $groupNames)) {
- $parentGroupSelectValues[$potentialParentGroupId] = $groupNames[$potentialParentGroupId];
- }
- }
-
- if (count($parentGroupSelectValues) > 1) {
- if (CRM_Core_Permission::isMultisiteEnabled()) {
- $required = empty($parentGroups) ? TRUE : FALSE;
- $required = (($this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id)) ||
- !isset($this->_id)
- ) ? FALSE : $required;
- }
- else {
- $required = FALSE;
- }
- $this->add('select', 'parents', ts('Add Parent'), $parentGroupSelectValues, $required);
- }
if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) {
//group organization Element
$props = array('api' => array('params' => array('contact_type' => 'Organization')));
$group = CRM_Contact_BAO_Group::create($params);
/*
- * Remove any parent groups requested to be removed
- */
+ * Remove any parent groups requested to be removed
+ */
if (!empty($this->_groupValues['parents'])) {
$parentGroupIds = explode(',', $this->_groupValues['parents']);
CRM_Contact_BAO_GroupNestingCache::update();
}
}
+
+ /*
+ * Build parent groups form elements
+ *
+ * @obj form object passed by reference
+ *
+ * @return parent groups array
+ * @static
+ * @access public
+ */
+ static function buildParentGroups( &$obj ) {
+ $groupNames = CRM_Core_PseudoConstant::group();
+ $parentGroups = $parentGroupElements = array();
+ if (isset($obj->_id) &&
+ CRM_Utils_Array::value('parents', $obj->_groupValues)
+ ) {
+ $parentGroupIds = explode(',', $obj->_groupValues['parents']);
+ foreach ($parentGroupIds as $parentGroupId) {
+ $parentGroups[$parentGroupId] = $groupNames[$parentGroupId];
+ if (array_key_exists($parentGroupId, $groupNames)) {
+ $parentGroupElements[$parentGroupId] = $groupNames[$parentGroupId];
+ $obj->addElement('checkbox', "remove_parent_group_$parentGroupId",
+ $groupNames[$parentGroupId]
+ );
+ }
+ }
+ }
+ $obj->assign_by_ref('parent_groups', $parentGroupElements);
+
+ if (isset($obj->_id)) {
+ $potentialParentGroupIds = CRM_Contact_BAO_GroupNestingCache::getPotentialCandidates($obj->_id,
+ $groupNames
+ );
+ }
+ else {
+ $potentialParentGroupIds = array_keys($groupNames);
+ }
+
+ $parentGroupSelectValues = array('' => '- ' . ts('select') . ' -');
+ foreach ($potentialParentGroupIds as $potentialParentGroupId) {
+ if (array_key_exists($potentialParentGroupId, $groupNames)) {
+ $parentGroupSelectValues[$potentialParentGroupId] = $groupNames[$potentialParentGroupId];
+ }
+ }
+
+ if (count($parentGroupSelectValues) > 1) {
+ if (CRM_Core_Permission::isMultisiteEnabled()) {
+ $required = empty($parentGroups) ? TRUE : FALSE;
+ $required = (($obj->_id && CRM_Core_BAO_Domain::isDomainGroup($obj->_id)) ||
+ !isset($obj->_id)
+ ) ? FALSE : $required;
+ }
+ else {
+ $required = FALSE;
+ }
+ $obj->add('select', 'parents', ts('Add Parent'), $parentGroupSelectValues, $required);
+ }
+
+ return $parentGroups;
+ }
}
+--------------------------------------------------------------------+
*}
<div class="crm-form-block crm-block crm-contact-task-createsmartgroup-form-block">
-<h3>{ts}Smart Group{/ts}</h3>
- {if $qill[0]}
- <div id="search-status">
- <ul>
- {foreach from=$qill[0] item=criteria}
- <li>{$criteria}</li>
- {/foreach}
- </ul>
- <br />
- </div>
- {/if}
+ <h3>{ts}Smart Group{/ts}</h3>
+ {if $qill[0]}
+ <div id="search-status">
+ <ul>
+ {foreach from=$qill[0] item=criteria}
+ <li>{$criteria}</li>
+ {/foreach}
+ </ul>
+ <br />
+ </div>
+ {/if}
<table class="form-layout-compressed">
- <tr class="crm-contact-task-createsmartgroup-form-block-title">
- <td class="label">{$form.title.label}</td>
- <td>{$form.title.html}</td>
- </tr>
- <tr class="crm-contact-task-createsmartgroup-form-block-description">
- <td class="label">{$form.description.label}</td>
- <td>{$form.description.html}</td>
- </tr>
- {if $form.group_type}
- <tr class="crm-contact-task-createsmartgroup-form-block-group_type">
- <td class="label">{$form.group_type.label}</td>
- <td>{$form.group_type.html}</td>
- </tr>
- {/if}
+ <tr class="crm-contact-task-createsmartgroup-form-block-title">
+ <td class="label">{$form.title.label}</td>
+ <td>{$form.title.html}</td>
+ </tr>
+ <tr class="crm-contact-task-createsmartgroup-form-block-description">
+ <td class="label">{$form.description.label}</td>
+ <td>{$form.description.html}</td>
+ </tr>
+ {if $form.group_type}
+ <tr class="crm-contact-task-createsmartgroup-form-block-group_type">
+ <td class="label">{$form.group_type.label}</td>
+ <td>{$form.group_type.html}</td>
+ </tr>
+ {/if}
</table>
- <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+
+ {*CRM-14190*}
+ {include file="CRM/Group/Form/ParentGroups.tpl"}
+
+ <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
</tr>
</table>
- {if $parent_groups|@count > 0 or $form.parents.html}
- <h3>{ts}Parent Groups{/ts} {help id="id-group-parent" file="CRM/Group/Page/Group.hlp"}</h3>
- {if $parent_groups|@count > 0}
- <table class="form-layout-compressed">
- <tr>
- <td><label>{ts}Remove Parent?{/ts}</label></td>
- </tr>
- {foreach from=$parent_groups item=cgroup key=group_id}
- {assign var="element_name" value="remove_parent_group_"|cat:$group_id}
- <tr>
- <td> {$form.$element_name.html} {$form.$element_name.label}</td>
- </tr>
- {/foreach}
- </table>
- <br />
- {/if}
- <table class="form-layout-compressed">
- <tr class="crm-group-form-block-parents">
- <td class="label"> {$form.parents.label}</td>
- <td>{$form.parents.html|crmAddClass:huge}</td>
- </tr>
- </table>
- {/if}
+ {*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>
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*}
+{*CRM-14190*}
+{if $parent_groups|@count > 0 or $form.parents.html}
+ <h3>{ts}Parent Groups{/ts} {help id="id-group-parent" file="CRM/Group/Page/Group.hlp"}</h3>
+ {if $parent_groups|@count > 0}
+ <table class="form-layout-compressed">
+ <tr>
+ <td><label>{ts}Remove Parent?{/ts}</label></td>
+ </tr>
+ {foreach from=$parent_groups item=cgroup key=group_id}
+ {assign var="element_name" value="remove_parent_group_"|cat:$group_id}
+ <tr>
+ <td> {$form.$element_name.html} {$form.$element_name.label}</td>
+ </tr>
+ {/foreach}
+ </table>
+ <br />
+ {/if}
+ <table class="form-layout-compressed">
+ <tr class="crm-group-form-block-parents">
+ <td class="label"> {$form.parents.label}</td>
+ <td>{$form.parents.html|crmAddClass:huge}</td>
+ </tr>
+ </table>
+{/if}