Commit 45656722 authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

#79 Fix partner badge update to avoid Spark conflict,...

#79 Fix partner badge update to avoid Spark conflict, other code cleanup, throw exception to detect errors.
parent 95cfaaa6
...@@ -79,13 +79,14 @@ function civicrm_org_providers_update_provider($contact_id) { ...@@ -79,13 +79,14 @@ function civicrm_org_providers_update_provider($contact_id) {
// } // }
// } // }
// Find out if they members and what type of members they are // Find out if they are members and what type of members they are
// Ignore the Spark membership types (23, 24, 25) // Ignore the Spark membership types (23, 24, 25)
$memberships = CRM_Core_DAO::executeQuery("SELECT id FROM civicrm_membership WHERE contact_id = %1 AND membership_type_id NOT IN (23,24,25) ORDER BY start_date DESC LIMIT 1", array(1 => array($contact_id, 'Integer'))); $memberships = CRM_Core_DAO::executeQuery("SELECT id FROM civicrm_membership WHERE contact_id = %1 AND membership_type_id NOT IN (23,24,25) ORDER BY start_date DESC LIMIT 1", array(1 => array($contact_id, 'Integer')));
$memberships->fetch(); $memberships->fetch();
$params = array('version' => 3, 'membership_id' => $memberships->id); $membership = civicrm_api3('Membership', 'getsingle', [
$membership=civicrm_api('Membership', 'getsingle', $params); 'membership_id' => $memberships->id,
]);
$membershipTypeBadgeTranslate = [ $membershipTypeBadgeTranslate = [
1 => 'partner-supporting', 1 => 'partner-supporting',
...@@ -109,10 +110,9 @@ function civicrm_org_providers_update_provider($contact_id) { ...@@ -109,10 +110,9 @@ function civicrm_org_providers_update_provider($contact_id) {
} }
$updateParams = array('version' => 3, 'contact_id' => $contact_id, 'custom_160' => json_encode($badges)); $updateParams = array('version' => 3, 'contact_id' => $contact_id, 'custom_160' => json_encode($badges));
$result = civicrm_api('contact', 'update', $updateParams); $result = civicrm_api3('contact', 'update', $updateParams);
$result = civicrm_api('involvement', 'update', array('contact_id' => $contact_id, 'version' => 3));
return; $result = civicrm_api('involvement', 'update', array('contact_id' => $contact_id, 'version' => 3));
} }
function civicrm_org_providers_block_info() { function civicrm_org_providers_block_info() {
......
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