From 99dfb87b5999d4997afbef992fd28636c17bb6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Fri, 24 Jun 2022 02:59:35 +0200 Subject: [PATCH] GH-224 Allow to get min vacation duration as a number --- includes/functions.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 1a101bbf..8a9d744b 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -108,13 +108,20 @@ function getUserMinimalVacationTime(&$user) { return getUserMinimalNormalVacationTime($user); } -function getUserMinimalNormalVacationTime(&$user) { - $hadProAccountWhenVacationStarted = ($user['pro_time'] > $user['vacation_starttime']); +function getUserMinimalNormalVacationDuration(&$user, $atTimestamp) { + $hasProAccount = ($user['pro_time'] > $atTimestamp); + + return ( + $hasProAccount ? + MINURLOP_PRO : + MINURLOP_FREE + ); +} - $vacationMinimalDuration = ( - $hadProAccountWhenVacationStarted ? - MINURLOP_PRO : - MINURLOP_FREE +function getUserMinimalNormalVacationTime(&$user) { + $vacationMinimalDuration = getUserMinimalNormalVacationDuration( + $user, + $user['vacation_starttime'] ); return ($vacationMinimalDuration + $user['vacation_starttime']);