mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Some changes for #419 flags
This commit is contained in:
parent
5f6ea3cf29
commit
135406ebfe
5 changed files with 37 additions and 16 deletions
|
|
@ -15,7 +15,7 @@ namespace MailSo\Imap;
|
||||||
* @category MailSo
|
* @category MailSo
|
||||||
* @package Imap
|
* @package Imap
|
||||||
*/
|
*/
|
||||||
class FolderInformation
|
class FolderInformation implements \JsonSerializable
|
||||||
{
|
{
|
||||||
use Traits\Status;
|
use Traits\Status;
|
||||||
|
|
||||||
|
|
@ -36,6 +36,7 @@ class FolderInformation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
|
* NOTE: Empty when FolderExamine is used
|
||||||
*/
|
*/
|
||||||
public $PermanentFlags = array();
|
public $PermanentFlags = array();
|
||||||
|
|
||||||
|
|
@ -57,4 +58,23 @@ class FolderInformation
|
||||||
\in_array($sFlag, $this->PermanentFlags) ||
|
\in_array($sFlag, $this->PermanentFlags) ||
|
||||||
\in_array($sFlag, $this->Flags);
|
\in_array($sFlag, $this->Flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'Name' => $this->FolderName,
|
||||||
|
'Flags' => $this->Flags,
|
||||||
|
'PermanentFlags' => $this->PermanentFlags,
|
||||||
|
/*
|
||||||
|
'Messages' => $this->MESSAGES,
|
||||||
|
'Unseen' => $this->UNSEEN,
|
||||||
|
'Recent' => $this->RECENT,
|
||||||
|
'UidNext' => $this->UIDNEXT,
|
||||||
|
'UidValidity' => $this->UIDVALIDITY,
|
||||||
|
'Highestmodseq' => $this->HIGHESTMODSEQ,
|
||||||
|
'Appendlimit' => $this->APPENDLIMIT,
|
||||||
|
'Mailboxid' => $this->MAILBOXID,
|
||||||
|
*/
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,7 @@ class Folder implements \JsonSerializable
|
||||||
'Selectable' => $this->IsSelectable(),
|
'Selectable' => $this->IsSelectable(),
|
||||||
'Flags' => $this->FlagsLowerCase(),
|
'Flags' => $this->FlagsLowerCase(),
|
||||||
// 'Extended' => $aExtended,
|
// 'Extended' => $aExtended,
|
||||||
|
// 'PermanentFlags' => $this->oImapFolder->PermanentFlags,
|
||||||
'Metadata' => $this->oImapFolder->Metadata()
|
'Metadata' => $this->oImapFolder->Metadata()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -521,21 +521,19 @@ class MailClient
|
||||||
*/
|
*/
|
||||||
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, SequenceSet $oRange = null) : array
|
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, SequenceSet $oRange = null) : array
|
||||||
{
|
{
|
||||||
$aFlags = array();
|
|
||||||
|
|
||||||
list($iCount, $iUnseenCount, $iUidNext, $iHighestModSeq, $iAppendLimit, $sMailboxId) = $this->initFolderValues($sFolderName);
|
list($iCount, $iUnseenCount, $iUidNext, $iHighestModSeq, $iAppendLimit, $sMailboxId) = $this->initFolderValues($sFolderName);
|
||||||
|
|
||||||
if ($oRange && \count($oRange))
|
$aFlags = array();
|
||||||
{
|
if ($oRange && \count($oRange)) {
|
||||||
$this->oImapClient->FolderExamine($sFolderName);
|
$oInfo = $this->oImapClient->FolderExamine($sFolderName);
|
||||||
|
// $oInfo->PermanentFlags
|
||||||
|
|
||||||
$aFetchResponse = $this->oImapClient->Fetch(array(
|
$aFetchResponse = $this->oImapClient->Fetch(array(
|
||||||
FetchType::UID,
|
FetchType::UID,
|
||||||
FetchType::FLAGS
|
FetchType::FLAGS
|
||||||
), (string) $oRange, $oRange->UID);
|
), (string) $oRange, $oRange->UID);
|
||||||
|
|
||||||
foreach ($aFetchResponse as $oFetchResponse)
|
foreach ($aFetchResponse as $oFetchResponse) {
|
||||||
{
|
|
||||||
$iUid = (int) $oFetchResponse->GetFetchValue(FetchType::UID);
|
$iUid = (int) $oFetchResponse->GetFetchValue(FetchType::UID);
|
||||||
$aLowerFlags = \array_map('strtolower', $oFetchResponse->GetFetchValue(FetchType::FLAGS));
|
$aLowerFlags = \array_map('strtolower', $oFetchResponse->GetFetchValue(FetchType::FLAGS));
|
||||||
$aFlags[] = array(
|
$aFlags[] = array(
|
||||||
|
|
@ -830,15 +828,19 @@ class MailClient
|
||||||
|
|
||||||
list($iMessageRealCount, $iMessageUnseenCount, $iUidNext, $iHighestModSeq) = $this->initFolderValues($oParams->sFolderName);
|
list($iMessageRealCount, $iMessageUnseenCount, $iUidNext, $iHighestModSeq) = $this->initFolderValues($oParams->sFolderName);
|
||||||
|
|
||||||
$this->oImapClient->FolderExamine($oParams->sFolderName);
|
// Don't use FolderExamine, else PERMANENTFLAGS is empty
|
||||||
|
$oInfo = $this->oImapClient->FolderSelect($oParams->sFolderName);
|
||||||
|
|
||||||
$oMessageCollection = new MessageCollection;
|
$oMessageCollection = new MessageCollection;
|
||||||
$oMessageCollection->FolderName = $oParams->sFolderName;
|
$oMessageCollection->FolderName = $oParams->sFolderName;
|
||||||
|
$oMessageCollection->FolderInfo = $oInfo;
|
||||||
$oMessageCollection->Offset = $oParams->iOffset;
|
$oMessageCollection->Offset = $oParams->iOffset;
|
||||||
$oMessageCollection->Limit = $oParams->iLimit;
|
$oMessageCollection->Limit = $oParams->iLimit;
|
||||||
$oMessageCollection->Search = $sSearch;
|
$oMessageCollection->Search = $sSearch;
|
||||||
$oMessageCollection->ThreadUid = $oParams->iThreadUid;
|
$oMessageCollection->ThreadUid = $oParams->iThreadUid;
|
||||||
$oMessageCollection->Filtered = '' !== \MailSo\Config::$MessageListPermanentFilter;
|
$oMessageCollection->Filtered = '' !== \MailSo\Config::$MessageListPermanentFilter;
|
||||||
|
$oMessageCollection->MessageCount = $iMessageRealCount;
|
||||||
|
$oMessageCollection->MessageUnseenCount = $iMessageUnseenCount;
|
||||||
|
|
||||||
$aUids = array();
|
$aUids = array();
|
||||||
$aAllThreads = [];
|
$aAllThreads = [];
|
||||||
|
|
@ -934,8 +936,6 @@ class MailClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$oMessageCollection->MessageCount = $iMessageRealCount;
|
|
||||||
$oMessageCollection->MessageUnseenCount = $iMessageUnseenCount;
|
|
||||||
$oMessageCollection->MessageResultCount = \count($aUids);
|
$oMessageCollection->MessageResultCount = \count($aUids);
|
||||||
|
|
||||||
if (\count($aUids))
|
if (\count($aUids))
|
||||||
|
|
@ -954,9 +954,6 @@ class MailClient
|
||||||
', limit:'.\MailSo\Config::$MessageListCountLimitTrigger.')');
|
', limit:'.\MailSo\Config::$MessageListCountLimitTrigger.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
$oMessageCollection->MessageCount = $iMessageRealCount;
|
|
||||||
$oMessageCollection->MessageUnseenCount = $iMessageUnseenCount;
|
|
||||||
|
|
||||||
if (\strlen($sSearch))
|
if (\strlen($sSearch))
|
||||||
{
|
{
|
||||||
$aUids = $this->GetUids($oParams->oCacher, $sSearch,
|
$aUids = $this->GetUids($oParams->oCacher, $sSearch,
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@ class MessageCollection extends \MailSo\Base\Collection
|
||||||
*/
|
*/
|
||||||
public $ThreadUid = 0;
|
public $ThreadUid = 0;
|
||||||
|
|
||||||
|
// MailSo\Imap\FolderInformation
|
||||||
|
public $FolderInfo = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|
@ -97,6 +100,7 @@ class MessageCollection extends \MailSo\Base\Collection
|
||||||
'MessageResultCount' => $this->MessageResultCount,
|
'MessageResultCount' => $this->MessageResultCount,
|
||||||
'Folder' => $this->FolderName,
|
'Folder' => $this->FolderName,
|
||||||
'FolderHash' => $this->FolderHash,
|
'FolderHash' => $this->FolderHash,
|
||||||
|
'FolderInfo' => $this->FolderInfo,
|
||||||
'UidNext' => $this->UidNext,
|
'UidNext' => $this->UidNext,
|
||||||
'ThreadUid' => $this->ThreadUid,
|
'ThreadUid' => $this->ThreadUid,
|
||||||
'NewMessages' => $this->NewMessages,
|
'NewMessages' => $this->NewMessages,
|
||||||
|
|
|
||||||
|
|
@ -426,13 +426,12 @@ trait Folders
|
||||||
);
|
);
|
||||||
$aInboxInformation['Flags'] = $aInboxInformation['MessagesFlags'];
|
$aInboxInformation['Flags'] = $aInboxInformation['MessagesFlags'];
|
||||||
unset($aInboxInformation['MessagesFlags']);
|
unset($aInboxInformation['MessagesFlags']);
|
||||||
|
return $this->DefaultResponse(__FUNCTION__, $aInboxInformation);
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
throw new ClientException(Notifications::MailServerError, $oException);
|
throw new ClientException(Notifications::MailServerError, $oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->DefaultResponse(__FUNCTION__, $aInboxInformation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue