* @return null|string
*/
public static function getContactMembershipCount($contactID, $activeOnly = FALSE) {
+ CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
+ $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 ";
$where .= " and civicrm_membership_status.is_current_member = 1";
}
- $query = $select . $where;
+ $query = $select . $where . $addWhere;
return CRM_Core_DAO::singleValueQuery($query);
}
* called when action is browse.
*/
public function browse() {
+ $links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
+ CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
+ $addWhere = "membership_type_id IN (0)";
+ if (!empty($membershipTypes)) {
+ $addWhere = "membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")";
+ }
+
$membership = [];
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
+ $dao->whereAdd($addWhere);
$dao->find();
//CRM--4418, check for view, edit, delete
$this->assertEquals($contribution['count'], 1);
}
+ public function testMembersipTypeACLFinancialTypeACL() {
+ $contactID = $this->individualCreate();
+ $this->contactMembershipCreate(['contact_id' => $contactID]);
+ $this->enableFinancialACLs();
+ $this->setPermissions([
+ 'access CiviCRM',
+ 'access CiviContribute',
+ 'view all contacts',
+ 'add contributions of type Donation',
+ 'view contributions of type Donation',
+ ]);
+ $this->assertEquals(0, CRM_Member_BAO_Membership::getContactMembershipCount($contactID));
+ $this->addFinancialAclPermissions([['view', 'Member Dues']]);
+ $this->assertEquals(1, CRM_Member_BAO_Membership::getContactMembershipCount($contactID));
+ }
+
}