Enable detection of some Kolab 'mail.*' folder types

This commit is contained in:
djmaze 2021-10-21 15:49:42 +02:00
parent d534d2700a
commit 524cafe689
2 changed files with 44 additions and 33 deletions

View file

@ -29,6 +29,9 @@ abstract class FolderType
const ARCHIVE = 12;
const ALL = 13;
// TODO: SnappyMail
const TEMPLATES = 19;
// Kolab
const CONFIGURATION = 20;
const CALENDAR = 21;

View file

@ -11,6 +11,7 @@
namespace MailSo\Mail;
use MailSo\Imap\Enumerations\FolderType;
use MailSo\Imap\Enumerations\MetadataKeys;
/**
@ -195,76 +196,83 @@ class Folder implements \JsonSerializable
switch (true)
{
case \in_array('\\inbox', $aFlags) || 'INBOX' === \strtoupper($this->FullNameRaw()):
return \MailSo\Imap\Enumerations\FolderType::INBOX;
return FolderType::INBOX;
case \in_array('\\sent', $aFlags):
case \in_array('\\sentmail', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::SENT;
return FolderType::SENT;
case \in_array('\\drafts', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::DRAFTS;
return FolderType::DRAFTS;
case \in_array('\\junk', $aFlags):
case \in_array('\\spam', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::JUNK;
return FolderType::JUNK;
case \in_array('\\trash', $aFlags):
case \in_array('\\bin', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::TRASH;
return FolderType::TRASH;
case \in_array('\\important', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::IMPORTANT;
return FolderType::IMPORTANT;
case \in_array('\\flagged', $aFlags):
case \in_array('\\starred', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::FLAGGED;
return FolderType::FLAGGED;
case \in_array('\\archive', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::ARCHIVE;
return FolderType::ARCHIVE;
case \in_array('\\all', $aFlags):
case \in_array('\\allmail', $aFlags):
return \MailSo\Imap\Enumerations\FolderType::ALL;
return FolderType::ALL;
// TODO
// case 'Templates' === $this->FullNameRaw():
// return \MailSo\Imap\Enumerations\FolderType::TEMPLATES;
// return FolderType::TEMPLATES;
}
/*
// TODO: Kolab
// Kolab
$type = $this->GetMetadata(MetadataKeys::KOLAB_CTYPE) ?: $this->GetMetadata(MetadataKeys::KOLAB_CTYPE_SHARED);
switch (($type && 0 !== \strpos($type, 'mail.')) ? $type : null)
switch ($type)
{
/*
// TODO: Kolab
case 'event':
return \MailSo\Imap\Enumerations\FolderType::CALENDAR;
case 'event.default':
return FolderType::CALENDAR;
case 'contact':
return \MailSo\Imap\Enumerations\FolderType::CONTACTS;
case 'contact.default':
return FolderType::CONTACTS;
case 'task':
return \MailSo\Imap\Enumerations\FolderType::TASKS;
case 'task.default':
return FolderType::TASKS;
case 'note':
return \MailSo\Imap\Enumerations\FolderType::NOTES;
case 'note.default':
return FolderType::NOTES;
case 'file':
return \MailSo\Imap\Enumerations\FolderType::FILES;
case 'file.default':
return FolderType::FILES;
case 'configuration':
return \MailSo\Imap\Enumerations\FolderType::CONFIGURATION;
return FolderType::CONFIGURATION;
case 'journal':
return \MailSo\Imap\Enumerations\FolderType::JOURNAL;
case 'mail.inbox':
return \MailSo\Imap\Enumerations\FolderType::INBOX;
case 'mail.drafts':
return \MailSo\Imap\Enumerations\FolderType::DRAFTS;
case 'mail.sentitems':
return \MailSo\Imap\Enumerations\FolderType::SENT;
case 'mail.wastebasket':
return \MailSo\Imap\Enumerations\FolderType::TRASH;
// case 'mail.outbox':
case 'mail.junkemail':
return \MailSo\Imap\Enumerations\FolderType::JUNK;
}
case 'journal.default':
return FolderType::JOURNAL;
*/
case 'mail.inbox':
return FolderType::INBOX;
// case 'mail.outbox':
case 'mail.sentitems':
return FolderType::SENT;
case 'mail.drafts':
return FolderType::DRAFTS;
case 'mail.junkemail':
return FolderType::JUNK;
case 'mail.wastebasket':
return FolderType::TRASH;
}
return \MailSo\Imap\Enumerations\FolderType::USER;
return FolderType::USER;
}
/**