Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show disabled membership types on contact tab #19431

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1575,11 +1575,15 @@ public static function buildMembershipTypeValues($form, $membershipTypeID = [],
* @return null|string
*/
public static function getContactMembershipCount($contactID, $activeOnly = FALSE) {
CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
$membershipTypes = \Civi\Api4\MembershipType::get(TRUE)
mattwire marked this conversation as resolved.
Show resolved Hide resolved
->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 ";

Expand Down
5 changes: 4 additions & 1 deletion CRM/Member/Page/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class CRM_Member_Page_Tab extends CRM_Core_Page {
*/
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)) . ")";
Expand Down
23 changes: 14 additions & 9 deletions ext/financialacls/financialacls.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,20 @@ function financialacls_civicrm_selectWhereClause($entity, &$clauses) {
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;

}

}
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/api/v3/FinancialTypeACLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,13 @@ public function testDeleteACLContribution() {
$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',
Expand Down