CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
- $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
- FALSE, FALSE, TRUE, NULL, 'name'
- ));
-
- $cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
- FALSE, FALSE, TRUE, NULL, 'name'
- ));
-
- $listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'contact_autocomplete_options'
- );
- $cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'contact_reference_options'
- );
-
- $autoSearchFields = array();
- if (!empty($list) && !empty($listEnabled)) {
- $autoSearchFields = array_combine($list, $listEnabled);
- }
-
- $cRSearchFields = array();
- if (!empty($cRlist) && !empty($cRlistEnabled)) {
- $cRSearchFields = array_combine($cRlist, $cRlistEnabled);
- }
-
- //Set defaults for autocomplete and contact reference options
- $this->_defaults['autocompleteContactSearch'] = array(
- '1' => 1,
- ) + $autoSearchFields;
- $this->_defaults['autocompleteContactReference'] = array(
- '1' => 1,
- ) + $cRSearchFields;
-
// we can handle all the ones defined in the metadata here. Others to be converted
foreach ($this->_settings as $setting => $group) {
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
);
}
+ $this->_defaults['contact_autocomplete_options'] = self::getAutocompleteContactSearch();
+ $this->_defaults['contact_reference_options'] = self::getAutocompleteContactReference();
$this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL');
$this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
$this->_defaults['enableComponents'] = Civi::settings()->get('enable_components');
elseif ($add == 'addSelect') {
$this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props));
}
+ elseif ($add == 'addCheckBox') {
+ $this->addCheckBox($setting, ts($props['title']), $options['values'], NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, array(' '));
+ }
elseif ($add == 'addChainSelect') {
$this->addChainSelect($setting, array(
'label' => ts($props['title']),
public function commonProcess(&$params) {
// save autocomplete search options
- if (!empty($params['autocompleteContactSearch'])) {
- $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_keys($params['autocompleteContactSearch'])
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
-
- CRM_Core_BAO_Setting::setItem($value,
- CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'contact_autocomplete_options'
- );
-
- unset($params['autocompleteContactSearch']);
+ if (!empty($params['contact_autocomplete_options'])) {
+ Civi::settings()->set('contact_autocomplete_options',
+ CRM_Utils_Array::implodePadded(array_keys($params['contact_autocomplete_options'])));
+ unset($params['contact_autocomplete_options']);
}
// save autocomplete contact reference options
- if (!empty($params['autocompleteContactReference'])) {
- $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_keys($params['autocompleteContactReference'])
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
-
- CRM_Core_BAO_Setting::setItem($value,
- CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'contact_reference_options'
- );
-
- unset($params['autocompleteContactReference']);
+ if (!empty($params['contact_reference_options'])) {
+ Civi::settings()->set('contact_reference_options',
+ CRM_Utils_Array::implodePadded(array_keys($params['contact_reference_options'])));
+ unset($params['contact_reference_options']);
}
// save components to be enabled
@unlink($configFile);
}
+ /**
+ * Ugh, this shouldn't exist.
+ *
+ * Get the selected values of "contact_reference_options" formatted for checkboxes.
+ *
+ * @return array
+ */
+ public static function getAutocompleteContactReference() {
+ $cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
+ FALSE, FALSE, TRUE, NULL, 'name'
+ ));
+ $cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+ 'contact_reference_options'
+ );
+ $cRSearchFields = array();
+ if (!empty($cRlist) && !empty($cRlistEnabled)) {
+ $cRSearchFields = array_combine($cRlist, $cRlistEnabled);
+ }
+ return array(
+ '1' => 1,
+ ) + $cRSearchFields;
+ }
+
+ /**
+ * Ugh, this shouldn't exist.
+ *
+ * Get the selected values of "contact_autocomplete_options" formatted for checkboxes.
+ *
+ * @return array
+ */
+ public static function getAutocompleteContactSearch() {
+ $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
+ FALSE, FALSE, TRUE, NULL, 'name'
+ ));
+ $listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+ 'contact_autocomplete_options'
+ );
+ $autoSearchFields = array();
+ if (!empty($list) && !empty($listEnabled)) {
+ $autoSearchFields = array_combine($list, $listEnabled);
+ }
+ //Set defaults for autocomplete and contact reference options
+ return array(
+ '1' => 1,
+ ) + $autoSearchFields;
+ }
+
}
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,
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Search Preferences'));
+ parent::buildQuickForm();
+
// @todo remove the following adds in favour of setting via the settings array (above).
// Autocomplete for Contact Search (quick search etc.)
- $options = 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 = $this->getElement('contact_autocomplete_options');
$element->_elements[0]->_flagFrozen = TRUE;
// Autocomplete for Contact Reference (custom fields)
- $optionsCR = 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 = $this->getElement('contact_reference_options');
$element->_elements[0]->_flagFrozen = TRUE;
+ }
- parent::buildQuickForm();
+ /**
+ * @return array
+ */
+ public static function getContactAutocompleteOptions() {
+ return array(
+ ts('Contact Name') => 1,
+ ) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
+ FALSE, FALSE, TRUE
+ ));
}
/**
));
}
+ /**
+ * @return array
+ */
+ public static function getContactReferenceOptions() {
+ return array(
+ ts('Contact Name') => 1,
+ ) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
+ FALSE, FALSE, TRUE
+ ));
+ }
+
}
* @param \Civi\Core\SettingsBag $settings
* @param string $activatedLocales
* Imploded list of locales which are supported in the DB.
- * @return array
*/
public static function applyLocale($settings, $activatedLocales) {
// are we in a multi-language setup?
'group' => 'core',
'name' => 'contact_autocomplete_options',
'type' => 'String',
- 'html_type' => 'checkboxes',
+ 'quick_form_type' => 'CheckBox',
'pseudoconstant' => array(
- 'optionGroupName' => 'contact_autocomplete_options',
+ 'callback' => 'CRM_Admin_Form_Setting_Search::getContactAutocompleteOptions',
),
- 'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 1',
+ 'default' => '\ 11\ 12\ 1',
'add' => '4.1',
- 'title' => 'Contact Reference Autocomplete Options',
+ 'title' => 'Autocomplete Contact Search',
'is_domain' => 1,
'is_contact' => 0,
- 'description' => NULL,
+ 'description' => "Selected fields will be displayed in back-office autocomplete dropdown search results (Quick Search, etc.). Contact Name is always included.",
'help_text' => NULL,
),
'contact_reference_options' => array(
'group' => 'core',
'name' => 'contact_reference_options',
'type' => 'String',
- 'html_type' => 'checkboxes',
+ 'quick_form_type' => 'CheckBox',
'pseudoconstant' => array(
- 'optionGroupName' => 'contact_reference_options',
+ 'callback' => 'CRM_Admin_Form_Setting_Search::getContactReferenceOptions',
),
- 'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 1',
+ 'default' => '\ 11\ 12\ 1',
'add' => '4.1',
'title' => 'Contact Reference Options',
'is_domain' => 1,
'is_contact' => 0,
- 'description' => NULL,
+ 'description' => "Selected fields will be displayed in autocomplete dropdown search results for 'Contact Reference' custom fields. Contact Name is always included. NOTE: You must assign 'access contact reference fields' permission to the anonymous role if you want to use custom contact reference fields in profiles on public pages. For most situations, you should use the 'Limit List to Group' setting when configuring a contact reference field which will be used in public forms to prevent exposing your entire contact list.",
'help_text' => NULL,
),
'max_attachments' => array(
'description' => 'If set, this will be the default profile used for contact search.',
'help_text' => NULL,
),
- 'autocompleteContactSearch' => array(
- 'group_name' => 'Search Preferences',
- 'group' => 'Search Preferences',
- 'name' => 'autocompleteContactSearch',
- 'prefetch' => 1,
- // prefetch causes it to be cached in config settings. Usually this is a transitional setting. Some things like urls are permanent. Remove this comment if you have assessed & it should be permanent
- 'config_only' => 1,
- //@todo - see https://wiki.civicrm.org/confluence/display/CRMDOC/Settings+Reference#SettingsReference-Convertingaconfigobjecttoasetting on removing this deprecated value
- 'type' => 'Integer',
- 'quick_form_type' => 'CheckBox',
- 'default' => 1,
- 'add' => '4.6',
- 'title' => 'Autocomplete Contact Search',
- 'pseudoconstant' => array('optionGroupName' => 'contact_autocomplete_options'),
- 'is_domain' => 1,
- 'is_contact' => 0,
- 'description' => "Selected fields will be displayed in back-office autocomplete dropdown search results (Quick Search, etc.). Contact Name is always included.",
- 'help_text' => NULL,
- ),
- 'autocompleteContactReference' => array(
- 'group_name' => 'Search Preferences',
- 'group' => 'Search Preferences',
- 'name' => 'autocompleteContactReference',
- 'prefetch' => 1,
- // prefetch causes it to be cached in config settings. Usually this is a transitional setting. Some things like urls are permanent. Remove this comment if you have assessed & it should be permanent
- 'config_only' => 1,
- //@todo - see https://wiki.civicrm.org/confluence/display/CRMDOC/Settings+Reference#SettingsReference-Convertingaconfigobjecttoasetting on removing this deprecated value
- 'type' => 'Integer',
- 'quick_form_type' => 'CheckBox',
- 'default' => 1,
- 'add' => '4.6',
- 'title' => 'Contact Reference Options',
- 'pseudoconstant' => array('optionGroupName' => 'contact_reference_options'),
- 'is_domain' => 1,
- 'is_contact' => 0,
- 'description' => "Selected fields will be displayed in autocomplete dropdown search results for 'Contact Reference' custom fields. Contact Name is always included. NOTE: You must assign 'access contact reference fields' permission to the anonymous role if you want to use custom contact reference fields in profiles on public pages. For most situations, you should use the 'Limit List to Group' setting when configuring a contact reference field which will be used in public forms to prevent exposing your entire contact list.",
- 'help_text' => NULL,
- ),
);
<span class="description">{ts}The number of minutes to cache smart group contacts. We strongly recommend that this value be greater than zero, since a value of zero means no caching at all. If your contact data changes frequently, you should set this value to at least 5 minutes.{/ts}</span></td>
</tr>
<tr class="crm-search-setting-form-block-autocompleteContactSearch">
- <td class="label">{$form.autocompleteContactSearch.label}</td>
- <td>{$form.autocompleteContactSearch.html}<br/>
+ <td class="label">{$form.contact_autocomplete_options.label}</td>
+ <td>{$form.contact_autocomplete_options.html}<br/>
<span class="description">{ts}Selected fields will be displayed in back-office autocomplete dropdown search results (Quick Search, etc.). Contact Name is always included.{/ts}</span></td>
</tr>
<tr class="crm-search-setting-form-block-autocompleteContactReference">
- <td class="label">{$form.autocompleteContactReference.label}</td>
- <td>{$form.autocompleteContactReference.html}<br/>
+ <td class="label">{$form.contact_reference_options.label}</td>
+ <td>{$form.contact_reference_options.html}<br/>
<span class="description">{ts}Selected fields will be displayed in autocomplete dropdown search results for 'Contact Reference' custom fields. Contact Name is always included. NOTE: You must assign 'access contact reference fields' permission to the anonymous role if you want to use custom contact reference fields in profiles on public pages. For most situations, you should use the 'Limit List to Group' setting when configuring a contact reference field which will be used in public forms to prevent exposing your entire contact list.{/ts}</span></td>
</tr>
<tr class="crm-search-setting-form-block-search_autocomplete_count">