3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2018
35 * This class generates form components for the display preferences.
37 class CRM_Admin_Form_Preferences_Display
extends CRM_Admin_Form_Preferences
{
38 public function preProcess() {
39 CRM_Utils_System
::setTitle(ts('Settings - Display Preferences'));
40 $optionValues = CRM_Activity_BAO_Activity
::buildOptions('activity_type_id');
42 $this->_varNames
= array(
43 CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
=> array(
44 'contact_view_options' => array(
45 'html_type' => 'checkboxes',
46 'title' => ts('Viewing Contacts'),
49 'contact_smart_group_display' => array(
50 'html_type' => 'radio',
51 'title' => ts('Viewing Smart Groups'),
54 'contact_edit_options' => array(
55 'html_type' => 'checkboxes',
56 'title' => ts('Editing Contacts'),
59 'advanced_search_options' => array(
60 'html_type' => 'checkboxes',
61 'title' => ts('Contact Search'),
64 'activity_assignee_notification' => array(
65 'html_type' => 'checkbox',
66 'title' => ts('Notify Activity Assignees'),
69 'activity_assignee_notification_ics' => array(
70 'html_type' => 'checkbox',
71 'title' => ts('Include ICal Invite to Activity Assignees'),
74 'preserve_activity_tab_filter' => array(
75 'html_type' => 'checkbox',
76 'title' => ts('Preserve activity filters as a user preference'),
79 'contact_ajax_check_similar' => array(
80 'title' => ts('Check for Similar Contacts'),
84 'user_dashboard_options' => array(
85 'html_type' => 'checkboxes',
86 'title' => ts('Contact Dashboard'),
89 'display_name_format' => array(
90 'html_type' => 'textarea',
91 'title' => ts('Individual Display Name Format'),
94 'sort_name_format' => array(
95 'html_type' => 'textarea',
96 'title' => ts('Individual Sort Name Format'),
103 'ajaxPopupsEnabled' => array(
104 'html_type' => 'checkbox',
105 'title' => ts('Enable Popup Forms'),
108 'do_not_notify_assignees_for' => array(
109 'html_type' => 'select',
110 'option_values' => $optionValues,
111 'attributes' => array('multiple' => 1, "class" => "huge crm-select2"),
112 'title' => ts('Do not notify assignees for'),
118 parent
::preProcess();
124 public function setDefaultValues() {
125 $defaults = parent
::setDefaultValues();
126 parent
::cbsDefaultValues($defaults);
128 if ($this->_config
->display_name_format
) {
129 $defaults['display_name_format'] = $this->_config
->display_name_format
;
131 if ($this->_config
->sort_name_format
) {
132 $defaults['sort_name_format'] = $this->_config
->sort_name_format
;
139 * Build the form object.
141 public function buildQuickForm() {
142 $wysiwyg_options = CRM_Core_OptionGroup
::values('wysiwyg_editor', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name');
144 //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
145 $invoiceSettings = Civi
::settings()->get('contribution_invoice_settings');
146 $invoicing = CRM_Utils_Array
::value('invoicing', $invoiceSettings);
147 $this->assign('invoicing', $invoicing);
150 $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra);
151 $this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor'));
153 $this->addRadio('contact_ajax_check_similar', ts('Check for Similar Contacts'), array(
154 '1' => ts('While Typing'),
155 '0' => ts('When Saving'),
159 $editOptions = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
160 $this->assign('editOptions', $editOptions);
162 $contactBlocks = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1');
163 $this->assign('contactBlocks', $contactBlocks);
165 $nameFields = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2');
166 $this->assign('nameFields', $nameFields);
168 $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences'));
170 $optionValues = CRM_Core_OptionGroup
::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
171 $invoicesKey = array_search('Invoices / Credit Notes', $optionValues);
172 $this->assign('invoicesKey', $invoicesKey);
173 parent
::buildQuickForm();
177 * Process the form submission.
179 public function postProcess() {
180 if ($this->_action
== CRM_Core_Action
::VIEW
) {
184 $this->_params
= $this->controller
->exportValues($this->_name
);
186 if (!empty($this->_params
['contact_edit_preferences'])) {
187 $preferenceWeights = explode(',', $this->_params
['contact_edit_preferences']);
188 foreach ($preferenceWeights as $key => $val) {
190 unset($preferenceWeights[$key]);
193 $opGroupId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name');
194 CRM_Core_BAO_OptionValue
::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
197 $this->_config
->editor_id
= $this->_params
['editor_id'];
199 $this->postProcessCommon();
201 // Fixme - shouldn't be needed
202 Civi
::settings()->set('contact_ajax_check_similar', $this->_params
['contact_ajax_check_similar']);
204 // If "Configure CKEditor" button was clicked
205 if (!empty($this->_params
['ckeditor_config'])) {
206 // Suppress the "Saved" status message and redirect to the CKEditor Config page
207 $session = CRM_Core_Session
::singleton();
208 $session->getStatus(TRUE);
209 $url = CRM_Utils_System
::url('civicrm/admin/ckeditor', 'reset=1');
210 $session->pushUserContext($url);