3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
32 * $Id: Display.php 45499 2013-02-08 12:31:05Z kurund $
37 * This class generates form components for the display preferences
40 class CRM_Admin_Form_Preferences_Display
extends CRM_Admin_Form_Preferences
{
41 function preProcess() {
42 CRM_Utils_System
::setTitle(ts('Settings - Display Preferences'));
44 if (defined('CIVICRM_ACTIVITY_ASSIGNEE_MAIL') && CIVICRM_ACTIVITY_ASSIGNEE_MAIL
) {
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");
50 $this->_varNames
= array(
51 CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
=>
53 'contact_view_options' => array(
54 'html_type' => 'checkboxes',
55 'title' => ts('Viewing Contacts'),
58 'contact_smart_group_display' => array(
59 'html_type' => 'radio',
60 'title' => ts('Viewing Smart Groups'),
63 'contact_edit_options' => array(
64 'html_type' => 'checkboxes',
65 'title' => ts('Editing Contacts'),
68 'advanced_search_options' => array(
69 'html_type' => 'checkboxes',
70 'title' => ts('Contact Search'),
73 'activity_assignee_notification' => array(
74 'html_type' => 'checkbox',
75 'title' => ts('Notify Activity Assignees'),
78 'activity_assignee_notification_ics' => array(
79 'html_type' => 'checkbox',
80 'title' => ts('Include ICal Invite to Activity Assignees'),
83 'contact_ajax_check_similar' => array(
84 'html_type' => 'checkbox',
85 'title' => ts('Check for Similar Contacts'),
88 'user_dashboard_options' => array(
89 'html_type' => 'checkboxes',
90 'title' => ts('Contact Dashboard'),
93 'display_name_format' => array(
94 'html_type' => 'textarea',
95 'title' => ts('Individual Display Name Format'),
98 'sort_name_format' => array(
99 'html_type' => 'textarea',
100 'title' => ts('Individual Sort Name Format'),
103 'editor_id' => array(
110 parent
::preProcess();
113 function setDefaultValues() {
114 $defaults = parent
::setDefaultValues();
115 parent
::cbsDefaultValues($defaults);
117 if ($this->_config
->editor_id
) {
118 $defaults['editor_id'] = $this->_config
->editor_id
;
120 if (empty($this->_config
->display_name_format
)) {
121 $defaults['display_name_format'] =
122 "{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}";
125 $defaults['display_name_format'] = $this->_config
->display_name_format
;
128 if (empty($this->_config
->sort_name_format
)) {
129 $defaults['sort_name_format'] = "{contact.last_name}{, }{contact.first_name}";
132 $defaults['sort_name_format'] = $this->_config
->sort_name_format
;
135 $config = CRM_Core_Config
::singleton();
136 if ($config->userSystem
->is_drupal
== '1' && module_exists("wysiwyg")) {
137 $defaults['wysiwyg_input_format'] = variable_get('civicrm_wysiwyg_input_format', 0);
144 * Function to build the form
149 public function buildQuickForm() {
150 $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_OptionGroup
::values('wysiwyg_editor');
152 $config = CRM_Core_Config
::singleton();
155 //if not using Joomla, remove Joomla default editor option
156 if ($config->userFramework
!= 'Joomla') {
157 unset($wysiwyg_options[3]);
160 $drupal_wysiwyg = FALSE;
161 if (!$config->userSystem
->is_drupal ||
!module_exists("wysiwyg")) {
162 unset($wysiwyg_options[4]);
165 $extra['onchange'] = '
167 cj("#crm-preferences-display-form-block-wysiwyg_input_format").show();
170 cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide()
173 $formats = filter_formats();
174 $format_options = array();
175 foreach ($formats as $id => $format) {
176 $format_options[$id] = $format->name
;
178 $drupal_wysiwyg = TRUE;
180 $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra);
182 if ($drupal_wysiwyg) {
183 $this->addElement('select', 'wysiwyg_input_format', ts('Input Format'), $format_options, NULL);
186 $editOptions = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
187 $this->assign('editOptions', $editOptions);
189 $contactBlocks = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1');
190 $this->assign('contactBlocks', $contactBlocks);
192 $nameFields = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2');
193 $this->assign('nameFields', $nameFields);
195 $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences'));
197 parent
::buildQuickForm();
201 * Function to process the form
207 public function postProcess() {
208 if ($this->_action
== CRM_Core_Action
::VIEW
) {
212 $this->_params
= $this->controller
->exportValues($this->_name
);
214 if (!empty($this->_params
['contact_edit_preferences'])) {
215 $preferenceWeights = explode(',', $this->_params
['contact_edit_preferences']);
216 foreach ($preferenceWeights as $key => $val) {
218 unset($preferenceWeights[$key]);
221 $opGroupId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name');
222 CRM_Core_BAO_OptionValue
::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
225 $config = CRM_Core_Config
::singleton();
226 if ($config->userSystem
->is_drupal
== '1' && module_exists("wysiwyg")) {
227 variable_set('civicrm_wysiwyg_input_format', $this->_params
['wysiwyg_input_format']);
230 $this->_config
->editor_id
= $this->_params
['editor_id'];
232 // set default editor to session if changed
233 $session = CRM_Core_Session
::singleton();
234 $session->set('defaultWysiwygEditor', $this->_params
['editor_id']);
236 $this->postProcessCommon();