$groups = self::group($type, $contactID, $tableName, $allGroups, $includedGroups);
$cache[$key] = $groups;
}
+ if (empty($groups)) {
+ return FALSE;
+ }
return in_array($groupID, $groups) ? TRUE : FALSE;
}
$groupNames = civicrm_api3('Group', 'get', $params + array(
'is_active' => 1,
+ 'check_permissions' => TRUE,
'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
));
$headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array(
*/
function civicrm_api3_group_get($params) {
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'Group', 'get');
- if (empty($options['return']) || !in_array('member_count', $options['return'])) {
+ if ((empty($options['return']) || !in_array('member_count', $options['return'])) && empty($params['check_permissions'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group');
}
$groups = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Group');
foreach ($groups as $id => $group) {
- $groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id);
+ if(!empty($params['check_permissions']) && !CRM_Contact_BAO_Group::checkPermission($group['id'])) {
+ unset($groups[$id]);
+ }
+ elseif (!empty($options['return']) && in_array('member_count', $options['return'])) {
+ $groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id);
+ }
}
return civicrm_api3_create_success($groups, $params, 'Group', 'get');
}