From 23f6cae28f26255de76a08c96b05494336479d85 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Mon, 3 Aug 2015 12:16:50 +0530 Subject: [PATCH] check for permission if specified in params --- CRM/Mailing/Info.php | 1 + api/v3/Group.php | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index 1905d16ed0..b38946c9df 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -117,6 +117,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { $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( diff --git a/api/v3/Group.php b/api/v3/Group.php index a44076ddeb..9326dd2cf4 100644 --- a/api/v3/Group.php +++ b/api/v3/Group.php @@ -71,17 +71,19 @@ function _civicrm_api3_group_create_spec(&$params) { */ 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'])) && 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) { - $permission = CRM_Contact_BAO_Group::checkPermission($group['id']); - if (!$permission) { + 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); } } - $groups = array_values($groups); return civicrm_api3_create_success($groups, $params, 'Group', 'get'); } -- 2.25.1