Compare commits

..

2 Commits

Author SHA1 Message Date
08b5349b23 fixed identation and styling 2018-08-30 20:34:04 +01:00
f43482e49b fix for profile search 2018-08-30 20:29:06 +01:00
3 changed files with 50 additions and 37 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

@ -8,39 +8,86 @@ class CRM_ConstituentsOnly_BAO_Query extends CRM_Contact_BAO_Query_Interface {
return self::$_networkFields; return self::$_networkFields;
} }
/**
* @param $query
*
*/
public function select(&$query) { 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,
];
}
} }
/** /**
* Build where clause for ConstituentsOnly * @param $query
* *
* @return void
* @access public
*/ */
public function where(&$query) { public function where(&$query) {
if (empty($query->_paramLookup['entryURL'])) { if (empty($query->_paramLookup['entryURL'])) {
return; return;
} }
if (CRM_Utils_Array::value('civicrm_contact', $query->_tables)) { 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)"; $query->_where[0][] = "( contact_a.do_not_trade IS NULL OR contact_a.do_not_trade = 0)";
} }
} }
/**
* @param string $name
* @param $mode
* @param $side
*
*/
public function from($name, $mode, $side) { public function from($name, $mode, $side) {
} }
/**
* @param $tables
*
*/
public function setTableDependency(&$tables) { public function setTableDependency(&$tables) {
} }
public function getPanesMapper(&$panes) { public function getPanesMapper(&$panes) {
} }
/**
* @param $panes
*
*/
public function registerAdvancedSearchPane(&$panes) { public function registerAdvancedSearchPane(&$panes) {
} }
/**
* @param CRM_Core_Form $form
* @param $type
*
*/
public function buildAdvancedSearchPaneForm(&$form, $type) { public function buildAdvancedSearchPaneForm(&$form, $type) {
} }
/**
* @param $paneTemplatePathArray
* @param $type
*
*/
public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type) { public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type) {
} }

View File

@ -134,17 +134,6 @@ function constituentsonly_civicrm_queryObjects(&$queryObjects, $type) {
} }
} }
/**
* Implements hook_civicrm_apiWrappers().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_apiWrappers
*/
function constituentsonly_civicrm_apiWrappers(&$wrappers, $apiRequest) {
if ($apiRequest['entity'] == 'Contact' && strtolower($apiRequest['action']) == 'getlist') {
$wrappers[] = new CRM_ConstituentsOnly_BAO_APIWrapper();
}
}
/** /**
* Implements hook_civicrm_contactListQuery(). * Implements hook_civicrm_contactListQuery().
* *