more changes to code

This commit is contained in:
CiviWare Solutions 2018-09-28 15:39:28 +01:00
parent e3e27bbcb6
commit 9fdb1ac12b
2 changed files with 24 additions and 3 deletions

View File

@ -66,7 +66,7 @@ class CRM_ConstituentsOnly_BAO_ConstituentsOnly {
* @param string $query
*
*/
public static function updateSearchRows($rows) {
public static function updateSearchRows($rows, $headers) {
$contactIds = array_keys($rows);
$sql = "SELECT MAX(contact_a.id) AS contact_id, cc.id AS og_contact_id
FROM civicrm_contact contact_a
@ -91,11 +91,32 @@ class CRM_ConstituentsOnly_BAO_ConstituentsOnly {
if (!empty($relContactIds)) {
$formValues = ['contact_id' => $relContactIds];
$url = CRM_Utils_Array::value('q', $_GET);
$returnProperties = NULL;
$request = $_REQUEST;
if (!empty($_REQUEST['has_js'])) {
$qfKey = $_REQUEST['qfKey'];
$formValuesFromSession = CRM_Core_Session::singleton()->get("CRM_Contact_Controller_Search_{$qfKey}");
if (!empty($formValuesFromSession['formValues'])) {
$request = $formValuesFromSession['formValues'];
}
}
if (in_array($url, ['civicrm/contact/search/builder']) || !empty($request['uf_group_id'])) {
foreach ($headers as $header) {
if (!empty($header['sort'])) {
$returnProperties[$header['sort']] = 1;
}
}
$returnProperties['contact_sub_type'] = 1;
$returnProperties['contact_type'] = 1;
}
$queryParams = CRM_Contact_BAO_Query::convertFormValues($formValues);
$selector = new CRM_Contact_Selector(
'',
$queryParams,
$queryParams
$queryParams,
$returnProperties
);
list($select, $from, $where, $having) = $selector->getQuery()->query();
$newRows = $selector->getRows('', '', '', '');

View File

@ -165,6 +165,6 @@ function constituentsonly_civicrm_selectWhereClause($entity, &$clauses) {
*/
function constituentsonly_civicrm_searchColumns($objectName, &$headers, &$rows, &$selector) {
if (in_array($objectName, ['contact']) && !empty($rows)) {
$rows = CRM_ConstituentsOnly_BAO_ConstituentsOnly::updateSearchRows($rows);
$rows = CRM_ConstituentsOnly_BAO_ConstituentsOnly::updateSearchRows($rows, $headers);
}
}