Update copyright date for 2020
[civicrm-core.git] / CRM / Admin / Form / Preferences / Display.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
f299f7db 6 | Copyright CiviCRM LLC (c) 2004-2020 |
6a488035
TO
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
f299f7db 31 * @copyright CiviCRM LLC (c) 2004-2020
6a488035
TO
32 */
33
c866eb5f
TO
34/**
35 * This class generates form components for the display preferences.
6a488035
TO
36 */
37class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
a55c9b35 38
be2fb01f 39 protected $_settings = [
a55c9b35 40 'contact_view_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
c5af8245 41 'contact_smart_group_display' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
719eda4a 42 'contact_edit_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
2e94f477 43 'advanced_search_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
94b60b64 44 'user_dashboard_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
719eda4a 45 'contact_ajax_check_similar' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
74f89a9f 46 'activity_assignee_notification' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
47 'activity_assignee_notification_ics' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
719eda4a 48 'do_not_notify_assignees_for' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
c89a43b3 49 'preserve_activity_tab_filter' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
719eda4a 50 'editor_id' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
74f89a9f 51 'ajaxPopupsEnabled' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
94b60b64 52 'display_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
7399a0a6 53 'sort_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
b30809e4 54 'menubar_position' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
8a52ae34 55 'menubar_color' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
d89d2545
TO
56 'theme_backend' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
57 'theme_frontend' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
be2fb01f 58 ];
a55c9b35 59
6a488035 60 /**
eceb18cc 61 * Build the form object.
6a488035
TO
62 */
63 public function buildQuickForm() {
6a488035 64
e0d683cf 65 //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
aaffa79f 66 $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
d0df87f2 67 $this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled());
6a488035 68
7266e09b 69 $this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor'));
6a488035 70
6a488035
TO
71 $editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
72 $this->assign('editOptions', $editOptions);
73
74 $contactBlocks = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1');
75 $this->assign('contactBlocks', $contactBlocks);
76
8b49cb50
OB
77 $nameFields = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2');
78 $this->assign('nameFields', $nameFields);
79
be2fb01f 80 $this->addElement('hidden', 'contact_edit_preferences', NULL, ['id' => 'contact_edit_preferences']);
6a488035 81
9148c277 82 $optionValues = CRM_Core_OptionGroup::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
e0d683cf
PB
83 $invoicesKey = array_search('Invoices / Credit Notes', $optionValues);
84 $this->assign('invoicesKey', $invoicesKey);
6a488035
TO
85 parent::buildQuickForm();
86 }
87
88 /**
eceb18cc 89 * Process the form submission.
6a488035
TO
90 */
91 public function postProcess() {
92 if ($this->_action == CRM_Core_Action::VIEW) {
93 return;
94 }
95
96 $this->_params = $this->controller->exportValues($this->_name);
97
a7488080 98 if (!empty($this->_params['contact_edit_preferences'])) {
6a488035
TO
99 $preferenceWeights = explode(',', $this->_params['contact_edit_preferences']);
100 foreach ($preferenceWeights as $key => $val) {
101 if (!$val) {
102 unset($preferenceWeights[$key]);
103 }
104 }
105 $opGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name');
106 CRM_Core_BAO_OptionValue::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
107 }
108
6a488035 109 $this->postProcessCommon();
7266e09b
CW
110
111 // If "Configure CKEditor" button was clicked
112 if (!empty($this->_params['ckeditor_config'])) {
113 // Suppress the "Saved" status message and redirect to the CKEditor Config page
114 $session = CRM_Core_Session::singleton();
115 $session->getStatus(TRUE);
116 $url = CRM_Utils_System::url('civicrm/admin/ckeditor', 'reset=1');
117 $session->pushUserContext($url);
118 }
6a488035 119 }
96025800 120
6a488035 121}