Commit 2116164b authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

Fix 'edit partner listing' link for partners who are also spark users

parent 7511dd4b
......@@ -124,34 +124,37 @@ function civicrm_org_providers_block_info() {
}
function civicrm_org_providers_block_view($block_name) {
switch($block_name){
switch($block_name) {
case 'update_links':
civicrm_initialize();
$session = CRM_Core_Session::singleton();
$myContactID = $session->get('userID');
$validStatuses = array("1","2","3","5");
$params = array(
'version' => 3,
$result = civicrm_api3('Relationship', 'get', [
'sequential' => 1,
'is_permission_a_b' => 1,
'contact_id_a' => $myContactID,
'relationship_type_id' => 4,
'is_active' => 1,
);
$result = civicrm_api('Relationship', 'get', $params);
]);
$thereAreLinks = FALSE;
foreach($result['values'] as $dontCare => $rel){
$showLink = FALSE;
$memParams = array(
'version' => 3,
'sequential' => 1,
'contact_id' => $rel['contact_id_b'],
'return' => 'status_id',
);
$memStatus = civicrm_api('Membership', 'getvalue', $memParams);
// var_dump($memStatus);
foreach ($result['values'] as $dontCare => $rel) {
$showLink = FALSE;
try {
$memStatus = civicrm_api3('Membership', 'getvalue', [
'sequential' => 1,
'contact_id' => $rel['contact_id_b'],
'membership_type_id' => [
'NOT IN' => [23,24,25], // Exclude Spark
],
'return' => 'status_id',
]);
// 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;
......@@ -182,6 +185,10 @@ function civicrm_org_providers_block_view($block_name) {
$pLink = CRM_Utils_System::url("civicrm/profile/edit", "gid=48&reset=1&id={$rel['contact_id_b']}");
$content .= '<div class="bold"><a href="' . $pLink . '">Edit listing for ' . $pName . '</a></li></div>';
}
}
catch (Exception $e) {
drupal_set_message("[civicrm_org_providers] Error fetching membership information: " . $e->getMessage(), 'error');
}
}
if(!$thereAreLinks){
return;
......@@ -192,7 +199,7 @@ function civicrm_org_providers_block_view($block_name) {
'content' => $content
);
return $output;
}
}
}
function civicrm_org_providers_batch_update($contact_ids=array()) {
......
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