3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
37 * Delegate query functions based on hook system
39 class CRM_Contact_BAO_Query_Hook
{
42 * @var array of CRM_Contact_BAO_Query_Interface objects
44 protected $_queryObjects = NULL;
47 * singleton function used to manage this object
53 public static function singleton() {
54 static $singleton = NULL;
56 $singleton = new CRM_Contact_BAO_Query_Hook();
62 * Get or build the list of search objects (via hook)
64 * @return array of CRM_Contact_BAO_Query_Interface objects
66 public function getSearchQueryObjects() {
67 if ($this->_queryObjects
=== NULL) {
68 $this->_queryObjects
= array();
69 CRM_Utils_Hook
::queryObjects($this->_queryObjects
, 'Contact');
71 return $this->_queryObjects
;
77 public function &getFields() {
79 foreach (self
::getSearchQueryObjects() as $obj) {
80 $flds = $obj->getFields();
81 $extFields = array_merge($extFields, $flds);
88 * @param $fieldOptions
90 public function alterSearchBuilderOptions(&$apiEntities, &$fieldOptions) {
91 foreach (self
::getSearchQueryObjects() as $obj) {
92 $obj->alterSearchBuilderOptions($apiEntities, $fieldOptions);
100 public function alterSearchQuery(&$query, $fnName) {
101 foreach (self
::getSearchQueryObjects() as $obj) {
102 $obj->$fnName($query);
113 public function buildSearchfrom($fieldName, $mode, $side) {
115 foreach (self
::getSearchQueryObjects() as $obj) {
116 $from .= $obj->from($fieldName, $mode, $side);
124 public function setTableDependency(&$tables) {
125 foreach (self
::getSearchQueryObjects() as $obj) {
126 $obj->setTableDependency($tables);
133 public function registerAdvancedSearchPane(&$panes) {
134 foreach (self
::getSearchQueryObjects() as $obj) {
135 $obj->registerAdvancedSearchPane($panes);
142 public function getPanesMapper(&$panes) {
143 foreach (self
::getSearchQueryObjects() as $obj) {
144 $obj->getPanesMapper($panes);
152 public function buildAdvancedSearchPaneForm(&$form, $type) {
153 foreach (self
::getSearchQueryObjects() as $obj) {
154 $obj->buildAdvancedSearchPaneForm($form, $type);
159 * @param $paneTemplatePathArray
162 public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type) {
163 foreach (self
::getSearchQueryObjects() as $obj) {
164 $obj->setAdvancedSearchPaneTemplatePath($paneTemplatePathArray, $type);