* @return null|string
*/
public static function getContactMembershipCount($contactID, $activeOnly = FALSE) {
- CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
+ $membershipTypes = \Civi\Api4\MembershipType::get(TRUE)
+ ->execute()
+ ->indexBy('id')
+ ->column('name');
$addWhere = " AND membership_type_id IN (0)";
if (!empty($membershipTypes)) {
$addWhere = " AND membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")";
}
+
$select = "SELECT count(*) FROM civicrm_membership ";
$where = "WHERE civicrm_membership.contact_id = {$contactID} AND civicrm_membership.is_test = 0 ";
*/
public function browse() {
$links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
- CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
+ $membershipTypes = \Civi\Api4\MembershipType::get(TRUE)
+ ->execute()
+ ->indexBy('id')
+ ->column('name');
$addWhere = "membership_type_id IN (0)";
if (!empty($membershipTypes)) {
$addWhere = "membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")";
if (!financialacls_is_acl_limiting_enabled()) {
return;
}
- if ($entity === 'LineItem') {
- $types = [];
- CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types);
- if ($types) {
- $clauses['financial_type_id'] = 'IN (' . implode(',', array_keys($types)) . ')';
- }
- else {
- $clauses['financial_type_id'] = '= 0';
- }
+
+ switch ($entity) {
+ case 'LineItem':
+ case 'MembershipType':
+ $types = [];
+ CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types);
+ if ($types) {
+ $clauses['financial_type_id'] = 'IN (' . implode(',', array_keys($types)) . ')';
+ }
+ else {
+ $clauses['financial_type_id'] = '= 0';
+ }
+ break;
+
}
}
$this->assertEquals($contribution['count'], 1);
}
- public function testMembersipTypeACLFinancialTypeACL() {
+ public function testMembershipTypeACLFinancialTypeACL() {
$contactID = $this->individualCreate();
$this->contactMembershipCreate(['contact_id' => $contactID]);
$this->enableFinancialACLs();
$this->setPermissions([
'access CiviCRM',
+ 'access CiviMember',
'access CiviContribute',
'view all contacts',
'add contributions of type Donation',