diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 552db8f9d111..b0c2619c68eb 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -1073,7 +1073,7 @@ public static function getGroupsHierarchy( $groups = []; $args = [1 => [$groupIdString, 'String']]; $query = " -SELECT id, title, description, visibility, parents +SELECT id, title, description, visibility, parents, saved_search_id FROM civicrm_group WHERE id IN $groupIdString "; @@ -1102,7 +1102,8 @@ public static function getGroupsHierarchy( 'title' => $dao->title, 'visibility' => $dao->visibility, 'description' => $dao->description, - ]; + 'icon' => empty($dao->saved_search_id) ? NULL : 'fa-lightbulb-o', + ); } else { $roots[] = [ @@ -1110,7 +1111,8 @@ public static function getGroupsHierarchy( 'title' => $dao->title, 'visibility' => $dao->visibility, 'description' => $dao->description, - ]; + 'icon' => empty($dao->saved_search_id) ? NULL : 'fa-lightbulb-o', + ); } } @@ -1118,6 +1120,7 @@ public static function getGroupsHierarchy( for ($i = 0; $i < count($roots); $i++) { self::buildGroupHierarchy($hierarchy, $roots[$i], $tree, $titleOnly, $spacer, 0); } + return $hierarchy; } @@ -1140,11 +1143,13 @@ private static function buildGroupHierarchy(&$hierarchy, $group, $tree, $titleOn $hierarchy[$group['id']] = $spaces . $group['title']; } else { - $hierarchy[$group['id']] = [ - 'title' => $spaces . $group['title'], + $hierarchy[] = array( + 'id' => $group['id'], + 'text' => $spaces . $group['title'], 'description' => $group['description'], 'visibility' => $group['visibility'], - ]; + 'icon' => $group['icon'], + ); } // For performance reasons we use a for loop rather than a foreach. diff --git a/CRM/Contact/Form/Edit/TagsAndGroups.php b/CRM/Contact/Form/Edit/TagsAndGroups.php index b89c3a023e9e..0f08c870aab4 100644 --- a/CRM/Contact/Form/Edit/TagsAndGroups.php +++ b/CRM/Contact/Form/Edit/TagsAndGroups.php @@ -118,7 +118,7 @@ public static function buildQuickForm( } if ($groupElementType == 'select') { - $groupsOptions[$id] = $group['title']; + $groupsOptions[$id] = $group; } else { $form->_tagGroup[$fName][$id]['description'] = $group['description']; @@ -127,8 +127,8 @@ public static function buildQuickForm( } if ($groupElementType == 'select' && !empty($groupsOptions)) { - $form->add('select', $fName, $groupName, $groupsOptions, FALSE, - ['id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2 twenty'] + $form->add('select2', $fName, $groupName, $groupsOptions, FALSE, + ['placeholder' => '- select -', 'multiple' => TRUE, 'class' => 'twenty'] ); $form->assign('groupCount', count($groupsOptions)); } diff --git a/CRM/Contact/Form/Search/Basic.php b/CRM/Contact/Form/Search/Basic.php index 9a3386836dbb..a7215810adda 100644 --- a/CRM/Contact/Form/Search/Basic.php +++ b/CRM/Contact/Form/Search/Basic.php @@ -65,14 +65,15 @@ public function buildQuickForm() { // add select for groups // Get hierarchical listing of groups, respecting ACLs for CRM-16836. - $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '  ', TRUE); + $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '  '); if (!empty($searchOptions['groups'])) { - $this->addField('group', [ - 'entity' => 'group_contact', - 'label' => ts('in'), - 'placeholder' => ts('- any group -'), - 'options' => $groupHierarchy, - ]); + $this->addField('group', array[ + 'entity' => 'group_contact', + 'label' => ts('in'), + 'placeholder' => ts('- any group -'), + 'options' => $groupHierarchy, + 'type' => 'Select2', + ]); } if (!empty($searchOptions['tags'])) { diff --git a/ang/crmMailing/Recipients.js b/ang/crmMailing/Recipients.js index 4203d4a3c8f7..64ca26b48fb1 100644 --- a/ang/crmMailing/Recipients.js +++ b/ang/crmMailing/Recipients.js @@ -94,7 +94,7 @@ return item.text; } var option = convertValueToObj(item.id); - var icon = (option.entity_type === 'civicrm_mailing') ? 'fa-envelope' : 'fa-users'; + var icon = (option.entity_type === 'civicrm_mailing') ? 'fa-envelope' : item.is_smart ? 'fa-lightbulb-o' : 'fa-users'; var spanClass = (option.mode == 'exclude') ? 'crmMailing-exclude' : 'crmMailing-include'; if (option.entity_type != 'civicrm_mailing' && isMandatory(option.entity_id)) { spanClass = 'crmMailing-mandatory'; @@ -154,7 +154,7 @@ mids.push(0); } - CRM.api3('Group', 'getlist', { params: { id: { IN: gids }, options: { limit: 0 } }, extra: ["is_hidden"] } ).then( + CRM.api3('Group', 'getlist', { params: { id: { IN: gids }, options: { limit: 0 } }, extra: ["is_hidden"] }).then( function(glist) { CRM.api3('Mailing', 'getlist', { params: { id: { IN: mids }, options: { limit: 0 } } }).then( function(mlist) { @@ -165,8 +165,8 @@ $(glist.values).each(function (idx, group) { var key = group.id + ' civicrm_group include'; - groupNames.push({id: parseInt(group.id), title: group.label, is_hidden: group.extra.is_hidden}); + groupNames.push({id: parseInt(group.id), title: group.label, is_hidden: group.extra.is_hidden}); if (values.indexOf(key) >= 0) { datamap.push({id: key, text: group.label}); } @@ -239,7 +239,7 @@ transport: function(params) { switch(rcpAjaxState.entity) { case 'civicrm_group': - CRM.api3('Group', 'getlist', params.data).then(params.success, params.error); + CRM.api3('Group', 'get', params.data).then(params.success, params.error); break; case 'civicrm_mailing': @@ -255,9 +255,8 @@ return obj["api.MailingRecipients.getcount"] > 0 ? { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, text: obj.label } : ''; } - else { - return { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, - text: obj.label }; + else if (obj.is_hidden == 0) { + return { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, text: obj.title, is_smart: (!_.isEmpty(obj.saved_search_id)) }; } }) };