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
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 'empoweredBy' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
48 'maxFileSize' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
49 'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
50 'secondDegRelPermissions' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
54 * Function to build the form
59 public function buildQuickForm() {
60 CRM_Utils_System
::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
62 // also check if we can enable triggers
63 $validTriggerPermission = CRM_Core_DAO
::checkTriggerViewPermission(FALSE);
65 // FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted
66 $domain = new CRM_Core_DAO_Domain
;
68 $attribs = $domain->locales ||
!$validTriggerPermission ?
69 array('disabled' => 'disabled') : array();
71 $this->assign('validTriggerPermission', $validTriggerPermission);
72 $this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs);
76 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'),
77 array('size' => 64, 'maxlength' => 256)
81 'text', 'recaptchaPublicKey', ts('Public Key'),
82 array('size' => 64, 'maxlength' => 64)
85 'text', 'recaptchaPrivateKey', ts('Private Key'),
86 array('size' => 64, 'maxlength' => 64)
90 'text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'),
91 array('size' => 3, 'maxlength' => 5)
94 'text', 'checksumTimeout', ts('CheckSum Lifespan'),
95 array('size' => 2, 'maxlength' => 8)
98 'text', 'recaptchaOptions', ts('Recaptcha Options'),
99 array('size' => 64, 'maxlength' => 64)
102 $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger');
104 $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
106 parent
::buildQuickForm();
112 * @param array $fields the input form values
113 * @param array $files the uploaded files if any
114 * @param array $options additional user data
116 * @return true if no errors, else array of errors
120 static function formRule($fields, $files, $options) {
123 if (!empty($fields['wkhtmltopdfPath'])) {
124 // check and ensure that thi leads to the wkhtmltopdf binary
125 // and it is a valid executable binary
126 // Only check the first space separated piece to allow for a value
127 // such as /usr/bin/xvfb-run -- wkhtmltopdf (CRM-13292)
128 $pieces = explode(' ', $fields['wkhtmltopdfPath']);
131 !file_exists($path) ||
132 !is_executable($path)
134 $errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid');
140 function setDefaultValues() {
141 parent
::setDefaultValues();
143 $this->_defaults
['checksumTimeout'] =
144 CRM_Core_BAO_Setting
::getItem(
145 CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
150 return $this->_defaults
;
153 public function postProcess() {
154 // store the submitted values in an array
155 $config = CRM_Core_Config
::singleton();
156 $params = $this->controller
->exportValues($this->_name
);
158 // get current logging status
159 $values = $this->exportValues();
161 parent
::postProcess();
163 if ($config->logging
!= $values['logging']) {
164 $logging = new CRM_Logging_Schema
;
165 if ($values['logging']) {
166 $logging->enableLogging();
169 $logging->disableLogging();