X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fcommon.lib.php;h=13a5d13c05fd8a1bf2996c57f70dbf02e55136ae;hb=8015002a4a219b8fe8a62c95d7561284db5ae07c;hp=3644c0587471ac433005eb93b83010c60785490a;hpb=60638b6c4f5fb33cd431cabdfef2de83c570b4da;p=timetracker.git diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index 3644c058..13a5d13c 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -143,15 +143,17 @@ } } -function time_to_decimal($a) { - $tmp = explode(":", $a); - if($tmp[1]{0}=="0") $tmp[1] = $tmp[1]{1}; +// time_to_decimal converts a time string such as 1:15 to its decimal representation such as 1.25 or 1,25. +function time_to_decimal($val) { + global $user; + $parts = explode(':', $val); // parts[0] is hours, parts[1] is minutes. + + $minutePercent = round($parts[1]*100/60); // Integer value (0-98) of percent of minutes portion in the hour. + if($minutePercent < 10) $minutePercent = '0'.$minutePercent; // Pad small values with a 0 to always have 2 digits. - $m = round($tmp[1]*100/60); + $decimalTime = $parts[0].$user->decimal_mark.$minutePercent; // Construct decimal representation of time value. - if($m<10) $m = "0".$m; - $time = $tmp[0].".".$m; - return $time; + return $decimalTime; } function sec_to_time_fmt_hm($sec) @@ -161,11 +163,9 @@ function sec_to_time_fmt_hm($sec) function magic_quotes_off() { - // if (get_magic_quotes_gpc()) { // This check is now done before calling this function. - $_POST = array_map('stripslashes_deep', $_POST); - $_GET = array_map('stripslashes_deep', $_GET); - $_COOKIE = array_map('stripslashes_deep', $_COOKIE); - // } + $_POST = array_map('stripslashes_deep', $_POST); + $_GET = array_map('stripslashes_deep', $_GET); + $_COOKIE = array_map('stripslashes_deep', $_COOKIE); } // check_extension checks whether a required PHP extension is loaded and dies if not so. @@ -340,10 +340,3 @@ function ttAccessCheck($required_rights) return true; } - -// ttPluginEnabled is used to check whether a plugin is enabled for user. -function ttPluginEnabled($plugin) -{ - global $user; - return in_array($plugin, explode(',', $user->plugins)); -}