X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fcommon.lib.php;h=6526d730c96df388faa66092856588c877aeee03;hb=a8084d2e767dd2ea7e57f2348a27d4fc2da42a6f;hp=43377103a294f0e7738dd01380b475c1721f2915;hpb=60a7d2b7a9ba3f15874c359c0cba2ca97ff9eca8;p=timetracker.git diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index 43377103..6526d730 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -165,7 +165,7 @@ function check_extension($ext) // isTrue is a helper function to return correct false for older config.php values defined as a string 'false'. function isTrue($val) { - return ($val == false || $val === 'false') ? false : true; + return (defined($val) && constant($val) === true); } // ttValidString is used to check user input to validate a string. @@ -226,7 +226,7 @@ function ttValidFloat($val, $emptyValid = false) return ($emptyValid ? true : false); global $user; - $decimal = $user->decimal_mark; + $decimal = $user->getDecimalMark(); if (!preg_match('/^-?[0-9'.$decimal.']+$/', $val)) return false; @@ -390,3 +390,19 @@ function ttStartsWith($string, $startString) $len = strlen($startString); return (substr($string, 0, $len) === $startString); } + +// ttEndsWith functions checks if a string ends with a given substring. +function ttEndsWith($string, $endString) +{ + $len = strlen($endString); + if ($len == 0) return true; + return (substr($string, -$len) === $endString); +} + +// ttDateToUserFormat converts a date from database format to user format. +function ttDateToUserFormat($date) +{ + global $user; + $o_date = new DateAndTime(DB_DATEFORMAT, $date); + return $o_date->toString($user->date_format); +}