<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
/**
- * This api exposes CiviCRM groups.
+ * This api exposes CiviCRM Groups.
*
* This api is for creating/deleting groups or fetching a list of existing groups.
- * To add/remove contacts to a group, use the groupContact api instead.
+ * To add/remove contacts to a group, use the GroupContact api instead.
*
* @package CiviCRM_APIv3
*/
* Create/update group.
*
* @param array $params
- * name/value pairs to insert in new 'group'
+ * name/value pairs to insert in new 'Group'
*
* @return array
* API result array
}
/**
- * Returns array of groups matching a set of one or more group properties.
+ * Returns array of groups matching a set of one or more Group properties.
*
* @param array $params
* Array of properties. If empty, all records will be returned.
* Array of matching groups
*/
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'])) {
+ $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) {
- $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');
+ return civicrm_api3_create_success($groups, $params, 'Group', 'get');
}
/**
- * Delete an existing group.
+ * Delete an existing Group.
*
* @param array $params
* [id]