CRM-15598 - Allow relative URL's for Link custom fields
[civicrm-core.git] / CRM / Utils / Rule.php
index 4c27b896e9a6c3299ec0ce521848dc9dd93ae99d..d58c86a63725a6f44edfb117be75017e1ce6622d 100644 (file)
@@ -153,6 +153,10 @@ class CRM_Utils_Rule {
    * @return bool
    */
   static function url($url) {
+    if (preg_match('/^\//', $url)) {
+      // allow relative URL's (CRM-15598)
+      $url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
+    }
     return (bool) filter_var($url, FILTER_VALIDATE_URL);
   }
 
@@ -212,7 +216,7 @@ class CRM_Utils_Rule {
   }
 
   /**
-   * check the validity of the date (in qf format)
+   * Check the validity of the date (in qf format)
    * note that only a year is valid, or a mon-year is
    * also valid in addition to day-mon-year. The date
    * specified has to be beyond today. (i.e today or later)
@@ -305,7 +309,7 @@ class CRM_Utils_Rule {
   }
 
   /**
-   * check the validity of a date or datetime (timestamp)
+   * Check the validity of a date or datetime (timestamp)
    * value which is in YYYYMMDD or YYYYMMDDHHMMSS format
    *
    * Uses PHP checkdate() - params are ( int $month, int $day, int $year )
@@ -420,6 +424,15 @@ class CRM_Utils_Rule {
 
     $config = CRM_Core_Config::singleton();
 
+    //CRM-14868 
+    $currencySymbols = CRM_Core_PseudoConstant::get(
+                          'CRM_Contribute_DAO_Contribution',
+                          'currency', array(
+                                           'keyColumn' => 'name',
+                                           'labelColumn' => 'symbol'
+                                            ));
+    $value = str_replace($currencySymbols,'',$value);
+
     if ($config->monetaryThousandSeparator) {
       $mon_thousands_sep = $config->monetaryThousandSeparator;
     }
@@ -540,7 +553,7 @@ class CRM_Utils_Rule {
   }
 
   /**
-   * see how file rules are written in HTML/QuickForm/file.php
+   * See how file rules are written in HTML/QuickForm/file.php
    * Checks to make sure the uploaded file is ascii
    *
    * @param     array     Uploaded file info (from $_FILES)
@@ -587,7 +600,7 @@ class CRM_Utils_Rule {
   }
 
   /**
-   * see how file rules are written in HTML/QuickForm/file.php
+   * See how file rules are written in HTML/QuickForm/file.php
    * Checks to make sure the uploaded file is html
    *
    * @param     array     Uploaded file info (from $_FILES)
@@ -732,7 +745,7 @@ class CRM_Utils_Rule {
   }
 
   /**
-   * check the validity of the date (in qf format)
+   * Check the validity of the date (in qf format)
    * note that only a year is valid, or a mon-year is
    * also valid in addition to day-mon-year
    *