From ce0dd6bd1bbe5a0570110484d11d6756f516c751 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Sun, 27 Sep 2015 19:10:18 +0200 Subject: [PATCH 1/3] Update to latest sources --- sources/backend/caldav/caldav.php | 2 +- sources/backend/caldav/config.php | 7 ++++++- sources/backend/imap/imap.php | 9 ++++++++- sources/testing/testing-caldav.php | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sources/backend/caldav/caldav.php b/sources/backend/caldav/caldav.php index 9a3c19c..811c798 100644 --- a/sources/backend/caldav/caldav.php +++ b/sources/backend/caldav/caldav.php @@ -227,7 +227,7 @@ class BackendCalDAV extends BackendDiff { /* Calculating the range of events we want to sync */ $begin = gmdate("Ymd\THis\Z", $cutoffdate); - $finish = gmdate("Ymd\THis\Z", 2147483647); + $finish = gmdate("Ymd\THis\Z", CALDAV_MAX_SYNC_PERIOD); $path = $this->_caldav_path . substr($folderid, 1) . "/"; if ($folderid[0] == "C") { diff --git a/sources/backend/caldav/config.php b/sources/backend/caldav/config.php index c42419c..1257443 100644 --- a/sources/backend/caldav/config.php +++ b/sources/backend/caldav/config.php @@ -64,4 +64,9 @@ define('CALDAV_PERSONAL', 'PRINCIPAL'); // DAViCal, SOGo and SabreDav support it // SabreDav version must be at least 1.9.0, otherwise set this to false // Setting this to false will work with most servers, but it will be slower -define('CALDAV_SUPPORTS_SYNC', false); \ No newline at end of file +define('CALDAV_SUPPORTS_SYNC', false); + + +// Maximum period to sync. +// Some servers don't support more than 10 years so you will need to change this +define('CALDAV_MAX_SYNC_PERIOD', 2147483647); \ No newline at end of file diff --git a/sources/backend/imap/imap.php b/sources/backend/imap/imap.php index 42e04f0..58ff36c 100644 --- a/sources/backend/imap/imap.php +++ b/sources/backend/imap/imap.php @@ -1144,7 +1144,14 @@ class BackendIMAP extends BackendDiff implements ISearchProvider { $bpo = $contentparameters->BodyPreference($output->asbody->type); if (Request::GetProtocolVersion() >= 14.0 && $bpo->GetPreview()) { - $output->asbody->preview = Utils::Utf8_truncate(Utils::ConvertHtmlToText($textBody), $bpo->GetPreview()); + // Preview must be always plaintext + $previewText = ""; + Mail_mimeDecode::getBodyRecursive($message, "plain", $previewText, true); + if (strlen($previewText) == 0) { + Mail_mimeDecode::getBodyRecursive($message, "html", $previewText, true); + $previewText = Utils::ConvertHtmlToText($previewText); + } + $output->asbody->preview = Utils::Utf8_truncate($previewText, $bpo->GetPreview()); } } /* END fmbiete's contribution r1528, ZP-320 */ diff --git a/sources/testing/testing-caldav.php b/sources/testing/testing-caldav.php index ec3f250..7fede51 100644 --- a/sources/testing/testing-caldav.php +++ b/sources/testing/testing-caldav.php @@ -34,7 +34,7 @@ $val = $caldav->GetCalendarDetails($path); print_r($val); $begin = gmdate("Ymd\THis\Z", time() - 24*7*60*60); -$finish = gmdate("Ymd\THis\Z", 2147483647); +$finish = gmdate("Ymd\THis\Z", CALDAV_MAX_SYNC_PERIOD); $msgs = $caldav->GetEvents($begin, $finish, $path); print_r($msgs); From 53e7117d18bcec37f7c633213696b08db12651ac Mon Sep 17 00:00:00 2001 From: polytan02 Date: Tue, 10 Nov 2015 08:03:19 +0100 Subject: [PATCH 2/3] Update to latest sources --- sources/backend/caldav/REQUIREMENTS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/backend/caldav/REQUIREMENTS b/sources/backend/caldav/REQUIREMENTS index 15735e8..cd00f71 100644 --- a/sources/backend/caldav/REQUIREMENTS +++ b/sources/backend/caldav/REQUIREMENTS @@ -2,4 +2,7 @@ REQUIREMENTS: php-curl libawl-php -CalDAV server (DAViCal, Sabredav, Sogo, Owncloud...) \ No newline at end of file +INSTALL: +Add your awl folder to the include_path variable (/etc/php.ini or similar) + +CalDAV server (DAViCal, Sabredav, Sogo, Owncloud...) From 92ac226c09e042ee2e670d64696bcb15c49968d6 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Sun, 3 Jan 2016 12:31:25 +0100 Subject: [PATCH 3/3] Update to latest sources --- sources/backend/imap/imap.php | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/sources/backend/imap/imap.php b/sources/backend/imap/imap.php index 58ff36c..3a04d2e 100644 --- a/sources/backend/imap/imap.php +++ b/sources/backend/imap/imap.php @@ -389,13 +389,13 @@ class BackendIMAP extends BackendDiff implements ISearchProvider { } if (strlen($plainBody) > 0) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->addTextParts(): The message has PLAIN body")); - if (strlen($htmlSource) > 0) { - ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->addTextParts(): The original message had HTML body, we cast new PLAIN to HTML")); - $altEmail->addSubPart('

' . str_replace("\n", "
", str_replace("\r\n", "\n", $plainBody)) . "

" . $separatorHtml . $htmlSource . $separatorHtmlEnd, array('content_type' => 'text/html; charset=utf-8', 'encoding' => 'base64')); - } if (strlen($plainSource) > 0) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->addTextParts(): The original message had PLAIN body")); - $altEmail->addSubPart($plainBody . $separator . str_replace("\n", "\n> ", "> ".$plainSource), array('content_type' => 'text/plain; charset=utf-8', 'encoding' => 'base64')); + $altEmail->addSubPart($plainBody . $separator . str_replace("\n", "\n> ", "> " . $plainSource), array('content_type' => 'text/plain; charset=utf-8', 'encoding' => 'base64')); + } + else { + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->addTextParts(): The original message had not PLAIN body, we use original HTML body to create PLAIN")); + $altEmail->addSubPart($plainBody . $separator . str_replace("\n", "\n> ", "> " . Utils::ConvertHtmlToText($htmlSource)), array('content_type' => 'text/plain; charset=utf-8', 'encoding' => 'base64')); } } @@ -2073,30 +2073,31 @@ class BackendIMAP extends BackendDiff implements ISearchProvider { protected function getFolderIdFromImapId($imapid, $case_sensitive = true) { $this->InitializePermanentStorage(); + if (!isset($this->permanentStorage->fmFimapFid)) { + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s') IMAP cache folder not found, creating one", $imapid)); + $this->GetFolderList(); + } + if ($case_sensitive) { - if (isset($this->permanentStorage->fmFimapFid)) { - if (isset($this->permanentStorage->fmFimapFid[$imapid])) { - $folderid = $this->permanentStorage->fmFimapFid[$imapid]; - ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s') = %s", $imapid, $folderid)); - return $folderid; - } - else { - ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s') = %s", $imapid, 'not found')); - return false; - } + if (isset($this->permanentStorage->fmFimapFid[$imapid])) { + $folderid = $this->permanentStorage->fmFimapFid[$imapid]; + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s') = %s", $imapid, $folderid)); + return $folderid; + } + else { + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s') = %s", $imapid, 'not found')); + return false; } } else { - if (isset($this->permanentStorage->fmFimapFidLowercase)) { - if (isset($this->permanentStorage->fmFimapFidLowercase[strtolower($imapid)])) { - $folderid = $this->permanentStorage->fmFimapFidLowercase[strtolower($imapid)]; - ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s', false) = %s", $imapid, $folderid)); - return $folderid; - } - else { - ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s', false) = %s", $imapid, 'not found')); - return false; - } + if (isset($this->permanentStorage->fmFimapFidLowercase[strtolower($imapid)])) { + $folderid = $this->permanentStorage->fmFimapFidLowercase[strtolower($imapid)]; + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s', false) = %s", $imapid, $folderid)); + return $folderid; + } + else { + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->getFolderIdFromImapId('%s', false) = %s", $imapid, 'not found')); + return false; } }