From edc904c69c8f91ffd1981f6d7075c54690d5a813 Mon Sep 17 00:00:00 2001 From: Monish Deb Date: Mon, 25 Nov 2019 09:51:51 +0530 Subject: [PATCH] user group.getlist api --- CRM/Contact/BAO/Group.php | 10 +++------- CRM/Contact/Form/Contact.php | 5 +++-- CRM/Contact/Form/Search/Criteria.php | 2 +- ang/crmMailing/Recipients.js | 15 ++++++++++----- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 4a02822d02..7d7f7c0085 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -1078,19 +1078,17 @@ WHERE id IN $groupIdString $parent = self::filterActiveGroups($parentArray); $tree[$parent][] = [ 'id' => $dao->id, - 'title' => $dao->title, + 'title' => empty($dao->saved_search_id) ? $dao->title : '* ' . $dao->title, 'visibility' => $dao->visibility, 'description' => $dao->description, - 'icon' => empty($dao->saved_search_id) ? NULL : 'fa-lightbulb-o', ]; } else { $roots[] = [ 'id' => $dao->id, - 'title' => $dao->title, + 'title' => empty($dao->saved_search_id) ? $dao->title : '* ' . $dao->title, 'visibility' => $dao->visibility, 'description' => $dao->description, - 'icon' => empty($dao->saved_search_id) ? NULL : 'fa-lightbulb-o', ]; } } @@ -1119,8 +1117,7 @@ WHERE id IN $groupIdString $spaces = str_repeat($spacer, $level); if ($titleOnly) { - $icon = $group['icon'] ? '* ' : ''; - $hierarchy[$group['id']] = $icon . $spaces . $group['title']; + $hierarchy[$group['id']] = $spaces . $group['title']; } else { $hierarchy[] = array( @@ -1128,7 +1125,6 @@ WHERE id IN $groupIdString 'text' => $spaces . $group['title'], 'description' => $group['description'], 'visibility' => $group['visibility'], - 'icon' => $group['icon'], ); } diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index 3a1d69fc16..eaf910f265 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -869,8 +869,9 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $params['preferred_communication_method'] = 'null'; } - $group = $params['group'] ?? NULL; - if (!empty($group) && is_array($group)) { + $group = CRM_Utils_Array::value('group', $params); + if (!empty($group)) { + $group = is_array($group) ? $group : explode(',', $group); unset($params['group']); foreach ($group as $key => $value) { $params['group'][$value] = 1; diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 87a516af33..c9a822e66f 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -45,7 +45,7 @@ class CRM_Contact_Form_Search_Criteria { $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '  '); $form->add('select2', 'group', ts('Groups'), $groupHierarchy, FALSE, - ['placeholder' => '- select -', 'multiple' => TRUE, 'class' => 'twenty'] + ['placeholder' => ts('- select -'), 'multiple' => TRUE, 'class' => 'twenty'] ); $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type'); $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, diff --git a/ang/crmMailing/Recipients.js b/ang/crmMailing/Recipients.js index 6ff799f6a5..1867e9582f 100644 --- a/ang/crmMailing/Recipients.js +++ b/ang/crmMailing/Recipients.js @@ -94,12 +94,13 @@ return item.text; } var option = convertValueToObj(item.id); - var icon = (option.entity_type === 'civicrm_mailing') ? 'fa-envelope' : item.is_smart ? 'fa-lightbulb-o' : 'fa-users'; + var icon = (option.entity_type === 'civicrm_mailing') ? 'fa-envelope' : 'fa-users'; + var smartGroupMarker = item.is_smart ? '* ' : ''; var spanClass = (option.mode == 'exclude') ? 'crmMailing-exclude' : 'crmMailing-include'; if (option.entity_type != 'civicrm_mailing' && isMandatory(option.entity_id)) { spanClass = 'crmMailing-mandatory'; } - return ' ' + item.text + ''; + return ' ' + smartGroupMarker + item.text + ''; } function validate() { @@ -233,13 +234,16 @@ if('civicrm_mailing' === rcpAjaxState.entity) { params["api.MailingRecipients.getcount"] = {}; } + else if ('civicrm_group' === rcpAjaxState.entity) { + params.extra = ["saved_search_id"]; + } return params; }, transport: function(params) { switch(rcpAjaxState.entity) { case 'civicrm_group': - CRM.api3('Group', 'get', params.data).then(params.success, params.error); + CRM.api3('Group', 'getlist', params.data).then(params.success, params.error); break; case 'civicrm_mailing': @@ -255,8 +259,9 @@ return obj["api.MailingRecipients.getcount"] > 0 ? { 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)) }; + else { + return { id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, text: obj.label, + is_smart: (!_.isEmpty(obj.extra.saved_search_id)) }; } }) }; -- 2.25.1