}
/**
- * @inheritDoc
- */
- public function addSelectWhereClause() {
- $whereClauses = parent::addSelectWhereClause();
- if ($whereClauses !== []) {
- // In this case permisssions have been applied & we assume the
- // financialaclreport is applying these
- // https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport/blob/master/financialaclreport.php#L107
- return $whereClauses;
- }
-
- if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
- return $whereClauses;
- }
- $types = CRM_Financial_BAO_FinancialType::getAllEnabledAvailableFinancialTypes();
- if (empty($types)) {
- $whereClauses['financial_type_id'] = 'IN (0)';
- }
- else {
- $whereClauses['financial_type_id'] = [
- 'IN (' . implode(',', array_keys($types)) . ')',
- ];
- }
- return $whereClauses;
- }
-
- /**
- * @param null $status
+ * @param string $status
* @param null $startDate
* @param null $endDate
*
return '';
}
if ($component === 'contribution') {
- $types = array_keys(self::getAllEnabledAvailableFinancialTypes());
- if (empty($types)) {
- $types = [0];
- }
- $clauses[] = ' civicrm_contribution.financial_type_id IN (' . implode(',', $types) . ')';
+ $clauses = CRM_Contribute_BAO_Contribution::getSelectWhereClause();
}
if ($component === 'membership') {
self::getAvailableMembershipTypes($types, CRM_Core_Action::VIEW);
case 'LineItem':
case 'MembershipType':
case 'ContributionRecur':
+ case 'Contribution':
$clauses['financial_type_id'] = _financialacls_civicrm_get_type_clause();
break;
'view contributions of type Member Dues',
]);
$whereClause = \CRM_Financial_BAO_FinancialType::buildPermissionedClause('contribution');
- $this->assertEquals(' civicrm_contribution.financial_type_id IN (1,2)', $whereClause);
+ $this->assertEquals('(`civicrm_contribution`.`financial_type_id` IS NULL OR (`civicrm_contribution`.`financial_type_id` IN (1,2)))', $whereClause);
$this->setPermissions([
'view contributions of type Donation',
'view contributions of type Member Dues',
]);
$whereClause = \CRM_Financial_BAO_FinancialType::buildPermissionedClause('contribution');
- $this->assertEquals(' civicrm_contribution.financial_type_id IN (1,4,2)', $whereClause);
+ $this->assertEquals('(`civicrm_contribution`.`financial_type_id` IS NULL OR (`civicrm_contribution`.`financial_type_id` IN (1,4,2)))', $whereClause);
}
}
$this->assertEquals($perm, TRUE, 'Verify that lineitems now have permission.');
}
- /**
- * Check method testisACLFinancialTypeStatus()
- */
- public function testBuildPermissionedClause() {
- $this->setACL();
- $this->setPermissions([
- 'view contributions of type Donation',
- 'view contributions of type Member Dues',
- ]);
- CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
- $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,2)');
- $this->setPermissions([
- 'view contributions of type Donation',
- 'view contributions of type Member Dues',
- 'view contributions of type Event Fee',
- ]);
- $whereClause = NULL;
-
- CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
- $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,4,2)');
- }
-
}