3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class generates form components for Miscellaneous.
21 class CRM_Admin_Form_Setting_Miscellaneous
extends CRM_Admin_Form_Setting
{
23 protected $_settings = [
24 'max_attachments' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
25 'max_attachments_backend' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
26 'contact_undelete' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
27 'empoweredBy' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
28 'logging' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
29 'maxFileSize' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
30 'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
31 'recordGeneratedLetters' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
32 'secondDegRelPermissions' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
33 'checksum_timeout' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
34 'recaptchaOptions' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
35 'recaptchaPublicKey' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
36 'recaptchaPrivateKey' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
37 'forceRecaptcha' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
38 'wkhtmltopdfPath' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
39 'recentItemsMaxCount' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
40 'recentItemsProviders' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
41 'dedupe_default_limit' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
42 'remote_profile_submissions' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
43 'allow_alert_autodismissal' => CRM_Core_BAO_Setting
::SYSTEM_PREFERENCES_NAME
,
44 'prevNextBackend' => CRM_Core_BAO_Setting
::SEARCH_PREFERENCES_NAME
,
47 public $_uploadMaxSize;
52 public function preProcess() {
53 $this->_uploadMaxSize
= (int) ini_get('upload_max_filesize');
54 // check for post max size
55 CRM_Utils_Number
::formatUnitSize(ini_get('post_max_size'), TRUE);
56 // This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but
57 // we haven't worked through NOT doing that. These settings have been un-hardcoded.
58 $this->assign('pure_config_settings', [
61 'max_attachments_backend',
63 'secondDegRelPermissions',
64 'recentItemsMaxCount',
65 'recentItemsProviders',
66 'dedupe_default_limit',
72 * Build the form object.
74 public function buildQuickForm() {
75 CRM_Utils_System
::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'));
77 $this->assign('validTriggerPermission', CRM_Core_DAO
::checkTriggerViewPermission(FALSE));
78 // dev/core#1812 Assign multilingual status.
79 $this->assign('isMultilingual', CRM_Core_I18n
::isMultilingual());
81 $this->addFormRule(['CRM_Admin_Form_Setting_Miscellaneous', 'formRule'], $this);
83 parent
::buildQuickForm();
84 $this->addRule('checksum_timeout', ts('Value should be a positive number'), 'positiveInteger');
90 * @param array $fields
91 * The input form values.
93 * The uploaded files if any.
94 * @param array $options
95 * Additional user data.
98 * true if no errors, else array of errors
100 public static function formRule($fields, $files, $options) {
103 // validate max file size
104 if ($fields['maxFileSize'] > $options->_uploadMaxSize
) {
105 $errors['maxFileSize'] = ts("Maximum file size cannot exceed Upload max size ('upload_max_filesize') as defined in PHP.ini.");
108 // validate recent items stack size
109 if ($fields['recentItemsMaxCount'] && ($fields['recentItemsMaxCount'] < 1 ||
$fields['recentItemsMaxCount'] > CRM_Utils_Recent
::MAX_ITEMS
)) {
110 $errors['recentItemsMaxCount'] = ts("Illegal stack size. Use values between 1 and %1.", [1 => CRM_Utils_Recent
::MAX_ITEMS
]);
113 if (!empty($fields['wkhtmltopdfPath'])) {
114 // check and ensure that thi leads to the wkhtmltopdf binary
115 // and it is a valid executable binary
116 // Only check the first space separated piece to allow for a value
117 // such as /usr/bin/xvfb-run -- wkhtmltopdf (CRM-13292)
118 $pieces = explode(' ', $fields['wkhtmltopdfPath']);
121 !file_exists($path) ||
122 !is_executable($path)
124 $errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid');