3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 public 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 public 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
149 public function buildQuickForm() {
150 $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_OptionGroup
::values('wysiwyg_editor');
152 //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
153 $invoiceSettings = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
154 $invoicing = CRM_Utils_Array
::value('invoicing', $invoiceSettings);
155 $this->assign('invoicing', $invoicing);
156 $config = CRM_Core_Config
::singleton();
159 //if not using Joomla, remove Joomla default editor option
160 if ($config->userFramework
!= 'Joomla') {
161 unset($wysiwyg_options[3]);
164 $drupal_wysiwyg = FALSE;
165 if (!$config->userSystem
->is_drupal ||
!module_exists("wysiwyg")) {
166 unset($wysiwyg_options[4]);
169 $extra['onchange'] = '
171 cj("#crm-preferences-display-form-block-wysiwyg_input_format").show();
174 cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide()
177 $formats = filter_formats();
178 $format_options = array();
179 foreach ($formats as $id => $format) {
180 $format_options[$id] = $format->name
;
182 $drupal_wysiwyg = TRUE;
184 $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra);
186 if ($drupal_wysiwyg) {
187 $this->addElement('select', 'wysiwyg_input_format', ts('Input Format'), $format_options, NULL);
190 $editOptions = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
191 $this->assign('editOptions', $editOptions);
193 $contactBlocks = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1');
194 $this->assign('contactBlocks', $contactBlocks);
196 $nameFields = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2');
197 $this->assign('nameFields', $nameFields);
199 $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences'));
201 $optionValues = CRM_Core_OptionGroup
::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
202 $invoicesKey = array_search('Invoices / Credit Notes', $optionValues);
203 $this->assign('invoicesKey', $invoicesKey);
204 parent
::buildQuickForm();
208 * Process the form submission
213 public function postProcess() {
214 if ($this->_action
== CRM_Core_Action
::VIEW
) {
218 $this->_params
= $this->controller
->exportValues($this->_name
);
220 if (!empty($this->_params
['contact_edit_preferences'])) {
221 $preferenceWeights = explode(',', $this->_params
['contact_edit_preferences']);
222 foreach ($preferenceWeights as $key => $val) {
224 unset($preferenceWeights[$key]);
227 $opGroupId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name');
228 CRM_Core_BAO_OptionValue
::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
231 $config = CRM_Core_Config
::singleton();
232 if ($config->userSystem
->is_drupal
== '1' && module_exists("wysiwyg")) {
233 variable_set('civicrm_wysiwyg_input_format', $this->_params
['wysiwyg_input_format']);
236 $this->_config
->editor_id
= $this->_params
['editor_id'];
238 // set default editor to session if changed
239 $session = CRM_Core_Session
::singleton();
240 $session->set('defaultWysiwygEditor', $this->_params
['editor_id']);
242 $this->postProcessCommon();