Resuming work on attachments handling.
[timetracker.git] / WEB-INF / lib / common.lib.php
index 4411fb5..6526d73 100644 (file)
@@ -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 === 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;
@@ -391,6 +391,14 @@ function ttStartsWith($string, $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)
 {