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
35 class CRM_Contact_Form_Search_Custom_FullText_Contact
extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery
{
37 function __construct() {
38 parent
::__construct('Contact', ts('Contacts'));
42 return CRM_Core_Permission
::check('view all contacts');
48 public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) {
49 $queries = $this->prepareQueries($queryText, $entityIDTableName);
50 $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit);
51 $this->moveIDs($entityIDTableName, $toTable, $detailLimit);
56 * @param string $queryText
57 * @param string $entityIDTableName
58 * @return array list tables/queries (for runQueries)
60 function prepareQueries($queryText, $entityIDTableName) {
61 // Note: For available full-text indices, see CRM_Core_InnoDBIndexer
63 $contactSQL = array();
66 FROM civicrm_entity_tag et
67 INNER JOIN civicrm_tag t ON et.tag_id = t.id
68 WHERE et.entity_table = 'civicrm_contact'
70 AND ({$this->matchText('civicrm_tag t', 'name', $queryText)})
74 // lets delete all the deceased contacts from the entityID box
75 // this allows us to keep numbers in sync
76 // when we have acl contacts, the situation gets even more murky
78 $final[] = "DELETE FROM {$entityIDTableName} WHERE entity_id IN (SELECT id FROM civicrm_contact WHERE is_deleted = 1)";
81 'civicrm_contact' => array(
86 'display_name' => NULL,
89 'civicrm_address' => array(
92 'street_address' => NULL,
94 'postal_code' => NULL,
97 'civicrm_email' => array(
99 'fields' => array('email' => NULL),
101 'civicrm_phone' => array(
102 'id' => 'contact_id',
103 'fields' => array('phone' => NULL),
105 'civicrm_note' => array(
107 'entity_table' => 'civicrm_contact',
113 'sql' => $contactSQL,
117 // get the custom data info
118 $this->fillCustomInfo($tables,
119 "( 'Contact', 'Individual', 'Organization', 'Household' )"
125 public function moveIDs($fromTable, $toTable, $limit) {
127 INSERT INTO {$toTable}
128 ( id, contact_id, sort_name, display_name, table_name )
129 SELECT c.id, ct.entity_id, c.sort_name, c.display_name, 'Contact'
131 INNER JOIN civicrm_contact c ON ct.entity_id = c.id
132 {$this->toLimit($limit)}
134 CRM_Core_DAO
::executeQuery($sql);