$form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE,
array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2')
);
- $groups = CRM_Core_PseudoConstant::group();
+ $groups = CRM_Core_PseudoConstant::nestedGroup();
$form->add('select', 'group', ts('Groups'), $groups, FALSE,
- array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')
+ array('multiple' => 'multiple', 'class' => 'crm-select2')
);
$showInterviewer = FALSE;
'' => ts('- select Parent -')) + $campaigns
);
}
-
+$groups = CRM_Core_PseudoConstant::nestedGroup();
//get the campaign groups.
- $groups = CRM_Core_PseudoConstant::group();
-
$this->add('select', 'includeGroups',
ts('Include Group(s)'),
$groups,
$this->addElement('text', 'ActivityType', ts('Activity Type'));
$this->addElement('text', 'newGroupName', ts('Name for new group'));
$this->addElement('text', 'newGroupDesc', ts('Description of new group'));
- $groups = CRM_Core_PseudoConstant::group();
+ $groups = CRM_Core_PseudoConstant::nestedGroup();
$hasExistingGroups = FALSE;
if (is_array($groups) && !empty($groups)) {
$hasExistingGroups = TRUE;
$this->addElement('select', 'groups', ts('Add respondent(s) to existing group(s)'),
- $groups, array('multiple' => "multiple", 'size' => 5)
+ $groups, array('multiple' => "multiple", 'class' => 'crm-select2')
);
}
$this->assign('hasExistingGroups', $hasExistingGroups);
*/
public function buildQuickForm() {
- $groupList = CRM_Core_PseudoConstant::group();
- $groupList[''] = ts('- All Contacts -');
- asort($groupList);
+ $groupList = array('' => ts('- All Contacts -')) + CRM_Core_PseudoConstant::nestedGroup();
$this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, array('class' => 'crm-select2 huge'));
$this->addButtons(array(
// this is loaded onto then replace with something like '__' & test
$separator = CRM_Core_DAO::VALUE_SEPARATOR;
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
- $form->add('select', 'contact_type', ts('Find...'), $contactTypes);
+ $form->add('select', 'contact_type', ts('Find...'), $contactTypes, FALSE, array('class' => 'crm-select2 huge'));
// add select for groups
- $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
- $form->addElement('select', 'group', ts('in'), $group);
+ $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup();
+ $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge'));
// add select for categories
$tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $form->addElement('select', 'tag', ts('Tagged'), $tag);
+ $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge'));
// text for sort_name
$form->add('text', 'sort_name', ts('Name'));
$form->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'custom'));
- $groups = CRM_Core_PseudoConstant::group();
+ $groups = CRM_Core_PseudoConstant::nestedGroup();
$select2style = array(
'multiple' => TRUE,
$this->setTitle(ts('Include / Exclude Search'));
- $groups = CRM_Core_PseudoConstant::group();
+ $groups = CRM_Core_PseudoConstant::nestedGroup();
$tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
if (count($groups) == 0 || count($tags) == 0) {
// this is loaded onto then replace with something like '__' & test
$separator = CRM_Core_DAO::VALUE_SEPARATOR;
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
- $form->add('select', 'contact_type', ts('Find...'), $contactTypes);
+ $form->add('select', 'contact_type', ts('Find...'), $contactTypes, array('class' => 'crm-select2 huge'));
// add select for groups
$group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
- $form->addElement('select', 'group', ts('in'), $group);
+ $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge'));
// add select for tags
$tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $form->addElement('select', 'tag', ts('Tagged'), $tag);
+ $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge'));
if (empty($this->_groupTree)) {
CRM_Core_Error::statusBounce(ts("Atleast one Custom Group must be present, for Custom Group search."),
* @param $form
*/
function buildForm(&$form) {
- $groups = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::allGroup();
- $form->addElement('select', 'group_id', ts('Group'), $groups);
+ $groups = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(FALSE);
+ $form->addElement('select', 'group_id', ts('Group'), $groups, array('class' => 'crm-select2 huge'));
/**
* if you are using the standard template, this array tells the template what elements
else {
$stateProvince = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince();
}
- $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
+ $form->add('select', 'state_province_id', ts('State/Province'), $stateProvince, FALSE, array('class' => 'crm-select2 huge'));
$country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
- $form->add('select', 'country_id', ts('Country'), $country, TRUE);
+ $form->add('select', 'country_id', ts('Country'), $country, TRUE, array('class' => 'crm-select2 huge'));
- $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
- $form->addElement('select', 'group', ts('Group'), $group);
+ $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup();
+ $form->addElement('select', 'group', ts('Group'), $group, array('class' => 'crm-select2 huge'));
$tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $form->addElement('select', 'tag', ts('Tag'), $tag);
+ $form->addElement('select', 'tag', ts('Tag'), $tag, array('class' => 'crm-select2 huge'));
// state country js, CRM-5233
TRUE
);
- $groups = CRM_Core_PseudoConstant::group();
+ $groups = CRM_Core_PseudoConstant::nestedGroup();
$select2style = array(
'multiple' => TRUE,
}
// add select for groups
- $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::group();
+ $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup();
$groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, FALSE, array('class' => 'crm-select2 huge'));
CRM_Core_Session::setStatus(ts("The contact type selected for Batch Update does not have a corresponding profile. Please set up a profile for %1s and try again.", array(1 => $types)), ts('No Profile Available'), 'error');
CRM_Utils_System::redirect($this->_userContext);
}
- $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE);
+ $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE, array('class' => 'crm-select2 huge'));
$this->addDefaultButtons(ts('Continue >>'));
}
*/
function buildQuickForm() {
// add select for groups
- $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::group();
+ $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup();
$groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, TRUE, array('class' => 'crm-select2 huge'));
CRM_Utils_System::setTitle(ts('Remove Contacts from Group'));
$this->assign('rowDisplayCount', 2);
- $groups = CRM_Core_PseudoConstant::group();
+ $groups = CRM_Core_PseudoConstant::nestedGroup();
$this->set('groups', $groups);
$tag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$groups = $this->get('groups');
if (!empty($groups)) {
- $this->addElement('select', 'groups', ts('Add imported records to existing group(s)'), $groups, array('multiple' => "multiple", 'size' => 5));
+ $this->addElement('select', 'groups', ts('Add imported records to existing group(s)'), $groups, array('multiple' => "multiple", 'class' => 'crm-select2'));
}
//display new tag
)
);
- $this->_group = CRM_Core_PseudoConstant::group();
+ $this->_group = CRM_Core_PseudoConstant::nestedGroup();
// multiselect for groups
if ($this->_group) {
}
/**
- * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
- *
* Get all permissioned groups from database
*
* The static array group is returned, and if it's
* Note: any database errors will be trapped by the DAO.
*
* @param string $groupType type of group(Access/Mailing)
- * @param bool|\boolen $excludeHidden exclude hidden groups.
+ * @param bool $excludeHidden exclude hidden groups.
*
* @access public
* @static
return CRM_Core_Permission::group($groupType, $excludeHidden);
}
+ /**
+ * Fetch groups in a nested format suitable for use in select form element
+ * @param bool $checkPermissions
+ * @param string|null $groupType
+ * @param bool $excludeHidden
+ * @return array
+ */
+ public static function nestedGroup($checkPermissions = TRUE, $groupType = NULL, $excludeHidden = TRUE) {
+ $groups = $checkPermissions ? self::group($groupType, $excludeHidden) : self::allGroup($groupType, $excludeHidden);
+ return CRM_Contact_BAO_Group::getGroupsHierarchy($groups, NULL, ' ', TRUE);
+ }
+
/**
* Get all permissioned groups from database
*
$this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => true));
+ $groups = CRM_Contact_BAO_Group::getGroupsHierarchy(CRM_Core_PseudoConstant::staticGroup(), NULL, ' ', TRUE);
$this->add('select', 'group_id', ts('Group'),
- CRM_Core_PseudoConstant::staticGroup(), FALSE, array('class' => 'crm-select2 huge')
+ $groups, FALSE, array('class' => 'crm-select2 huge')
);
CRM_Mailing_BAO_Mailing::commonCompose($this);
$this->addGroup($postalMailing, 'postal_mailing_export', ts('Postal Mailing Export'), '<br/>');
$this->addElement('select', 'additional_group', ts('Additional Group for Export'),
- array('' => ts('- select group -')) + CRM_Core_PseudoConstant::group()
+ array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(),
+ array('class' => 'crm-select2 huge')
);
}
)
);
- $this->_group = CRM_Core_PseudoConstant::group();
+ $this->_group = CRM_Core_PseudoConstant::nestedGroup();
// multiselect for groups
if ($this->_group) {
$this->addElement('checkbox', 'dedupe_email', ts('Remove duplicate emails?'));
//get the mailing groups.
- $groups = CRM_Core_PseudoConstant::group('Mailing');
+ $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
if ($hiddenMailingGroup) {
$groups[$hiddenMailingGroup] =
CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $hiddenMailingGroup, 'title');
$this->add('select', 'baseGroup',
ts('Unsubscription Group'),
array(
- '' => ts('- select -')) + $staticGroups,
+ '' => ts('- select -')) + CRM_Contact_BAO_Group::getGroupsHierarchy($staticGroups, NULL, ' ', TRUE),
TRUE,
array('class' => 'crm-select2 huge')
);
if (CRM_Core_Permission::check('administer Reports') && $this->_add2groupSupported) {
$this->addElement('select', 'groups', ts('Group'),
- array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup()
+ array('' => ts('Add Contacts to Group')) + CRM_Core_PseudoConstant::nestedGroup(),
+ array('class' => 'crm-select2 crm-action-menu action-icon-plus huge')
);
$this->assign('group', TRUE);
}
- $label = ts('Add These Contacts to Group');
- $this->addElement('submit', $this->_groupButtonName, $label, array('onclick' => 'return checkGroup();'));
+ $this->addElement('submit', $this->_groupButtonName, '', array('style' => 'display: none;'));
$this->addChartOptions();
$this->addButtons(array(
);
//get the mailing groups.
- $groups = CRM_Core_PseudoConstant::group('Mailing');
+ $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
//get the sms mailing list
$mailings = CRM_Mailing_PseudoConstant::completed('sms');
{/if}
{if $form.groups}
<tr>
- <td>{$form.groups.html|crmAddClass:big}</td>
- <td align="right">{$form.$group.html}</td>
+ <td>
+ {$form.groups.html}{$form.$group.html}
+ <script type="text/javascript">
+ {literal}
+ (function($) {
+ $('#groups').val('').change(function() {
+ CRM.confirm({
+ message: ts({/literal}'{ts escape='js' 1='<em>%1</em>'}Add all contacts to %1 group?{/ts}'{literal}, {1: $('option:selected', '#groups').text()})
+ })
+ .on('crmConfirm:yes', function() {
+ $('#groups').siblings(':submit').click();
+ });
+ $('#groups').select2('val', '');
+ });
+ })(CRM.$);
+ {/literal}
+ </script>
+ </td>
</tr>
{/if}
</table>