3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
35 * Delegate query functions based on hook system.
37 class CRM_Contact_BAO_Query_Hook
{
40 * @var array of CRM_Contact_BAO_Query_Interface objects
42 protected $_queryObjects = NULL;
45 * Singleton function used to manage this object.
49 public static function singleton() {
50 static $singleton = NULL;
52 $singleton = new CRM_Contact_BAO_Query_Hook();
58 * Get or build the list of search objects (via hook).
61 * Array of CRM_Contact_BAO_Query_Interface objects
63 public function getSearchQueryObjects() {
64 if ($this->_queryObjects
=== NULL) {
65 $this->_queryObjects
= array();
66 CRM_Utils_Hook
::queryObjects($this->_queryObjects
, 'Contact');
68 return $this->_queryObjects
;
74 public function &getFields() {
76 foreach (self
::getSearchQueryObjects() as $obj) {
77 $flds = $obj->getFields();
78 $extFields = array_merge($extFields, $flds);
85 * @param $fieldOptions
87 public function alterSearchBuilderOptions(&$apiEntities, &$fieldOptions) {
88 foreach (self
::getSearchQueryObjects() as $obj) {
89 $obj->alterSearchBuilderOptions($apiEntities, $fieldOptions);
96 * @param string $query
97 * @param string $fnName
99 public function alterSearchQuery(&$query, $fnName) {
100 foreach (self
::getSearchQueryObjects() as $obj) {
101 $obj->$fnName($query);
106 * @param string $fieldName
112 public function buildSearchfrom($fieldName, $mode, $side) {
114 foreach (self
::getSearchQueryObjects() as $obj) {
115 $from .= $obj->from($fieldName, $mode, $side);
123 public function setTableDependency(&$tables) {
124 foreach (self
::getSearchQueryObjects() as $obj) {
125 $obj->setTableDependency($tables);
132 public function registerAdvancedSearchPane(&$panes) {
133 foreach (self
::getSearchQueryObjects() as $obj) {
134 $obj->registerAdvancedSearchPane($panes);
141 public function getPanesMapper(&$panes) {
142 foreach (self
::getSearchQueryObjects() as $obj) {
143 $obj->getPanesMapper($panes);
148 * @param CRM_Core_Form $form
151 public function buildAdvancedSearchPaneForm(&$form, $type) {
152 foreach (self
::getSearchQueryObjects() as $obj) {
153 $obj->buildAdvancedSearchPaneForm($form, $type);
158 * @param $paneTemplatePathArray
161 public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type) {
162 foreach (self
::getSearchQueryObjects() as $obj) {
163 $obj->setAdvancedSearchPaneTemplatePath($paneTemplatePathArray, $type);