From: Edsel Date: Tue, 16 Feb 2016 14:12:41 +0000 (+0530) Subject: CRM-16526 CIVI-3 Added restriction for retrieving lineitems X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2344a42b4c00af8ae63bd942276865fe77df816e;p=civicrm-core.git CRM-16526 CIVI-3 Added restriction for retrieving lineitems ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526 --- diff --git a/api/v3/LineItem.php b/api/v3/LineItem.php index 463aab2b88..6b9494d140 100644 --- a/api/v3/LineItem.php +++ b/api/v3/LineItem.php @@ -95,6 +95,18 @@ function _civicrm_api3_line_item_create_spec(&$params) { * Array of matching line_items */ function civicrm_api3_line_item_get($params) { + if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types); + $lineItems = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); + if ($lineItems['count'] > 0) { + foreach ($lineItems['values'] as $key => $items) { + if (!in_array($items['financial_type_id'], array_keys($types))) { + unset($lineItems['values'][$key]); + } + } + return $lineItems; + } + } return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); }