X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FRule.php;h=6526da977e10ff289952973b8856f442ba60963b;hb=1578e7cf94a9d31c7ef3a853f2a092bcd22c8012;hp=50f0e60c8596d033352992ee77222f8cf0a04cd4;hpb=397d0aec7771968e6ad649229f9a72c9c0e9b12c;p=civicrm-core.git diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php index 50f0e60c85..6526da977e 100644 --- a/CRM/Utils/Rule.php +++ b/CRM/Utils/Rule.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -222,10 +222,11 @@ class CRM_Utils_Rule { * specified has to be beyond today. (i.e today or later) * * @param array $date - * @param bool $monthRequired check whether month is mandatory + * @param bool $monthRequired + * Check whether month is mandatory. * - * @return bool true if valid date - * @static + * @return bool + * true if valid date */ public static function currentDate($date, $monthRequired = TRUE) { $config = CRM_Core_Config::singleton(); @@ -315,8 +316,8 @@ class CRM_Utils_Rule { * * @param string $date * - * @return bool true if valid date - * @static + * @return bool + * true if valid date */ public static function mysqlDate($date) { // allow date to be null @@ -422,14 +423,15 @@ class CRM_Utils_Rule { $config = CRM_Core_Config::singleton(); - //CRM-14868 + //CRM-14868 $currencySymbols = CRM_Core_PseudoConstant::get( - 'CRM_Contribute_DAO_Contribution', - 'currency', array( - 'keyColumn' => 'name', - 'labelColumn' => 'symbol' - )); - $value = str_replace($currencySymbols,'',$value); + 'CRM_Contribute_DAO_Contribution', + 'currency', array( + 'keyColumn' => 'name', + 'labelColumn' => 'symbol', + ) + ); + $value = str_replace($currencySymbols, '', $value); if ($config->monetaryThousandSeparator) { $mon_thousands_sep = $config->monetaryThousandSeparator; @@ -441,7 +443,9 @@ class CRM_Utils_Rule { // ugly fix for CRM-6391: do not drop the thousand separator if // it looks like it’s separating decimal part (because a given // value undergoes a second cleanMoney() call, for example) - if ($mon_thousands_sep != '.' or substr($value, -3, 1) != '.') { + // CRM-15835 - in case the amount/value contains 0 after decimal + // eg 150.5 the following if condition will pass + if ($mon_thousands_sep != '.' or (substr($value, -3, 1) != '.' && substr($value, -2, 1) != '.')) { $value = str_replace($mon_thousands_sep, '', $value); } @@ -535,10 +539,10 @@ class CRM_Utils_Rule { return TRUE; } - // allow between 4-6 digits as postal code since india needs 6 and US needs 5 (or - // if u disregard the first 0, 4 (thanx excel!) - // FIXME: we need to figure out how to localize such rules /** + * allow between 4-6 digits as postal code since india needs 6 and US needs 5 (or + * if u disregard the first 0, 4 (thanx excel!) + * FIXME: we need to figure out how to localize such rules * @param $value * * @return bool @@ -554,9 +558,8 @@ class CRM_Utils_Rule { * 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) - * - * @return bool true if file has been uploaded, false otherwise + * @return bool + * true if file has been uploaded, false otherwise */ public static function asciiFile($elementValue) { if ((isset($elementValue['error']) && $elementValue['error'] == 0) || @@ -570,9 +573,8 @@ class CRM_Utils_Rule { /** * Checks to make sure the uploaded file is in UTF-8, recodes if it's not * - * @param array Uploaded file info (from $_FILES) - * - * @return bool whether file has been uploaded properly and is now in UTF-8 + * @return bool + * whether file has been uploaded properly and is now in UTF-8 */ public static function utf8File($elementValue) { $success = FALSE; @@ -599,9 +601,8 @@ class CRM_Utils_Rule { * 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) - * - * @return bool true if file has been uploaded, false otherwise + * @return bool + * true if file has been uploaded, false otherwise */ public static function htmlFile($elementValue) { if ((isset($elementValue['error']) && $elementValue['error'] == 0) || @@ -613,13 +614,15 @@ class CRM_Utils_Rule { } /** - * Check if there is a record with the same name in the db + * Check if there is a record with the same name in the db. * - * @param string $value the value of the field we are checking - * @param array $options the daoName and fieldName (optional ) + * @param string $value + * The value of the field we are checking. + * @param array $options + * The daoName and fieldName (optional ). * - * @return boolean true if object exists - * @static + * @return bool + * true if object exists */ public static function objectExists($value, $options) { $name = 'name'; @@ -745,8 +748,8 @@ class CRM_Utils_Rule { * * @param array $date * - * @return bool true if valid date - * @static + * @return bool + * true if valid date */ public static function qfDate($date) { $config = CRM_Core_Config::singleton(); @@ -798,4 +801,5 @@ class CRM_Utils_Rule { public static function qfKey($key) { return ($key) ? CRM_Core_Key::valid($key) : FALSE; } + }