Skip to content

Commit

Permalink
user group.getlist api
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Feb 7, 2020
1 parent 64bf59b commit 36bbaba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
10 changes: 3 additions & 7 deletions CRM/Contact/BAO/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,19 +1078,17 @@ public static function getGroupsHierarchy(
$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',
];
}
}
Expand Down Expand Up @@ -1119,16 +1117,14 @@ private static function buildGroupHierarchy(&$hierarchy, $group, $tree, $titleOn
$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(
'id' => $group['id'],
'text' => $spaces . $group['title'],
'description' => $group['description'],
'visibility' => $group['visibility'],
'icon' => $group['icon'],
);
}

Expand Down
3 changes: 2 additions & 1 deletion CRM/Contact/Form/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,8 @@ public function postProcess() {
}

$group = CRM_Utils_Array::value('group', $params);
if (!empty($group) && is_array($group)) {
if (!empty($group)) {
$group = is_array($group) ? $group : explode(',', $group);
unset($params['group']);
foreach ($group as $key => $value) {
$params['group'][$value] = 1;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Search/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function basic(&$form) {
$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,
Expand Down
15 changes: 10 additions & 5 deletions ang/crmMailing/Recipients.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<i class="crm-i '+icon+'"></i> <span class="' + spanClass + '">' + item.text + '</span>';
return '<i class="crm-i '+icon+'"></i> <span class="' + spanClass + '">' + smartGroupMarker + item.text + '</span>';
}

function validate() {
Expand Down Expand Up @@ -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':
Expand All @@ -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)) };
}
})
};
Expand Down

0 comments on commit 36bbaba

Please sign in to comment.