CRM-16526 CIVI-3 Added restriction for retrieving lineitems
authorEdsel <edsel.lopez@jmaconsulting.biz>
Tue, 16 Feb 2016 14:12:41 +0000 (19:42 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 22 Feb 2016 18:11:38 +0000 (23:41 +0530)
----------------------------------------
* CRM-16526: ACLs for Financial Types
  https://issues.civicrm.org/jira/browse/CRM-16526

api/v3/LineItem.php

index 463aab2b8888e32463ed8ebf25619033a48a4fc9..6b9494d14066e0f3931b1b0b710dc4502d5f4379 100644 (file)
@@ -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);
 }