From 29db130d0152f056ce271d2a359cca4b4e59e484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20G=C3=BCnther?= Date: Mon, 7 Oct 2024 10:11:10 +0200 Subject: [PATCH] Added new function to allow keeping the flags original case --- lib/Horde/Imap/Client.php | 2 ++ lib/Horde/Imap/Client/Data/Fetch.php | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Horde/Imap/Client.php b/lib/Horde/Imap/Client.php index d03173d3f..efb49ae8b 100644 --- a/lib/Horde/Imap/Client.php +++ b/lib/Horde/Imap/Client.php @@ -115,6 +115,8 @@ class Horde_Imap_Client /* @since 2.11.0 */ const FETCH_DOWNGRADED = 16; + const FETCH_FLAGS_ORIGINAL_CASE = 999; + /* Namespace constants. @deprecated */ const NS_PERSONAL = 1; const NS_OTHER = 2; diff --git a/lib/Horde/Imap/Client/Data/Fetch.php b/lib/Horde/Imap/Client/Data/Fetch.php index 4a476ef3b..01a56e266 100644 --- a/lib/Horde/Imap/Client/Data/Fetch.php +++ b/lib/Horde/Imap/Client/Data/Fetch.php @@ -325,9 +325,11 @@ public function getEnvelope() */ public function setFlags(array $flags) { + $trimmed = array_map('trim', $flags); + $this->_data[Horde_Imap_Client::FETCH_FLAGS_ORIGINAL_CASE] = $trimmed; $this->_data[Horde_Imap_Client::FETCH_FLAGS] = array_map( 'Horde_String::lower', - array_map('trim', $flags) + $trimmed ); } @@ -343,6 +345,18 @@ public function getFlags() : array(); } + /** + * Get IMAP flags without changing their case. + * + * @return array An array of IMAP flags with their original case + */ + public function getFlagsOriginalCase() + { + return isset($this->_data[Horde_Imap_Client::FETCH_FLAGS_ORIGINAL_CASE]) + ? $this->_data[Horde_Imap_Client::FETCH_FLAGS_ORIGINAL_CASE] + : array(); + } + /** * Set IMAP internal date. *