From c6ff5b0de988c482974736fbefa5aac465886525 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Sat, 20 Jul 2013 02:30:20 +0530 Subject: [PATCH] fixes notes display for search builder CRM-11790 --- CRM/Contact/BAO/Query.php | 19 +++++++++++++++---- CRM/Contact/Selector.php | 7 +++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 63f2fb31be..9db32208ff 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -578,12 +578,10 @@ class CRM_Contact_BAO_Query { * @access public */ function selectClause() { - $properties = array(); $this->addSpecialFields(); foreach ($this->_fields as $name => $field) { - // skip component fields // there are done by the alter query below // and need not be done on every field @@ -607,14 +605,27 @@ class CRM_Contact_BAO_Query { continue; } - //special handling for groups/tags + // make an exception for special cases, to add the field in select clause $makeException = FALSE; - if (in_array($name, array('groups', 'tags')) + + //special handling for groups/tags + if (in_array($name, array('groups', 'tags', 'notes')) && isset($this->_returnProperties[substr($name, 0, -1)]) ) { $makeException = TRUE; } + // since note has 3 different options we need special handling + // note / note_subject / note_body + if ($name == 'notes') { + foreach (array('note', 'note_subject', 'note_body') as $noteField) { + if (isset($this->_returnProperties[$noteField])) { + $makeException = TRUE; + break; + } + } + } + $cfID = CRM_Core_BAO_CustomField::getKeyID($name); if ( CRM_Utils_Array::value($name, $this->_paramLookup) || diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 14261fe63c..4b82633447 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -1073,9 +1073,16 @@ SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.dis $properties = array(); foreach ($returnProperties as $name => $value) { if ($name != 'location') { + // special handling for group and tag if (in_array($name, array('group', 'tag'))) { $name = "{$name}s"; } + + // special handling for notes + if (in_array($name, array('note', 'note_subject', 'note_body'))) { + $name = "notes"; + } + $properties[] = $name; } else { -- 2.25.1