diff --git a/CRM/ConstituentsOnly/BAO/Query.php b/CRM/ConstituentsOnly/BAO/Query.php index f01f2ba..fbe68b2 100644 --- a/CRM/ConstituentsOnly/BAO/Query.php +++ b/CRM/ConstituentsOnly/BAO/Query.php @@ -49,6 +49,11 @@ class CRM_ConstituentsOnly_BAO_Query extends CRM_Contact_BAO_Query_Interface { return; } + if (!empty($query->_paramLookup['ignore_constituent_search'])) { + $query->_qill[0][] = ts("Include non-constituents in this search"); + return; + } + if (CRM_Utils_Array::value('civicrm_contact', $query->_tables) && empty($query->_paramLookup['do_not_trade'])) { $query->_where[0][] = " IF (contact_a.do_not_trade = 1, diff --git a/constituentsonly.php b/constituentsonly.php index 9f5fd23..eaab62d 100644 --- a/constituentsonly.php +++ b/constituentsonly.php @@ -190,6 +190,25 @@ function constituentsonly_civicrm_selectWhereClause($entity, &$clauses) { */ function constituentsonly_civicrm_searchColumns($objectName, &$headers, &$rows, &$selector) { if (in_array($objectName, ['contact']) && !empty($rows)) { + if (!empty($_POST['ignore_constituent_search'])) { + return; + } $rows = CRM_ConstituentsOnly_BAO_ConstituentsOnly::updateSearchRows($rows, $headers); } } + +/** + * Implements hook_civicrm_buildForm(). + * + * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm + */ +function constituentsonly_civicrm_buildForm($formName, &$form) { + if ('CRM_Contact_Form_Search_Advanced' == $formName + && !($form->getVar('_action') == CRM_Core_Action::DELETE) + ) { + $form->addElement('checkbox', 'ignore_constituent_search', ts('Include non-constituents')); + CRM_Core_Region::instance('page-body')->add(array( + 'template' => 'CRM/common.tpl', + )); + } +} diff --git a/templates/CRM/common.tpl b/templates/CRM/common.tpl new file mode 100644 index 0000000..3427f16 --- /dev/null +++ b/templates/CRM/common.tpl @@ -0,0 +1,13 @@ + +
{$form.ignore_constituent_search.html} {$form.ignore_constituent_search.label} | +