CRM-12750
authorDonald A. Lobo <lobo@civicrm.org>
Mon, 3 Jun 2013 16:10:42 +0000 (09:10 -0700)
committerDonald A. Lobo <lobo@civicrm.org>
Mon, 3 Jun 2013 16:10:42 +0000 (09:10 -0700)
----------------------------------------
* CRM-12750: upgrade smarty to 2.6.27
  http://issues.civicrm.org/jira/browse/CRM-12750

CRM/Admin/Form/Setting/Component.php
CRM/Admin/Form/Setting/Miscellaneous.php

index e893e85414a41b55f2f650194834f68e97308b76..8b87877e9da8034ad579f7872df0d93f336acc1f 100644 (file)
@@ -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'])) {
index 5628c1f2e6349dadfcd0accfd9ed1376eb954baa..c0704eddce2369741d2d915ad3999715ef54af29 100644 (file)
@@ -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();