CRM-16526 CIVI-3 Modified get lineitem permissioning
authorEdsel <edsel.lopez@jmaconsulting.biz>
Fri, 19 Feb 2016 12:09:35 +0000 (17:39 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 22 Feb 2016 18:11:39 +0000 (23:41 +0530)
----------------------------------------
* CRM-16526: ACLs for Financial Types
  https://issues.civicrm.org/jira/browse/CRM-16526

api/v3/LineItem.php

index 764e0f93b79d845132fc286a2a5ba2b93472c9ec..d9a503504e47d254cd183474a73fdcdeda375d72 100644 (file)
@@ -78,7 +78,18 @@ function _civicrm_api3_line_item_create_spec(&$params) {
 function civicrm_api3_line_item_get($params) {
   if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
     CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types);
-    $params['financial_type_id'] = array('IN' => array_keys($types));
+    if (empty($params['financial_type_id'])) {
+      $params['financial_type_id'] = array('IN' => array_keys($types));
+    }
+    else {
+      if (is_array($params['financial_type_id'])) {
+        $invalidFts = array_diff($params['financial_type_id'], array_keys($types));
+      }
+      elseif (!in_array($params['financial_type_id'], array_keys($types))) {
+        $invalidFts = $params['financial_type_id'];
+      }
+      $params['financial_type_id'] = array('NOT IN' => $invalidFts);
+    }
   }
   return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }