fix for profile search

This commit is contained in:
2018-08-30 20:29:06 +01:00
parent 8abfaebb4c
commit f43482e49b
3 changed files with 21 additions and 34 deletions

View File

@ -1,23 +0,0 @@
<?php
class CRM_ConstituentsOnly_BAO_APIWrapper implements API_Wrapper {
/**
* the wrapper contains a method that allows you to alter the parameters of the api request (including the action and the entity)
*/
public function fromApiInput($apiRequest) {
$params = &$apiRequest['params'];
if (!array_key_exists('do_not_trade', $params['params'])) {
$params['params']['do_not_trade'] = '0 AND (contact_a.do_not_trade IS NULL OR contact_a.do_not_trade = 0)';
}
return $apiRequest;
}
/**
* alter the result before returning it to the caller.
*/
public function toApiOutput($apiRequest, $result) {
return $result;
}
}

View File

@ -9,6 +9,26 @@ class CRM_ConstituentsOnly_BAO_Query extends CRM_Contact_BAO_Query_Interface {
}
public function select(&$query) {
// hack for profile search
$url = CRM_Utils_Array::value('q', $_GET);
if ($url == 'civicrm/profile') {
if (empty($query->_params)) {
$query->_params[] = [
'entryURL',
'=',
0,
0,
1,
];
}
$query->_paramLookup['entryURL'] = [
'entryURL',
'=',
0,
0,
1,
];
}
}
/**
@ -21,6 +41,7 @@ class CRM_ConstituentsOnly_BAO_Query extends CRM_Contact_BAO_Query_Interface {
if (empty($query->_paramLookup['entryURL'])) {
return;
}
if (CRM_Utils_Array::value('civicrm_contact', $query->_tables)) {
$query->_where[0][] = "( contact_a.do_not_trade IS NULL OR contact_a.do_not_trade = 0)";
}