Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
32 | * $Id: Display.php 45499 2013-02-08 12:31:05Z kurund $ | |
33 | * | |
34 | */ | |
35 | ||
36 | /**r | |
37 | * This class generates form components for the display preferences | |
38 | * | |
39 | */ | |
40 | class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { | |
41 | function preProcess() { | |
42 | CRM_Utils_System::setTitle(ts('Settings - Display Preferences')); | |
43 | ||
44 | if (defined('CIVICRM_ACTIVITY_ASSIGNEE_MAIL') && CIVICRM_ACTIVITY_ASSIGNEE_MAIL) { | |
68679c0d KJ |
45 | CRM_Core_Session::setStatus(ts('Your civicrm.settings.php file contains CIVICRM_ACTIVITY_ASSIGNEE_MAIL but this |
46 | constant is no longer used. Please remove this from your config file and set your "Notify Activity Assignees" | |
47 | preference below.'), ts("Deprecated Constant"), "alert"); | |
6a488035 TO |
48 | } |
49 | ||
50 | $this->_varNames = array( | |
51 | CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => | |
52 | array( | |
53 | 'contact_view_options' => array( | |
54 | 'html_type' => 'checkboxes', | |
55 | 'title' => ts('Viewing Contacts'), | |
56 | 'weight' => 1, | |
57 | ), | |
58 | 'contact_edit_options' => array( | |
59 | 'html_type' => 'checkboxes', | |
60 | 'title' => ts('Editing Contacts'), | |
61 | 'weight' => 2, | |
62 | ), | |
63 | 'advanced_search_options' => array( | |
64 | 'html_type' => 'checkboxes', | |
65 | 'title' => ts('Contact Search'), | |
66 | 'weight' => 3, | |
67 | ), | |
68 | 'activity_assignee_notification' => array( | |
69 | 'html_type' => 'checkbox', | |
70 | 'title' => ts('Notify Activity Assignees'), | |
71 | 'weight' => 5, | |
72 | ), | |
73 | 'activity_assignee_notification_ics' => array( | |
74 | 'html_type' => 'checkbox', | |
75 | 'title' => ts('Include ICal Invite to Activity Assignees'), | |
76 | 'weight' => 5, | |
77 | ), | |
78 | 'contact_ajax_check_similar' => array( | |
79 | 'html_type' => 'checkbox', | |
80 | 'title' => ts('Check for Similar Contacts'), | |
81 | 'weight' => 5, | |
82 | ), | |
83 | 'user_dashboard_options' => array( | |
84 | 'html_type' => 'checkboxes', | |
85 | 'title' => ts('Contact Dashboard'), | |
86 | 'weight' => 6, | |
87 | ), | |
88 | 'display_name_format' => array( | |
89 | 'html_type' => 'textarea', | |
90 | 'title' => ts('Individual Display Name Format'), | |
91 | 'weight' => 7, | |
92 | ), | |
93 | 'sort_name_format' => array( | |
94 | 'html_type' => 'textarea', | |
95 | 'title' => ts('Individual Sort Name Format'), | |
96 | 'weight' => 8, | |
97 | ), | |
98 | 'editor_id' => array( | |
99 | 'html_type' => NULL, | |
100 | 'weight' => 9, | |
101 | ), | |
102 | ), | |
103 | ); | |
104 | ||
105 | ||
106 | parent::preProcess(); | |
107 | } | |
108 | ||
109 | function setDefaultValues() { | |
110 | $defaults = parent::setDefaultValues(); | |
111 | parent::cbsDefaultValues($defaults); | |
112 | ||
113 | if ($this->_config->editor_id) { | |
114 | $defaults['editor_id'] = $this->_config->editor_id; | |
115 | } | |
116 | if (empty($this->_config->display_name_format)) { | |
68679c0d KJ |
117 | $defaults['display_name_format'] = |
118 | "{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}"; | |
6a488035 TO |
119 | } |
120 | else { | |
121 | $defaults['display_name_format'] = $this->_config->display_name_format; | |
122 | } | |
123 | ||
124 | if (empty($this->_config->sort_name_format)) { | |
125 | $defaults['sort_name_format'] = "{contact.last_name}{, }{contact.first_name}"; | |
126 | } | |
127 | else { | |
128 | $defaults['sort_name_format'] = $this->_config->sort_name_format; | |
129 | } | |
130 | ||
131 | $config = CRM_Core_Config::singleton(); | |
68679c0d | 132 | if ($config->userSystem->is_drupal == '1' && module_exists("wysiwyg")) { |
6a488035 TO |
133 | $defaults['wysiwyg_input_format'] = variable_get('civicrm_wysiwyg_input_format', 0); |
134 | } | |
135 | ||
136 | return $defaults; | |
137 | } | |
138 | ||
139 | /** | |
140 | * Function to build the form | |
141 | * | |
142 | * @return None | |
143 | * @access public | |
144 | */ | |
145 | public function buildQuickForm() { | |
6a488035 TO |
146 | $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_PseudoConstant::wysiwygEditor(); |
147 | ||
148 | $config = CRM_Core_Config::singleton(); | |
149 | $extra = array(); | |
150 | ||
151 | //if not using Joomla, remove Joomla default editor option | |
152 | if ($config->userFramework != 'Joomla') { | |
153 | unset($wysiwyg_options[3]); | |
154 | } | |
155 | ||
156 | $drupal_wysiwyg = FALSE; | |
68679c0d | 157 | if (!$config->userSystem->is_drupal || !module_exists("wysiwyg")) { |
6a488035 TO |
158 | unset($wysiwyg_options[4]); |
159 | } | |
160 | else { | |
68679c0d KJ |
161 | $extra['onchange'] = ' |
162 | if (this.value==4) { | |
163 | cj("#crm-preferences-display-form-block-wysiwyg_input_format").show(); | |
164 | } | |
165 | else { | |
166 | cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide() | |
167 | }'; | |
6a488035 TO |
168 | |
169 | $formats = filter_formats(); | |
170 | $format_options = array(); | |
171 | foreach ($formats as $id => $format) { | |
172 | $format_options[$id] = $format->name; | |
173 | } | |
174 | $drupal_wysiwyg = TRUE; | |
175 | } | |
176 | $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra); | |
177 | ||
178 | if ($drupal_wysiwyg) { | |
179 | $this->addElement('select', 'wysiwyg_input_format', ts('Input Format'), $format_options, NULL); | |
180 | } | |
68679c0d | 181 | |
6a488035 TO |
182 | $editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0'); |
183 | $this->assign('editOptions', $editOptions); | |
184 | ||
185 | $contactBlocks = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1'); | |
186 | $this->assign('contactBlocks', $contactBlocks); | |
187 | ||
188 | $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences')); | |
189 | ||
190 | parent::buildQuickForm(); | |
191 | } | |
192 | ||
193 | /** | |
194 | * Function to process the form | |
195 | * | |
196 | * @access public | |
197 | * | |
198 | * @return None | |
199 | */ | |
200 | public function postProcess() { | |
201 | if ($this->_action == CRM_Core_Action::VIEW) { | |
202 | return; | |
203 | } | |
204 | ||
205 | $this->_params = $this->controller->exportValues($this->_name); | |
206 | ||
207 | if (CRM_Utils_Array::value('contact_edit_preferences', $this->_params)) { | |
208 | $preferenceWeights = explode(',', $this->_params['contact_edit_preferences']); | |
209 | foreach ($preferenceWeights as $key => $val) { | |
210 | if (!$val) { | |
211 | unset($preferenceWeights[$key]); | |
212 | } | |
213 | } | |
214 | $opGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name'); | |
215 | CRM_Core_BAO_OptionValue::updateOptionWeights($opGroupId, array_flip($preferenceWeights)); | |
216 | } | |
217 | ||
218 | $config = CRM_Core_Config::singleton(); | |
68679c0d | 219 | if ($config->userSystem->is_drupal == '1' && module_exists("wysiwyg")) { |
6a488035 TO |
220 | variable_set('civicrm_wysiwyg_input_format', $this->_params['wysiwyg_input_format']); |
221 | } | |
222 | ||
223 | $this->_config->editor_id = $this->_params['editor_id']; | |
224 | ||
225 | // set default editor to session if changed | |
226 | $session = CRM_Core_Session::singleton(); | |
227 | $session->set('defaultWysiwygEditor', $this->_params['editor_id']); | |
228 | ||
229 | $this->postProcessCommon(); | |
230 | } | |
231 | //end of function | |
232 | } | |
233 |