From 5a64153f40ae833f8b57cdd3f40c24ccc0b679d1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 29 Aug 2014 14:07:06 +0200 Subject: Fix vacation times handling --- .../lib/Roundcube/rcube_sieve_vacation.php | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'plugins') diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php index af028e0ae..820265b86 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php @@ -156,20 +156,22 @@ class rcube_sieve_vacation extends rcube_sieve_engine $date = trim($$var . ' ' . $time); if ($date && ($dt = rcube_utils::anytodatetime($date, $timezone))) { - $vacation_tests[] = array( - 'test' => 'currentdate', - 'part' => 'date', - 'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'), - 'zone' => $dt->format('O'), - 'arg' => $dt->format('Y-m-d'), - ); if ($time) { $vacation_tests[] = array( 'test' => 'currentdate', - 'part' => 'time', + 'part' => 'iso8601', 'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'), 'zone' => $dt->format('O'), - 'arg' => $dt->format('H:i:s'), + 'arg' => str_replace('+00:00', 'Z', strtoupper($dt->format('c'))), + ); + } + else { + $vacation_tests[] = array( + 'test' => 'currentdate', + 'part' => 'date', + 'type' => 'value-' . ($var == 'date_from' ? 'ge' : 'le'), + 'zone' => $dt->format('O'), + 'arg' => $dt->format('Y-m-d'), ); } } @@ -333,24 +335,24 @@ class rcube_sieve_vacation extends rcube_sieve_engine $date_value = array(); foreach ((array) $this->vacation['tests'] as $test) { - if ($test['test'] == 'currentdate' && ($test['part'] == 'date' || $test['part'] == 'time')) { + if ($test['test'] == 'currentdate') { $idx = $test['type'] == 'value-ge' ? 'from' : 'to'; - $date_value[$idx][$test['part']] = $test['arg']; - if ($test['zone']) { - $date_value[$idx]['zone'] = $test['zone']; + + if ($test['part'] == 'date') { + $date_value[$idx]['date'] = $test['arg']; + } + else if ($test['part'] == 'iso8601') { + $date_value[$idx]['datetime'] = $test['arg']; } } } foreach ($date_value as $idx => $value) { - $date = $value['date'] . ' ' - . ($value['time'] ? $value['time'] : ($idx == 'from' ? '00:00:00' : '23:59:59')) - . ($value['zone'] ? ' ' . $value['zone'] : ''); - - $date_value[$idx] = $this->rc->format_date($date, $date_format, !empty($value['time']) && !empty($value['zone'])); + $date = $value['datetime'] ?: $value['date']; + $date_value[$idx] = $this->rc->format_date($date, $date_format, false); - if (!empty($value['time'])) { - $date_value['time_' . $idx] = $this->rc->format_date($date, $time_format, !empty($value['zone'])); + if (!empty($value['datetime'])) { + $date_value['time_' . $idx] = $this->rc->format_date($date, $time_format, true); } } } -- cgit v1.2.3