Commit 9f798484 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

civicrm_org_providers_block_view: fix for when a partner has expired memberships.

parent 254abd73
......@@ -146,30 +146,35 @@ function civicrm_org_providers_block_view($block_name) {
$showLink = FALSE;
try {
$memStatus = civicrm_api3('Membership', 'getvalue', [
// A contact might have expired memberships
$mem_result = civicrm_api3('Membership', 'get', [
'sequential' => 1,
'contact_id' => $rel['contact_id_b'],
'membership_type_id' => [
'NOT IN' => [23,24,25], // Exclude Spark
],
'return' => 'status_id',
'sequential' => 1,
]);
// If org has membership (new, current, grace, or pending) show link. Else check if in active contributor group (gid=131)
if (in_array($memStatus, $validStatuses)) {
$showLink = TRUE;
} else {
$groupParams = array(
'version' => 3,
'sequential' => 1,
'contact_id' => $rel['contact_id_b'],
);
$groups = civicrm_api('GroupContact', 'get', $groupParams);
foreach($groups['values'] as $dontCare => $group){
if ($group['group_id'] == '487') {
$showLink = TRUE;
}
}
foreach ($mem_result['values'] as $key => $mem) {
if (in_array($mem['status_id'], $validStatuses)) {
$showLink = TRUE;
}
else {
$groupParams = array(
'version' => 3,
'sequential' => 1,
'contact_id' => $rel['contact_id_b'],
);
$groups = civicrm_api('GroupContact', 'get', $groupParams);
foreach($groups['values'] as $dontCare => $group){
if ($group['group_id'] == '487') {
$showLink = TRUE;
}
}
}
}
if ($showLink) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment