diff --git a/CRM/Admin/Form/Setting/Component.php b/CRM/Admin/Form/Setting/Component.php index e893e85414a41b55f2f650194834f68e97308b76..8b87877e9da8034ad579f7872df0d93f336acc1f 100644 --- a/CRM/Admin/Form/Setting/Component.php +++ b/CRM/Admin/Form/Setting/Component.php @@ -76,7 +76,7 @@ class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting { * @access public * @static */ - static function formRule($fields) { + static function formRule($fields, $files, $options) { $errors = array(); if (is_array($fields['enableComponents'])) { diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index 5628c1f2e6349dadfcd0accfd9ed1376eb954baa..c0704eddce2369741d2d915ad3999715ef54af29 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -99,9 +99,38 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { $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 + if ( + !file_exists($fields['wkhtmltopdfPath']) || + !is_executable($fields['wkhtmltopdfPath']) + ) { + $errors['wkhtmltopdfPath'] = ts('The wkhtmltodfPath does not exist or is not valid'); + } + } + return $errors; + } + function setDefaultValues() { parent::setDefaultValues();