From 8ac621f5ce8c13f8813b310a508f041d755cb8b5 Mon Sep 17 00:00:00 2001 From: Civiware Solutions Date: Thu, 30 Aug 2018 16:33:22 +0100 Subject: [PATCH] Fixed report to retrieve only contacts with donot trade = 0 --- constituentsonly.php | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) 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'; } }