diff --git a/constituentsonly.php b/constituentsonly.php index 281f812..d77cd31 100644 --- a/constituentsonly.php +++ b/constituentsonly.php @@ -146,33 +146,12 @@ function constituentsonly_civicrm_apiWrappers(&$wrappers, $apiRequest) { } /** - * Implements hook_civicrm_alterReportVar(). + * Implements hook_civicrm_selectWhereClause(). * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterReportVar + * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_selectWhereClause */ -function constituentsonly_civicrm_alterReportVar($varType, &$var, &$object) { - $instanceValue = $object->getVar('_instanceValues'); - if (!empty($instanceValue) && - in_array( - $instanceValue['report_id'], - array( - 'contact/summary', - 'contact/detail', - 'contact/currentEmployer', - ) - ) - ) { - if ($varType == 'sql') { - $var->_columnHeaders['civicrm_contact_do_not_trade'] = array( - 'type' => 1, - 'title' => 'Constituent', - 'no_display' => TRUE, - ); - $var->_select .= ' , contact_civireport.do_not_trade as civicrm_contact_do_not_trade '; - - $where = $var->getVar('_where'); - $where .= ' AND contact_civireport.do_not_trade <> 1'; - $var->setVar('_where', $where); - } +function constituentsonly_civicrm_selectWhereClause($entity, &$clauses) { + if ($entity == 'Contact') { + $clauses['do_not_trade'] = ' = 0'; } }