Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
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 | ||
6a488035 TO |
44 | $this->_varNames = array( |
45 | CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => | |
46 | array( | |
47 | 'contact_view_options' => array( | |
48 | 'html_type' => 'checkboxes', | |
49 | 'title' => ts('Viewing Contacts'), | |
50 | 'weight' => 1, | |
51 | ), | |
65f9bd70 KJ |
52 | 'contact_smart_group_display' => array( |
53 | 'html_type' => 'radio', | |
54 | 'title' => ts('Viewing Smart Groups'), | |
55 | 'weight' => 2, | |
56 | ), | |
6a488035 TO |
57 | 'contact_edit_options' => array( |
58 | 'html_type' => 'checkboxes', | |
59 | 'title' => ts('Editing Contacts'), | |
65f9bd70 | 60 | 'weight' => 3, |
6a488035 TO |
61 | ), |
62 | 'advanced_search_options' => array( | |
63 | 'html_type' => 'checkboxes', | |
64 | 'title' => ts('Contact Search'), | |
65f9bd70 | 65 | 'weight' => 4, |
6a488035 TO |
66 | ), |
67 | 'activity_assignee_notification' => array( | |
68 | 'html_type' => 'checkbox', | |
69 | 'title' => ts('Notify Activity Assignees'), | |
70 | 'weight' => 5, | |
71 | ), | |
72 | 'activity_assignee_notification_ics' => array( | |
73 | 'html_type' => 'checkbox', | |
74 | 'title' => ts('Include ICal Invite to Activity Assignees'), | |
65f9bd70 | 75 | 'weight' => 6, |
6a488035 TO |
76 | ), |
77 | 'contact_ajax_check_similar' => array( | |
78 | 'html_type' => 'checkbox', | |
79 | 'title' => ts('Check for Similar Contacts'), | |
65f9bd70 | 80 | 'weight' => 7, |
6a488035 TO |
81 | ), |
82 | 'user_dashboard_options' => array( | |
83 | 'html_type' => 'checkboxes', | |
84 | 'title' => ts('Contact Dashboard'), | |
65f9bd70 | 85 | 'weight' => 8, |
6a488035 TO |
86 | ), |
87 | 'display_name_format' => array( | |
88 | 'html_type' => 'textarea', | |
89 | 'title' => ts('Individual Display Name Format'), | |
65f9bd70 | 90 | 'weight' => 9, |
6a488035 TO |
91 | ), |
92 | 'sort_name_format' => array( | |
93 | 'html_type' => 'textarea', | |
94 | 'title' => ts('Individual Sort Name Format'), | |
65f9bd70 | 95 | 'weight' => 10, |
6a488035 TO |
96 | ), |
97 | 'editor_id' => array( | |
98 | 'html_type' => NULL, | |
65f9bd70 | 99 | 'weight' => 11, |
6a488035 | 100 | ), |
53f2643c | 101 | 'ajaxPopupsEnabled' => array( |
f1cf499b CW |
102 | 'html_type' => 'checkbox', |
103 | 'title' => ts('Enable Popup Forms'), | |
104 | 'weight' => 12, | |
105 | ), | |
6a488035 TO |
106 | ), |
107 | ); | |
108 | ||
6a488035 TO |
109 | parent::preProcess(); |
110 | } | |
111 | ||
112 | function setDefaultValues() { | |
113 | $defaults = parent::setDefaultValues(); | |
114 | parent::cbsDefaultValues($defaults); | |
115 | ||
116 | if ($this->_config->editor_id) { | |
117 | $defaults['editor_id'] = $this->_config->editor_id; | |
118 | } | |
119 | if (empty($this->_config->display_name_format)) { | |
68679c0d KJ |
120 | $defaults['display_name_format'] = |
121 | "{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}"; | |
6a488035 TO |
122 | } |
123 | else { | |
124 | $defaults['display_name_format'] = $this->_config->display_name_format; | |
125 | } | |
126 | ||
127 | if (empty($this->_config->sort_name_format)) { | |
128 | $defaults['sort_name_format'] = "{contact.last_name}{, }{contact.first_name}"; | |
129 | } | |
130 | else { | |
131 | $defaults['sort_name_format'] = $this->_config->sort_name_format; | |
132 | } | |
133 | ||
134 | $config = CRM_Core_Config::singleton(); | |
68679c0d | 135 | if ($config->userSystem->is_drupal == '1' && module_exists("wysiwyg")) { |
6a488035 TO |
136 | $defaults['wysiwyg_input_format'] = variable_get('civicrm_wysiwyg_input_format', 0); |
137 | } | |
138 | ||
139 | return $defaults; | |
140 | } | |
141 | ||
142 | /** | |
143 | * Function to build the form | |
144 | * | |
355ba699 | 145 | * @return void |
6a488035 TO |
146 | * @access public |
147 | */ | |
148 | public function buildQuickForm() { | |
cbf48754 | 149 | $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_OptionGroup::values('wysiwyg_editor'); |
6a488035 TO |
150 | |
151 | $config = CRM_Core_Config::singleton(); | |
152 | $extra = array(); | |
153 | ||
154 | //if not using Joomla, remove Joomla default editor option | |
155 | if ($config->userFramework != 'Joomla') { | |
156 | unset($wysiwyg_options[3]); | |
157 | } | |
158 | ||
159 | $drupal_wysiwyg = FALSE; | |
68679c0d | 160 | if (!$config->userSystem->is_drupal || !module_exists("wysiwyg")) { |
6a488035 TO |
161 | unset($wysiwyg_options[4]); |
162 | } | |
163 | else { | |
68679c0d KJ |
164 | $extra['onchange'] = ' |
165 | if (this.value==4) { | |
166 | cj("#crm-preferences-display-form-block-wysiwyg_input_format").show(); | |
167 | } | |
168 | else { | |
169 | cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide() | |
170 | }'; | |
6a488035 TO |
171 | |
172 | $formats = filter_formats(); | |
173 | $format_options = array(); | |
174 | foreach ($formats as $id => $format) { | |
175 | $format_options[$id] = $format->name; | |
176 | } | |
177 | $drupal_wysiwyg = TRUE; | |
178 | } | |
179 | $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra); | |
180 | ||
181 | if ($drupal_wysiwyg) { | |
182 | $this->addElement('select', 'wysiwyg_input_format', ts('Input Format'), $format_options, NULL); | |
183 | } | |
68679c0d | 184 | |
6a488035 TO |
185 | $editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0'); |
186 | $this->assign('editOptions', $editOptions); | |
187 | ||
188 | $contactBlocks = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1'); | |
189 | $this->assign('contactBlocks', $contactBlocks); | |
190 | ||
8b49cb50 OB |
191 | $nameFields = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2'); |
192 | $this->assign('nameFields', $nameFields); | |
193 | ||
6a488035 TO |
194 | $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences')); |
195 | ||
196 | parent::buildQuickForm(); | |
197 | } | |
198 | ||
199 | /** | |
200 | * Function to process the form | |
201 | * | |
202 | * @access public | |
203 | * | |
355ba699 | 204 | * @return void |
6a488035 TO |
205 | */ |
206 | public function postProcess() { | |
207 | if ($this->_action == CRM_Core_Action::VIEW) { | |
208 | return; | |
209 | } | |
210 | ||
211 | $this->_params = $this->controller->exportValues($this->_name); | |
212 | ||
a7488080 | 213 | if (!empty($this->_params['contact_edit_preferences'])) { |
6a488035 TO |
214 | $preferenceWeights = explode(',', $this->_params['contact_edit_preferences']); |
215 | foreach ($preferenceWeights as $key => $val) { | |
216 | if (!$val) { | |
217 | unset($preferenceWeights[$key]); | |
218 | } | |
219 | } | |
220 | $opGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name'); | |
221 | CRM_Core_BAO_OptionValue::updateOptionWeights($opGroupId, array_flip($preferenceWeights)); | |
222 | } | |
223 | ||
224 | $config = CRM_Core_Config::singleton(); | |
68679c0d | 225 | if ($config->userSystem->is_drupal == '1' && module_exists("wysiwyg")) { |
6a488035 TO |
226 | variable_set('civicrm_wysiwyg_input_format', $this->_params['wysiwyg_input_format']); |
227 | } | |
228 | ||
229 | $this->_config->editor_id = $this->_params['editor_id']; | |
230 | ||
231 | // set default editor to session if changed | |
232 | $session = CRM_Core_Session::singleton(); | |
233 | $session->set('defaultWysiwygEditor', $this->_params['editor_id']); | |
234 | ||
235 | $this->postProcessCommon(); | |
236 | } | |
237 | //end of function | |
238 | } | |
239 |