Commit dee423e5 authored by Michael McAndrew's avatar Michael McAndrew

founding partners now recognised

parent 094ed084
......@@ -5,7 +5,6 @@
//The reason we do this is because we need something we can add to a view, since it (IMHO) is impossible to do the view calculation in the view itself
function civicrm_providers_civicrm_post($op, $objectName, $objectId, $ObjectRef){
if(!in_array($op, array('edit', 'create', 'delete'))){
return;
......@@ -37,18 +36,29 @@ function civicrm_providers_update_provider($contact_id){
//find out if they are in the active contributors group. NOTE: this criteria is likely to change as we get more sophisticated about how we classify active contributors
$params = array('version' => 3, 'contact_id' => $contact_id);
$groups=civicrm_api('GroupContact', 'get', $params);
foreach($groups['values'] as $group){
if($group['group_id']==140){
$founder = true;
break;
}
}
$params = array('version' => 3, 'contact_id' => $contact_id);
$groups=civicrm_api('GroupContact', 'get', $params);
foreach($groups['values'] as $group){
if($group['group_id']==131){
$badges[]='active-contributor';
break;
}
}
//find out if they members and what type of members they are
$params = array('version' => 3, 'contact_id' => $contact_id);
$membership=civicrm_api('Membership', 'getsingle', $params);
if(in_array($membership['status_id'], array(1,2,3,5))){
$badges[]=str_replace(' ', '-', strtolower($membership['membership_name'])); //1=new, 2=current, 3=grace, 5=pending
if(in_array($membership['status_id'], array(1,2,3,5))){ //1=new, 2=current, 3=grace, 5=pending
$partnerText = str_replace(' ', '-', strtolower($membership['membership_name']));
if($founder){
$partnerText = 'founding-'.$partnerText;
}
$badges[]=$partnerText;
}
$updateParams = array('version' => 3, 'contact_id' => $contact_id, 'custom_160' => json_encode($badges));
$result=civicrm_api('contact', 'update', $updateParams);
......
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