return;
}
+ // skip for hook injected fields / params
+ $extFields = CRM_Contact_BAO_Query_Hook::singleton()->getFields();
+ if (array_key_exists($values[0], $extFields)) {
+ return;
+ }
+
switch ($values[0]) {
case 'deleted_contacts':
$this->deletedContacts($values);
// to handle table dependencies of components
CRM_Core_Component::tableNames($tables);
+ // to handle table dependencies of hook injected tables
+ CRM_Contact_BAO_Query_Hook::singleton()->setTableDependency($tables);
//format the table list according to the weight
$info = CRM_Core_TableHierarchy::info();
}
return $from;
}
+
+ public function setTableDependency(&$tables) {
+ foreach (self::getSearchQueryObjects() as $obj) {
+ $obj->setTableDependency($tables);
+ }
+ }
+
+ public function registerAdvancedSearchPane(&$panes) {
+ foreach (self::getSearchQueryObjects() as $obj) {
+ $obj->registerAdvancedSearchPane($panes);
+ }
+ }
+
+ public function buildAdvancedSearchPaneForm(&$form, $type) {
+ foreach (self::getSearchQueryObjects() as $obj) {
+ $obj->buildAdvancedSearchPaneForm($form, $type);
+ }
+ }
+
+ public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type) {
+ foreach (self::getSearchQueryObjects() as $obj) {
+ $obj->setAdvancedSearchPaneTemplatePath($paneTemplatePathArray, $type);
+ }
+ }
}
\ No newline at end of file
*/
/**
- * Interface for search BAO query objects
+ * Abstract class for search BAO query objects
*/
-interface CRM_Contact_BAO_Query_Interface {
+abstract class CRM_Contact_BAO_Query_Interface {
- public function &getFields();
+ abstract public function &getFields();
+ abstract public function from($fieldName, $mode, $side);
- public function select(&$query);
+ public function select(&$query) {
+ return NULL;
+ }
- public function where(&$query);
+ public function where(&$query) {
+ return NULL;
+ }
- public function from($fieldName, $mode, $side);
+ public function setTableDependency(&$tables) {
+ return NULL;
+ }
+
+ public function registerAdvancedSearchPane(&$panes) {
+ return NULL;
+ }
+
+ public function buildAdvancedSearchPaneForm(&$form, $type) {
+ return NULL;
+ }
+
+ public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type) {
+ return NULL;
+ }
}
\ No newline at end of file
$paneNames[$pane['title']] = $pane['name'];
}
- $this->_paneTemplatePath = array();
+ $hookPanes = array();
+ CRM_Contact_BAO_Query_Hook::singleton()->registerAdvancedSearchPane($hookPanes);
+ $paneNames = array_merge($paneNames, $hookPanes);
+ $this->_paneTemplatePath = array();
foreach ($paneNames as $name => $type) {
- if (!$this->_searchOptions[$type]) {
+ if (!array_key_exists($type, $this->_searchOptions) && !in_array($type, $hookPanes)) {
continue;
}
) {
$allPanes[$name]['open'] = 'true';
-
if (CRM_Utils_Array::value($type, $components)) {
$c = $components[$type];
$this->add('hidden', "hidden_$type", 1);
$c->buildAdvancedSearchPaneForm($this);
$this->_paneTemplatePath[$type] = $c->getAdvancedSearchPaneTemplatePath();
}
+ else if (in_array($type, $hookPanes)) {
+ CRM_Contact_BAO_Query_Hook::singleton()->buildAdvancedSearchPaneForm($this, $type);
+ CRM_Contact_BAO_Query_Hook::singleton()->setAdvancedSearchPaneTemplatePath($this->_paneTemplatePath, $type);
+ }
else {
CRM_Contact_Form_Search_Criteria::$type($this);
$template = ucfirst($type);