Merge pull request #6746 from systopia/CRM-17218
[civicrm-core.git] / CRM / Admin / Form / Setting / Search.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2015
32 */
33
34 /**
35 * This class generates form components for Search Parameters
36 *
37 */
38 class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting {
39
40 protected $_settings = array(
41 'contact_reference_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
42 'contact_autocomplete_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
43 'search_autocomplete_count' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
44 'enable_innodb_fts' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
45 'includeWildCardInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
46 'includeEmailInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
47 'includeNickNameInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
48 'includeAlphabeticalPager' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
49 'includeOrderByClause' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
50 'smartGroupCacheTimeout' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
51 'defaultSearchProfileID' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
52 );
53
54 /**
55 * Build the form object.
56 */
57 public function buildQuickForm() {
58 CRM_Utils_System::setTitle(ts('Settings - Search Preferences'));
59
60 parent::buildQuickForm();
61
62 // @todo remove the following adds in favour of setting via the settings array (above).
63
64 // Autocomplete for Contact Search (quick search etc.)
65 $element = $this->getElement('contact_autocomplete_options');
66 $element->_elements[0]->_flagFrozen = TRUE;
67
68 // Autocomplete for Contact Reference (custom fields)
69 $element = $this->getElement('contact_reference_options');
70 $element->_elements[0]->_flagFrozen = TRUE;
71 }
72
73 /**
74 * @return array
75 */
76 public static function getContactAutocompleteOptions() {
77 return array(
78 ts('Contact Name') => 1,
79 ) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
80 FALSE, FALSE, TRUE
81 ));
82 }
83
84 /**
85 * @return array
86 */
87 public static function getAvailableProfiles() {
88 return array('' => ts('- none -')) + CRM_Core_BAO_UFGroup::getProfiles(array(
89 'Contact',
90 'Individual',
91 'Organization',
92 'Household',
93 ));
94 }
95
96 /**
97 * @return array
98 */
99 public static function getContactReferenceOptions() {
100 return array(
101 ts('Contact Name') => 1,
102 ) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
103 FALSE, FALSE, TRUE
104 ));
105 }
106
107 }