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
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 'versionCheck' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
47 'maxFileSize' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
48 'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
49 'secondDegRelPermissions' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
53 * Function to build the form
58 public function buildQuickForm() {
59 CRM_Utils_System
::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
61 // also check if we can enable triggers
62 $validTriggerPermission = CRM_Core_DAO
::checkTriggerViewPermission(FALSE);
64 // FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted
65 $domain = new CRM_Core_DAO_Domain
;
67 $attribs = $domain->locales ||
!$validTriggerPermission ?
68 array('disabled' => 'disabled') : NULL;
70 $this->assign('validTriggerPermission', $validTriggerPermission);
71 $this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs);
75 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'),
76 array('size' => 64, 'maxlength' => 256)
80 'text', 'recaptchaPublicKey', ts('Public Key'),
81 array('size' => 64, 'maxlength' => 64)
84 'text', 'recaptchaPrivateKey', ts('Private Key'),
85 array('size' => 64, 'maxlength' => 64)
89 'text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'),
90 array('size' => 3, 'maxlength' => 5)
93 'text', 'checksumTimeout', ts('CheckSum Lifespan'),
94 array('size' => 2, 'maxlength' => 8)
97 'text', 'recaptchaOptions', ts('Recaptcha Options'),
98 array('size' => 64, 'maxlength' => 64)
101 $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger');
103 $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
105 parent
::buildQuickForm();
111 * @param array $fields the input form values
112 * @param array $files the uploaded files if any
113 * @param array $options additional user data
115 * @return true if no errors, else array of errors
119 static function formRule($fields, $files, $options) {
122 if (!empty($fields['wkhtmltopdfPath'])) {
123 // check and ensure that thi leads to the wkhtmltopdf binary
124 // and it is a valid executable binary
125 // Only check the first space separated piece to allow for a value
126 // such as /usr/bin/xvfb-run -- wkhtmltopdf (CRM-13292)
127 $pieces = explode(' ', $fields['wkhtmltopdfPath']);
130 !file_exists($path) ||
131 !is_executable($path)
133 $errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid');
139 function setDefaultValues() {
140 parent
::setDefaultValues();
142 $this->_defaults
['checksumTimeout'] =
143 CRM_Core_BAO_Setting
::getItem(
144 CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
149 return $this->_defaults
;
152 public function postProcess() {
153 // store the submitted values in an array
154 $config = CRM_Core_Config
::singleton();
155 $params = $this->controller
->exportValues($this->_name
);
157 // get current logging status
158 $values = $this->exportValues();
160 parent
::postProcess();
162 if ($config->logging
!= $values['logging']) {
163 $logging = new CRM_Logging_Schema
;
164 if ($values['logging']) {
165 $logging->enableLogging();
168 $logging->disableLogging();