Commit a55c9b35 authored by eileen's avatar eileen

Allow Preferences form to work from settings

parent bd3a9553
......@@ -35,6 +35,9 @@
* Base class for settings forms.
*/
class CRM_Admin_Form_Preferences extends CRM_Core_Form {
use CRM_Admin_Form_SettingTrait;
protected $_system = FALSE;
protected $_contactID = NULL;
public $_action = NULL;
......@@ -85,6 +88,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
$this->_config->contact_id = $this->_contactID;
}
$this->addFieldsDefinedInSettingsMetadata();
$settings = Civi::settings();
foreach ($this->_varNames as $groupName => $settingNames) {
foreach ($settingNames as $settingName => $options) {
......
......@@ -35,17 +35,17 @@
* This class generates form components for the display preferences.
*/
class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
protected $_settings = array(
'contact_view_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
);
public function preProcess() {
CRM_Utils_System::setTitle(ts('Settings - Display Preferences'));
$optionValues = CRM_Activity_BAO_Activity::buildOptions('activity_type_id');
$this->_varNames = array(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
'contact_view_options' => array(
'html_type' => 'checkboxes',
'title' => ts('Viewing Contacts'),
'weight' => 1,
),
'contact_smart_group_display' => array(
'html_type' => 'radio',
'title' => ts('Viewing Smart Groups'),
......
......@@ -125,6 +125,19 @@ trait CRM_Admin_Form_SettingTrait {
elseif ($add == 'addCheckBox') {
$this->addCheckBox($setting, ts($props['title']), $options['values'], NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, ['  ']);
}
elseif ($add == 'addCheckBoxes') {
$options = array_flip($options['values']);
$newOptions = [];
foreach ($options as $key => $val) {
$newOptions[$key] = $val;
}
$this->addCheckBox($setting,
$props['title'],
$newOptions,
NULL, NULL, NULL, NULL,
['&nbsp;&nbsp;', '&nbsp;&nbsp;', '<br/>']
);
}
elseif ($add == 'addChainSelect') {
$this->addChainSelect($setting, [
'label' => ts($props['title']),
......
......@@ -42,16 +42,17 @@ return array(
'group' => 'core',
'name' => 'contact_view_options',
'type' => 'String',
'quick_form_type' => 'CheckBoxes',
'html_type' => 'checkboxes',
'pseudoconstant' => array(
'optionGroupName' => 'contact_view_options',
),
'default' => '123456789101113',
'add' => '4.1',
'title' => 'Viewing Contacts',
'title' => ts('Viewing Contacts'),
'is_domain' => '1',
'is_contact' => 0,
'description' => NULL,
'description' => ts("Select the tabs that should be displayed when viewing a contact record. EXAMPLE: If your organization does not keep track of 'Relationships', then un-check this option to simplify the screen display. Tabs for Contributions, Pledges, Memberships, Events, Grants and Cases are also hidden if the corresponding component is not enabled. Go to Administer > System Settings > Enable Components to modify the components which are available for your site."),
'help_text' => NULL,
),
'contact_edit_options' => array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment