/** * Given a list of conditions in query generate the required where clause. * * @param CRM_Contact_BAO_Query $query */ public static function where(&$query) { foreach ($query->_params as $id => $values) { if (!is_array($values) || count($values) != 5) { continue; } if (substr($query->_params[$id][0], 0, 5) == 'case_') { if ($query->_mode == CRM_Contact_BAO_Query::MODE_CONTACTS) { $query->_useDistinct = TRUE; } self::whereClauseSingle($query->_params[$id], $query); } } // Add acl clause // This is new and so far only for cases - it would be good to find a more abstract // way to auto-apply this for all search components rather than copy-pasting this code to others if (isset($query->_tables['civicrm_case'])) { $aclClauses = array_filter(CRM_Case_BAO_Case::getSelectWhereClause()); foreach ($aclClauses as $clause) { $query->_where[0][] = $clause; } } }