CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionAlert' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionCheck' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'empoweredBy' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'maxFileSize' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'secondDegRelPermissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, ); /** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)')); // also check if we can enable triggers $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(FALSE); // FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted $domain = new CRM_Core_DAO_Domain; $domain->find(TRUE); $attribs = $domain->locales || !$validTriggerPermission ? array('disabled' => 'disabled') : array(); $this->assign('validTriggerPermission', $validTriggerPermission); $this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs); $this->addElement( 'text', 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'), array('size' => 64, 'maxlength' => 256) ); $this->addElement( 'text', 'recaptchaPublicKey', ts('Public Key'), array('size' => 64, 'maxlength' => 64) ); $this->addElement( 'text', 'recaptchaPrivateKey', ts('Private Key'), array('size' => 64, 'maxlength' => 64) ); $this->addElement( 'text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'), array('size' => 3, 'maxlength' => 5) ); $this->addElement( 'text', 'checksumTimeout', ts('CheckSum Lifespan'), array('size' => 2, 'maxlength' => 8) ); $this->addElement( 'text', 'recaptchaOptions', ts('Recaptcha Options'), array('size' => 64, 'maxlength' => 64) ); $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger'); $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this); parent::buildQuickForm(); } /** * global form rule * * @param array $fields the input form values * @param array $files the uploaded files if any * @param array $options additional user data * * @return true if no errors, else array of errors * @access public * @static */ static function formRule($fields, $files, $options) { $errors = array(); if (!empty($fields['wkhtmltopdfPath'])) { // check and ensure that thi leads to the wkhtmltopdf binary // and it is a valid executable binary // Only check the first space separated piece to allow for a value // such as /usr/bin/xvfb-run -- wkhtmltopdf (CRM-13292) $pieces = explode(' ', $fields['wkhtmltopdfPath']); $path = $pieces[0]; if ( !file_exists($path) || !is_executable($path) ) { $errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid'); } } return $errors; } function setDefaultValues() { parent::setDefaultValues(); $this->_defaults['checksumTimeout'] = CRM_Core_BAO_Setting::getItem( CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'checksum_timeout', NULL, 7 ); return $this->_defaults; } public function postProcess() { // store the submitted values in an array $config = CRM_Core_Config::singleton(); $params = $this->controller->exportValues($this->_name); // get current logging status $values = $this->exportValues(); parent::postProcess(); if ($config->logging != $values['logging']) { $logging = new CRM_Logging_Schema; if ($values['logging']) { $logging->enableLogging(); } else { $logging->disableLogging(); } } } }