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
37 * This class generates form components for Miscellaneous
40 class CRM_Admin_Form_Setting_Miscellaneous
extends CRM_Admin_Form_Setting
{
42 protected $_settings = array(
43 'max_attachments' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
44 'contact_undelete' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
45 'versionAlert' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
46 'securityUpdateAlert' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
47 'versionCheck' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
48 'versionCheckIgnoreDate' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
49 'empoweredBy' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
50 'maxFileSize' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
51 'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
52 'secondDegRelPermissions' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
53 'checksumTimeout' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
56 public $_uploadMaxSize;
62 public function preProcess() {
63 $config = CRM_Core_Config
::singleton();
64 $this->_uploadMaxSize
= (int) ini_get('upload_max_filesize');
65 // check for post max size
66 CRM_Core_Config_Defaults
::formatUnitSize(ini_get('post_max_size'), TRUE);
70 * Build the form object
74 public function buildQuickForm() {
75 CRM_Utils_System
::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
77 // also check if we can enable triggers
78 $validTriggerPermission = CRM_Core_DAO
::checkTriggerViewPermission(FALSE);
80 // FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted
81 $domain = new CRM_Core_DAO_Domain
;
83 $attribs = $domain->locales ||
!$validTriggerPermission ?
84 array('disabled' => 'disabled') : array();
86 $this->assign('validTriggerPermission', $validTriggerPermission);
87 $this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs);
91 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'),
92 array('size' => 64, 'maxlength' => 256)
96 'text', 'recaptchaPublicKey', ts('Public Key'),
97 array('size' => 64, 'maxlength' => 64)
100 'text', 'recaptchaPrivateKey', ts('Private Key'),
101 array('size' => 64, 'maxlength' => 64)
105 'text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'),
106 array('size' => 3, 'maxlength' => 5)
110 'text', 'recaptchaOptions', ts('Recaptcha Options'),
111 array('size' => 64, 'maxlength' => 64)
114 $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
116 parent
::buildQuickForm();
117 $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger');
123 * @param array $fields the input form values
124 * @param array $files the uploaded files if any
125 * @param array $options additional user data
127 * @return true if no errors, else array of errors
130 public static function formRule($fields, $files, $options) {
133 // validate max file size
134 if ($fields['maxFileSize'] > $options->_uploadMaxSize
) {
135 $errors['maxFileSize'] = ts("Maximum file size cannot exceed Upload max size ('upload_max_filesize') as defined in PHP.ini.");
138 if (!empty($fields['wkhtmltopdfPath'])) {
139 // check and ensure that thi leads to the wkhtmltopdf binary
140 // and it is a valid executable binary
141 // Only check the first space separated piece to allow for a value
142 // such as /usr/bin/xvfb-run -- wkhtmltopdf (CRM-13292)
143 $pieces = explode(' ', $fields['wkhtmltopdfPath']);
146 !file_exists($path) ||
147 !is_executable($path)
149 $errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid');
156 public function postProcess() {
157 // store the submitted values in an array
158 $config = CRM_Core_Config
::singleton();
159 $params = $this->controller
->exportValues($this->_name
);
161 // update upload max size in $config
162 // Fixme: why are we storing this php setting in $config?
163 $hiddenSettings = array(
164 'maxImportFileSize' => CRM_Core_Config_Defaults
::formatUnitSize(ini_get('upload_max_filesize'))
166 CRM_Core_BAO_ConfigSetting
::create($hiddenSettings);
168 // get current logging status
169 $values = $this->exportValues();
171 parent
::postProcess();
173 if ($config->logging
!= $values['logging']) {
174 $logging = new CRM_Logging_Schema
;
175 if ($values['logging']) {
176 $logging->enableLogging();
179 $logging->disableLogging();