From: jitendrapurohit Date: Mon, 3 Aug 2015 06:46:50 +0000 (+0530) Subject: check for permission if specified in params X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=23f6cae28f26255de76a08c96b05494336479d85;p=civicrm-core.git check for permission if specified in params --- 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'); }