3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
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 $this->_varNames
= array(
45 CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
=> array(
46 'contact_view_options' => array(
47 'html_type' => 'checkboxes',
48 'title' => ts('Viewing Contacts'),
51 'contact_smart_group_display' => array(
52 'html_type' => 'radio',
53 'title' => ts('Viewing Smart Groups'),
56 'contact_edit_options' => array(
57 'html_type' => 'checkboxes',
58 'title' => ts('Editing Contacts'),
61 'advanced_search_options' => array(
62 'html_type' => 'checkboxes',
63 'title' => ts('Contact Search'),
66 'activity_assignee_notification' => array(
67 'html_type' => 'checkbox',
68 'title' => ts('Notify Activity Assignees'),
71 'activity_assignee_notification_ics' => array(
72 'html_type' => 'checkbox',
73 'title' => ts('Include ICal Invite to Activity Assignees'),
76 'contact_ajax_check_similar' => array(
77 'html_type' => 'checkbox',
78 'title' => ts('Check for Similar Contacts'),
81 'user_dashboard_options' => array(
82 'html_type' => 'checkboxes',
83 'title' => ts('Contact Dashboard'),
86 'display_name_format' => array(
87 'html_type' => 'textarea',
88 'title' => ts('Individual Display Name Format'),
91 'sort_name_format' => array(
92 'html_type' => 'textarea',
93 'title' => ts('Individual Sort Name Format'),
100 'ajaxPopupsEnabled' => array(
101 'html_type' => 'checkbox',
102 'title' => ts('Enable Popup Forms'),
108 parent
::preProcess();
114 function setDefaultValues() {
115 $defaults = parent
::setDefaultValues();
116 parent
::cbsDefaultValues($defaults);
118 if ($this->_config
->editor_id
) {
119 $defaults['editor_id'] = $this->_config
->editor_id
;
121 if (empty($this->_config
->display_name_format
)) {
122 $defaults['display_name_format'] =
123 "{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}";
126 $defaults['display_name_format'] = $this->_config
->display_name_format
;
129 if (empty($this->_config
->sort_name_format
)) {
130 $defaults['sort_name_format'] = "{contact.last_name}{, }{contact.first_name}";
133 $defaults['sort_name_format'] = $this->_config
->sort_name_format
;
136 $config = CRM_Core_Config
::singleton();
137 if ($config->userSystem
->is_drupal
== '1' && module_exists("wysiwyg")) {
138 $defaults['wysiwyg_input_format'] = variable_get('civicrm_wysiwyg_input_format', 0);
145 * Build the form object
150 public function buildQuickForm() {
151 $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_OptionGroup
::values('wysiwyg_editor');
153 //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
154 $invoiceSettings = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
155 $invoicing = CRM_Utils_Array
::value('invoicing', $invoiceSettings);
156 $this->assign('invoicing', $invoicing);
157 $config = CRM_Core_Config
::singleton();
160 //if not using Joomla, remove Joomla default editor option
161 if ($config->userFramework
!= 'Joomla') {
162 unset($wysiwyg_options[3]);
165 $drupal_wysiwyg = FALSE;
166 if (!$config->userSystem
->is_drupal ||
!module_exists("wysiwyg")) {
167 unset($wysiwyg_options[4]);
170 $extra['onchange'] = '
172 cj("#crm-preferences-display-form-block-wysiwyg_input_format").show();
175 cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide()
178 $formats = filter_formats();
179 $format_options = array();
180 foreach ($formats as $id => $format) {
181 $format_options[$id] = $format->name
;
183 $drupal_wysiwyg = TRUE;
185 $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra);
187 if ($drupal_wysiwyg) {
188 $this->addElement('select', 'wysiwyg_input_format', ts('Input Format'), $format_options, NULL);
191 $editOptions = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
192 $this->assign('editOptions', $editOptions);
194 $contactBlocks = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1');
195 $this->assign('contactBlocks', $contactBlocks);
197 $nameFields = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2');
198 $this->assign('nameFields', $nameFields);
200 $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences'));
202 $optionValues = CRM_Core_OptionGroup
::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
203 $invoicesKey = array_search('Invoices / Credit Notes', $optionValues);
204 $this->assign('invoicesKey', $invoicesKey);
205 parent
::buildQuickForm();
209 * Process the form submission
215 public function postProcess() {
216 if ($this->_action
== CRM_Core_Action
::VIEW
) {
220 $this->_params
= $this->controller
->exportValues($this->_name
);
222 if (!empty($this->_params
['contact_edit_preferences'])) {
223 $preferenceWeights = explode(',', $this->_params
['contact_edit_preferences']);
224 foreach ($preferenceWeights as $key => $val) {
226 unset($preferenceWeights[$key]);
229 $opGroupId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name');
230 CRM_Core_BAO_OptionValue
::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
233 $config = CRM_Core_Config
::singleton();
234 if ($config->userSystem
->is_drupal
== '1' && module_exists("wysiwyg")) {
235 variable_set('civicrm_wysiwyg_input_format', $this->_params
['wysiwyg_input_format']);
238 $this->_config
->editor_id
= $this->_params
['editor_id'];
240 // set default editor to session if changed
241 $session = CRM_Core_Session
::singleton();
242 $session->set('defaultWysiwygEditor', $this->_params
['editor_id']);
244 $this->postProcessCommon();