<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
*/
class CRM_Contact_Form_Search_Custom_FullText_Membership extends CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery {
- function __construct() {
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
parent::__construct('Membership', ts('Memberships'));
}
- function isActive() {
+ /**
+ * @return bool
+ */
+ public function isActive() {
$config = CRM_Core_Config::singleton();
return in_array('CiviMember', $config->enableComponents) &&
- CRM_Core_Permission::check('access CiviMember');
+ CRM_Core_Permission::check('access CiviMember');
}
/**
- * {@inheritdoc}
+ * @inheritDoc
*/
public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) {
- $count = $this->fillMembershipIDs($queryText, $entityIDTableName, $queryLimit);
- $this->moveMembershipIDs($entityIDTableName, $toTable, $detailLimit);
- return $count;
+ $queries = $this->prepareQueries($queryText, $entityIDTableName);
+ $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit);
+ $this->moveIDs($entityIDTableName, $toTable, $detailLimit);
+ if (!empty($result['files'])) {
+ $this->moveFileIDs($toTable, 'membership_id', $result['files']);
+ }
+ return $result;
}
/**
- * get membership ids in entity tables.
+ * Get membership ids in entity tables.
*
* @param string $queryText
- * @return int the total number of matches
+ * @param string $entityIDTableName
+ * @return array
+ * list tables/queries (for runQueries)
*/
- function fillMembershipIDs($queryText, $entityIDTableName, $limit) {
+ public function prepareQueries($queryText, $entityIDTableName) {
// Note: For available full-text indices, see CRM_Core_InnoDBIndexer
$contactSQL = array();
'id' => 'id',
'fields' => array('source' => NULL),
),
+ 'file' => array(
+ 'xparent_table' => 'civicrm_membership',
+ ),
'sql' => $contactSQL,
);
// get the custom data info
$this->fillCustomInfo($tables, "( 'Membership' )");
- return $this->runQueries($queryText, $tables, $entityIDTableName, $limit);
+ return $tables;
}
- public function moveMembershipIDs($fromTable, $toTable, $limit) {
+ public function moveIDs($fromTable, $toTable, $limit) {
$sql = "
INSERT INTO {$toTable}
( table_name, contact_id, sort_name, membership_id, membership_type, membership_fee, membership_start_date,
CRM_Core_DAO::executeQuery($sql);
}
-}
\ No newline at end of file
+}