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
=>
47 'contact_view_options' => array(
48 'html_type' => 'checkboxes',
49 'title' => ts('Viewing Contacts'),
52 'contact_smart_group_display' => array(
53 'html_type' => 'radio',
54 'title' => ts('Viewing Smart Groups'),
57 'contact_edit_options' => array(
58 'html_type' => 'checkboxes',
59 'title' => ts('Editing Contacts'),
62 'advanced_search_options' => array(
63 'html_type' => 'checkboxes',
64 'title' => ts('Contact Search'),
67 'activity_assignee_notification' => array(
68 'html_type' => 'checkbox',
69 'title' => ts('Notify Activity Assignees'),
72 'activity_assignee_notification_ics' => array(
73 'html_type' => 'checkbox',
74 'title' => ts('Include ICal Invite to Activity Assignees'),
77 'contact_ajax_check_similar' => array(
78 'html_type' => 'checkbox',
79 'title' => ts('Check for Similar Contacts'),
82 'user_dashboard_options' => array(
83 'html_type' => 'checkboxes',
84 'title' => ts('Contact Dashboard'),
87 'display_name_format' => array(
88 'html_type' => 'textarea',
89 'title' => ts('Individual Display Name Format'),
92 'sort_name_format' => array(
93 'html_type' => 'textarea',
94 'title' => ts('Individual Sort Name Format'),
101 'ajaxPopupsEnabled' => array(
102 'html_type' => 'checkbox',
103 'title' => ts('Enable Popup Forms'),
109 parent
::preProcess();
115 function setDefaultValues() {
116 $defaults = parent
::setDefaultValues();
117 parent
::cbsDefaultValues($defaults);
119 if ($this->_config
->editor_id
) {
120 $defaults['editor_id'] = $this->_config
->editor_id
;
122 if (empty($this->_config
->display_name_format
)) {
123 $defaults['display_name_format'] =
124 "{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}";
127 $defaults['display_name_format'] = $this->_config
->display_name_format
;
130 if (empty($this->_config
->sort_name_format
)) {
131 $defaults['sort_name_format'] = "{contact.last_name}{, }{contact.first_name}";
134 $defaults['sort_name_format'] = $this->_config
->sort_name_format
;
137 $config = CRM_Core_Config
::singleton();
138 if ($config->userSystem
->is_drupal
== '1' && module_exists("wysiwyg")) {
139 $defaults['wysiwyg_input_format'] = variable_get('civicrm_wysiwyg_input_format', 0);
146 * Function to build the form
151 public function buildQuickForm() {
152 $wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_OptionGroup
::values('wysiwyg_editor');
154 //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
155 $invoiceSettings = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::CONTRIBUTE_PREFERENCES_NAME
, 'contribution_invoice_settings');
156 $invoicing = CRM_Utils_Array
::value('invoicing', $invoiceSettings);
157 $this->assign('invoicing', $invoicing);
158 $config = CRM_Core_Config
::singleton();
161 //if not using Joomla, remove Joomla default editor option
162 if ($config->userFramework
!= 'Joomla') {
163 unset($wysiwyg_options[3]);
166 $drupal_wysiwyg = FALSE;
167 if (!$config->userSystem
->is_drupal ||
!module_exists("wysiwyg")) {
168 unset($wysiwyg_options[4]);
171 $extra['onchange'] = '
173 cj("#crm-preferences-display-form-block-wysiwyg_input_format").show();
176 cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide()
179 $formats = filter_formats();
180 $format_options = array();
181 foreach ($formats as $id => $format) {
182 $format_options[$id] = $format->name
;
184 $drupal_wysiwyg = TRUE;
186 $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra);
188 if ($drupal_wysiwyg) {
189 $this->addElement('select', 'wysiwyg_input_format', ts('Input Format'), $format_options, NULL);
192 $editOptions = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
193 $this->assign('editOptions', $editOptions);
195 $contactBlocks = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 1');
196 $this->assign('contactBlocks', $contactBlocks);
198 $nameFields = CRM_Core_OptionGroup
::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2');
199 $this->assign('nameFields', $nameFields);
201 $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences'));
203 $optionValues = CRM_Core_OptionGroup
::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
204 $invoicesKey = array_search('Invoices / Credit Notes', $optionValues);
205 $this->assign('invoicesKey', $invoicesKey);
206 parent
::buildQuickForm();
210 * Function to process the form
216 public function postProcess() {
217 if ($this->_action
== CRM_Core_Action
::VIEW
) {
221 $this->_params
= $this->controller
->exportValues($this->_name
);
223 if (!empty($this->_params
['contact_edit_preferences'])) {
224 $preferenceWeights = explode(',', $this->_params
['contact_edit_preferences']);
225 foreach ($preferenceWeights as $key => $val) {
227 unset($preferenceWeights[$key]);
230 $opGroupId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name');
231 CRM_Core_BAO_OptionValue
::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
234 $config = CRM_Core_Config
::singleton();
235 if ($config->userSystem
->is_drupal
== '1' && module_exists("wysiwyg")) {
236 variable_set('civicrm_wysiwyg_input_format', $this->_params
['wysiwyg_input_format']);
239 $this->_config
->editor_id
= $this->_params
['editor_id'];
241 // set default editor to session if changed
242 $session = CRM_Core_Session
::singleton();
243 $session->set('defaultWysiwygEditor', $this->_params
['editor_id']);
245 $this->postProcessCommon();