// check for both id and contact_id
if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
$this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
+ $field = CRM_Utils_Array::value('id', $this->_fields);
+ list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(
+ 'CRM_Contact_BAO_Contact',
+ "contact_a.id",
+ $this->_params[$id][2],
+ $this->_params[$id][1]
+ );
+ $this->_qill[0][] = ts("%1 %2 %3", [
+ 1 => $field['title'],
+ 2 => $qillop,
+ 3 => $qillVal
+ ]);
}
else {
$this->whereClauseSingle($this->_params[$id], $apiEntity);
$name = $targetName[4] ? "%$name%" : $name;
$this->_where[$grouping][] = "contact_b_log.sort_name LIKE '%$name%'";
$this->_tables['civicrm_log'] = $this->_whereTables['civicrm_log'] = 1;
- $this->_qill[$grouping][] = ts('Modified By') . " $name";
+ $fieldTitle = ts('Added By');
+ foreach ($this->_params as $params) {
+ if ($params[0] == 'log_date') {
+ if ($params[2] == 2) {
+ $fieldTitle = ts('Modified By');
+ }
+ break;
+ }
+ }
+ list($qillop, $qillVal) = self::buildQillForFieldValue(NULL, 'changed_by', $name, 'LIKE');
+ $this->_qill[$grouping][] = ts("%1 %2 %3", [
+ 1 => $fieldTitle,
+ 2 => $qillop,
+ 3 => $qillVal,
+ ]);
}
/**
// MySQL expect the columns present in GROUP BY, must be present in SELECT clause and that results into error, needless to have other columns.
// 2. When GROUP BY columns are present then disable FGB otherwise it demands to add ORDER BY columns in GROUP BY and eventually in SELECT
// clause. This will impact the search query output.
- $disableFullGroupByMode = ($sortByChar || !empty($groupByCols));
+ $disableFullGroupByMode = ($sortByChar || !empty($groupByCols) || $groupContacts);
if ($disableFullGroupByMode) {
CRM_Core_DAO::disableFullGroupByMode();
$select .= sprintf(", (%s) AS _wgt", $this->createSqlCase('contact_a.id', $cids));
$where .= sprintf(' AND contact_a.id IN (%s)', implode(',', $cids));
$order = 'ORDER BY _wgt';
- $groupBy = '';
+ $groupBy = $this->_useGroupBy ? ' GROUP BY contact_a.id' : '';
$limit = '';
$query = "$select $from $where $groupBy $order $limit";