3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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_Participant
extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery
{
40 public function __construct() {
41 parent
::__construct('Participant', ts('Participants'));
47 public function isActive() {
48 $config = CRM_Core_Config
::singleton();
49 return in_array('CiviEvent', $config->enableComponents
) &&
50 CRM_Core_Permission
::check('view event participants');
56 public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) {
57 $queries = $this->prepareQueries($queryText, $entityIDTableName);
58 $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit);
59 $this->moveIDs($entityIDTableName, $toTable, $detailLimit);
60 if (!empty($result['files'])) {
61 $this->moveFileIDs($toTable, 'participant_id', $result['files']);
67 * Get participant ids in entity tables.
69 * @param string $queryText
70 * @param string $entityIDTableName
72 * list tables/queries (for runQueries)
74 public function prepareQueries($queryText, $entityIDTableName) {
75 // Note: For available full-text indices, see CRM_Core_InnoDBIndexer
77 $contactSQL = array();
80 FROM civicrm_participant cp
81 INNER JOIN civicrm_contact c ON cp.contact_id = c.id
82 WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_name', 'nick_name'), $queryText)})
85 'civicrm_participant' => array(
90 'fee_amount' => 'Int',
94 'xparent_table' => 'civicrm_participant',
97 'civicrm_note' => array(
99 'entity_table' => 'civicrm_participant',
107 // get the custom data info
108 $this->fillCustomInfo($tables, "( 'Participant' )");
112 public function moveIDs($fromTable, $toTable, $limit) {
114 INSERT INTO {$toTable}
115 ( table_name, contact_id, sort_name, participant_id, event_title, participant_fee_level, participant_fee_amount,
116 participant_register_date, participant_source, participant_status, participant_role )
117 SELECT 'Participant', c.id, c.sort_name, cp.id, ce.title, cp.fee_level, cp.fee_amount, cp.register_date, cp.source,
118 participantStatus.label, cp.role_id
120 INNER JOIN civicrm_participant cp ON cp.id = ct.entity_id
121 LEFT JOIN civicrm_contact c ON cp.contact_id = c.id
122 LEFT JOIN civicrm_event ce ON ce.id = cp.event_id
123 LEFT JOIN civicrm_participant_status_type participantStatus ON participantStatus.id = cp.status_id
124 {$this->toLimit($limit)}
126 CRM_Core_DAO
::executeQuery($sql);