Merge pull request #9595 from totten/master-extbatch-env
[civicrm-core.git] / CRM / Admin / Form / Setting / Search.php
index b783ed05902829cad21cff61c008a8938c778af8..006aca2de0375cf7bb87234cd695266cd346cb20 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2017
  */
 
 /**
 class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting {
 
   protected $_settings = array(
+    'contact_reference_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'contact_autocomplete_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
     'search_autocomplete_count' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
     'enable_innodb_fts' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'includeWildCardInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'includeEmailInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'includeNickNameInName' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'includeAlphabeticalPager' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'includeOrderByClause' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'smartGroupCacheTimeout' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'defaultSearchProfileID' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
   );
 
   /**
@@ -48,50 +57,51 @@ class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting {
   public function buildQuickForm() {
     CRM_Utils_System::setTitle(ts('Settings - Search Preferences'));
 
-    // @todo remove the following adds in favour of setting via the settings array (above).
-    $this->addYesNo('includeWildCardInName', ts('Automatic Wildcard'));
-    $this->addYesNo('includeEmailInName', ts('Include Email'));
-    $this->addYesNo('includeNickNameInName', ts('Include Nickname'));
-
-    $this->addYesNo('includeAlphabeticalPager', ts('Include Alphabetical Pager'));
-    $this->addYesNo('includeOrderByClause', ts('Include Order By Clause'));
+    parent::buildQuickForm();
 
-    $this->addElement('text', 'smartGroupCacheTimeout', ts('Smart group cache timeout'),
-      array('size' => 3, 'maxlength' => 5)
-    );
+    // @todo remove the following adds in favour of setting via the settings array (above).
 
-    $types = array('Contact', 'Individual', 'Organization', 'Household');
-    $profiles = CRM_Core_BAO_UFGroup::getProfiles($types);
+    // Autocomplete for Contact Search (quick search etc.)
+    $element = $this->getElement('contact_autocomplete_options');
+    $element->_elements[0]->_flagFrozen = TRUE;
 
-    $this->add('select', 'defaultSearchProfileID', ts('Default Contact Search Profile'),
-      array('' => ts('- none -')) + $profiles, FALSE, array('class' => 'crm-select2 huge')
-    );
+    // Autocomplete for Contact Reference (custom fields)
+    $element = $this->getElement('contact_reference_options');
+    $element->_elements[0]->_flagFrozen = TRUE;
+  }
 
-    // Autocomplete for Contact Search (quick search etc.)
-    $options = array(
+  /**
+   * @return array
+   */
+  public static function getContactAutocompleteOptions() {
+    return array(
       ts('Contact Name') => 1,
     ) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
-        FALSE, FALSE, TRUE
-      ));
-    $this->addCheckBox('autocompleteContactSearch', ts('Autocomplete Contact Search'), $options,
-      NULL, NULL, NULL, NULL, array('  ')
-    );
-    $element = $this->getElement('autocompleteContactSearch');
-    $element->_elements[0]->_flagFrozen = TRUE;
+      FALSE, FALSE, TRUE
+    ));
+  }
 
-    // Autocomplete for Contact Reference (custom fields)
-    $optionsCR = array(
+  /**
+   * @return array
+   */
+  public static function getAvailableProfiles() {
+    return array('' => ts('- none -')) + CRM_Core_BAO_UFGroup::getProfiles(array(
+      'Contact',
+      'Individual',
+      'Organization',
+      'Household',
+    ));
+  }
+
+  /**
+   * @return array
+   */
+  public static function getContactReferenceOptions() {
+    return array(
       ts('Contact Name') => 1,
     ) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
-        FALSE, FALSE, TRUE
-      ));
-    $this->addCheckBox('autocompleteContactReference', ts('Contact Reference Options'), $optionsCR,
-      NULL, NULL, NULL, NULL, array('  ')
-    );
-    $element = $this->getElement('autocompleteContactReference');
-    $element->_elements[0]->_flagFrozen = TRUE;
-
-    parent::buildQuickForm();
+      FALSE, FALSE, TRUE
+    ));
   }
 
 }