Activate OLDER and YOUNGER of RFC 5032

This commit is contained in:
the-djmaze 2023-11-23 00:35:52 +01:00
parent ad3d8c87ec
commit 60964c9869

View file

@ -292,14 +292,26 @@ abstract class SearchCriterias
$bUseCache = false; $bUseCache = false;
break; break;
case 'OLDER_THAN': case 'OLDER_THAN':
$aCriteriasResult[] = 'BEFORE'; $oDate = (new \DateTime())->sub(new \DateInterval("P{$sRawValue}"));
$aCriteriasResult[] = (new \DateTime())->sub(new \DateInterval("P{$sRawValue}"))->format('j-M-Y'); if ($oImapClient->hasCapability('WITHIN')) {
$aCriteriasResult[] = 'OLDER';
$aCriteriasResult[] = \time() - $oDate->getTimestamp();
} else {
$aCriteriasResult[] = 'BEFORE';
$aCriteriasResult[] = $oDate->format('j-M-Y');
}
break; break;
case 'NEWER_THAN': case 'NEWER_THAN':
$iTimeFilter = \max( $oDate = (new \DateTime())->sub(new \DateInterval("P{$sRawValue}"));
$iTimeFilter, if ($oImapClient->hasCapability('WITHIN')) {
(new \DateTime())->sub(new \DateInterval("P{$sRawValue}"))->getTimestamp() $aCriteriasResult[] = 'YOUNGER';
); $aCriteriasResult[] = \time() - $oDate->getTimestamp();
} else {
$iTimeFilter = \max(
$iTimeFilter,
(new \DateTime())->sub(new \DateInterval("P{$sRawValue}"))->getTimestamp()
);
}
break; break;
} }
} }
@ -397,6 +409,8 @@ abstract class SearchCriterias
case 'SENTSINCE': case 'SENTSINCE':
case 'SENTBEFORE': case 'SENTBEFORE':
case 'BEFORE': case 'BEFORE':
case 'OLDER':
case 'YOUNGER':
if (\strlen($mValue)) { if (\strlen($mValue)) {
$aResult[$sName] = $mValue; $aResult[$sName] = $mValue;
} }