mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 23:17:02 +03:00
v1.3.3.451
This commit is contained in:
parent
87f10aecd6
commit
8b9afa23bd
434 changed files with 1171 additions and 660 deletions
182
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/Attachment.php
Normal file
182
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/Attachment.php
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
*/
|
||||
class Attachment
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sFolder;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iUid;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Imap\BodyStructure
|
||||
*/
|
||||
private $oBodyStructure;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public function Clear()
|
||||
{
|
||||
$this->sFolder = '';
|
||||
$this->iUid = 0;
|
||||
$this->oBodyStructure = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Folder()
|
||||
{
|
||||
return $this->sFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function Uid()
|
||||
{
|
||||
return $this->iUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function MimeIndex()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->PartID() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bCalculateOnEmpty = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function FileName($bCalculateOnEmpty = false)
|
||||
{
|
||||
$sFileName = '';
|
||||
if ($this->oBodyStructure)
|
||||
{
|
||||
$sFileName = $this->oBodyStructure->FileName();
|
||||
if ($bCalculateOnEmpty && 0 === \strlen(trim($sFileName)))
|
||||
{
|
||||
$sMimeType = \strtolower(\trim($this->MimeType()));
|
||||
if ('message/rfc822' === $sMimeType)
|
||||
{
|
||||
$sFileName = 'message'.$this->MimeIndex().'.eml';
|
||||
}
|
||||
else if ('text/calendar' === $sMimeType)
|
||||
{
|
||||
$sFileName = 'calendar'.$this->MimeIndex().'.ics';
|
||||
}
|
||||
else if (0 < \strlen($sMimeType))
|
||||
{
|
||||
$sFileName = \str_replace('/', $this->MimeIndex().'.', $sMimeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function MimeType()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->ContentType() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentTransferEncoding()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->MailEncodingName() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function EncodedSize()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->Size() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function EstimatedSize()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->EstimatedSize() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Cid()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->ContentID() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsInline()
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->IsInline() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFolder
|
||||
* @param int $iUid
|
||||
* @param \MailSo\Imap\BodyStructure $oBodyStructure
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public static function NewBodyStructureInstance($sFolder, $iUid, $oBodyStructure)
|
||||
{
|
||||
return self::NewInstance()->InitByBodyStructure($sFolder, $iUid, $oBodyStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFolder
|
||||
* @param int $iUid
|
||||
* @param \MailSo\Imap\BodyStructure $oBodyStructure
|
||||
* @return \MailSo\Mail\Attachment
|
||||
*/
|
||||
public function InitByBodyStructure($sFolder, $iUid, $oBodyStructure)
|
||||
{
|
||||
$this->sFolder = $sFolder;
|
||||
$this->iUid = $iUid;
|
||||
$this->oBodyStructure = $oBodyStructure;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
*/
|
||||
class AttachmentCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\AttachmentCollection
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function InlineCount()
|
||||
{
|
||||
$aList = $this->FilterList(function ($oAttachment) {
|
||||
return $oAttachment && $oAttachment->IsInline();
|
||||
});
|
||||
|
||||
return \is_array($aList) ? \count($aList) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function NonInlineCount()
|
||||
{
|
||||
$aList = $this->FilterList(function ($oAttachment) {
|
||||
return $oAttachment && !$oAttachment->IsInline();
|
||||
});
|
||||
|
||||
return \is_array($aList) ? \count($aList) : 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class Exception extends \MailSo\Base\Exceptions\Exception {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class NonEmptyFolder extends \MailSo\Mail\Exceptions\RuntimeException {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail\Exceptions;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
* @subpackage Exceptions
|
||||
*/
|
||||
class RuntimeException extends \MailSo\Mail\Exceptions\Exception {}
|
||||
305
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/Folder.php
Normal file
305
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/Folder.php
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
*/
|
||||
class Folder
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sParentFullNameRaw;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iNestingLevel;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bExisten;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bSubscribed;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Imap\Folder
|
||||
*/
|
||||
private $oImapFolder;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mail\FolderCollection
|
||||
*/
|
||||
private $oSubFolders;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
* @param \MailSo\Imap\Folder $oImapFolder
|
||||
* @param bool $bSubscribed = true
|
||||
* @param bool $bExisten = true
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
private function __construct($oImapFolder, $bSubscribed = true, $bExisten = true)
|
||||
{
|
||||
if ($oImapFolder instanceof \MailSo\Imap\Folder)
|
||||
{
|
||||
$this->oImapFolder = $oImapFolder;
|
||||
$this->oSubFolders = null;
|
||||
|
||||
$aNames = \explode($this->oImapFolder->Delimiter(), $this->oImapFolder->FullNameRaw());
|
||||
$this->iNestingLevel = \count($aNames);
|
||||
|
||||
$this->sParentFullNameRaw = '';
|
||||
if (1 < $this->iNestingLevel)
|
||||
{
|
||||
\array_pop($aNames);
|
||||
$this->sParentFullNameRaw = \implode($this->oImapFolder->Delimiter(), $aNames);
|
||||
}
|
||||
|
||||
$this->bSubscribed = $bSubscribed;
|
||||
$this->bExisten = $bExisten;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Imap\Folder $oImapFolder
|
||||
* @param bool $bSubscribed = true
|
||||
* @param bool $bExisten = true
|
||||
*
|
||||
* @return \MailSo\Mail\Folder
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public static function NewInstance($oImapFolder, $bSubscribed = true, $bExisten = true)
|
||||
{
|
||||
return new self($oImapFolder, $bSubscribed, $bExisten);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFullNameRaw
|
||||
* @param string $sDelimiter
|
||||
*
|
||||
* @return \MailSo\Mail\Folder
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public static function NewNonExistenInstance($sFullNameRaw, $sDelimiter)
|
||||
{
|
||||
return self::NewInstance(
|
||||
\MailSo\Imap\Folder::NewInstance($sFullNameRaw, $sDelimiter, array('\NoSelect')), true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Name()
|
||||
{
|
||||
return \MailSo\Base\Utils::ConvertEncoding($this->NameRaw(),
|
||||
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function FullName()
|
||||
{
|
||||
return \MailSo\Base\Utils::ConvertEncoding($this->FullNameRaw(),
|
||||
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function NameRaw()
|
||||
{
|
||||
return $this->oImapFolder->NameRaw();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function FullNameRaw()
|
||||
{
|
||||
return $this->oImapFolder->FullNameRaw();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ParentFullName()
|
||||
{
|
||||
return \MailSo\Base\Utils::ConvertEncoding($this->sParentFullNameRaw,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ParentFullNameRaw()
|
||||
{
|
||||
return $this->sParentFullNameRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Delimiter()
|
||||
{
|
||||
return $this->oImapFolder->Delimiter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function Flags()
|
||||
{
|
||||
return $this->oImapFolder->Flags();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function FlagsLowerCase()
|
||||
{
|
||||
return $this->oImapFolder->FlagsLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bCreateIfNull = false
|
||||
* @return \MailSo\Mail\FolderCollection
|
||||
*/
|
||||
public function SubFolders($bCreateIfNull = false)
|
||||
{
|
||||
if ($bCreateIfNull && !$this->oSubFolders)
|
||||
{
|
||||
$this->oSubFolders = FolderCollection::NewInstance();
|
||||
}
|
||||
|
||||
return $this->oSubFolders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function HasSubFolders()
|
||||
{
|
||||
return $this->oSubFolders && 0 < $this->oSubFolders->Count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function HasVisibleSubFolders()
|
||||
{
|
||||
$sList = array();
|
||||
if ($this->oSubFolders)
|
||||
{
|
||||
$sList = $this->oSubFolders->FilterList(function (\MailSo\Mail\Folder $oFolder) {
|
||||
return $oFolder->IsSubscribed();
|
||||
});
|
||||
}
|
||||
|
||||
return 0 < \count($sList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsSubscribed()
|
||||
{
|
||||
return $this->bSubscribed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsExisten()
|
||||
{
|
||||
return $this->bExisten;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsSelectable()
|
||||
{
|
||||
return $this->IsExisten() && $this->oImapFolder->IsSelectable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function Status()
|
||||
{
|
||||
return $this->oImapFolder->GetExtended('STATUS');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsInbox()
|
||||
{
|
||||
return $this->oImapFolder->IsInbox();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetFolderXListType()
|
||||
{
|
||||
$aFlags = $this->oImapFolder->FlagsLowerCase();
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::USER;
|
||||
|
||||
if (\is_array($aFlags))
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
case \in_array('\inbox', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::INBOX;
|
||||
break;
|
||||
case \in_array('\sent', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::SENT;
|
||||
break;
|
||||
case \in_array('\drafts', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::DRAFTS;
|
||||
break;
|
||||
case \in_array('\spam', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::SPAM;
|
||||
break;
|
||||
case \in_array('\bin', $aFlags):
|
||||
case \in_array('\trash', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::TRASH;
|
||||
break;
|
||||
case \in_array('\important', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::IMPORTANT;
|
||||
break;
|
||||
case \in_array('\starred', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::STARRED;
|
||||
break;
|
||||
case \in_array('\all', $aFlags):
|
||||
case \in_array('\archive', $aFlags):
|
||||
case \in_array('\allmail', $aFlags):
|
||||
$iXListType = \MailSo\Imap\Enumerations\FolderType::ALLMAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $iXListType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
*/
|
||||
class FolderCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sNamespace;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $FoldersHash;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $IsThreadsSupported;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $SystemFolders;
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->sNamespace = '';
|
||||
$this->FoldersHash = '';
|
||||
$this->SystemFolders = array();
|
||||
$this->IsThreadsSupported = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\FolderCollection
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFullNameRaw
|
||||
*
|
||||
* @return \MailSo\Mail\Folder|null
|
||||
*/
|
||||
public function &GetByFullNameRaw($sFullNameRaw)
|
||||
{
|
||||
$mResult = null;
|
||||
foreach ($this->aItems as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
|
||||
{
|
||||
if ($oFolder->FullNameRaw() === $sFullNameRaw)
|
||||
{
|
||||
$mResult = $oFolder;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetNamespace()
|
||||
{
|
||||
return $this->sNamespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sNamespace
|
||||
*
|
||||
* @return \MailSo\Mail\FolderCollection
|
||||
*/
|
||||
public function SetNamespace($sNamespace)
|
||||
{
|
||||
$this->sNamespace = $sNamespace;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aUnsortedMailFolders
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function InitByUnsortedMailFolderArray($aUnsortedMailFolders)
|
||||
{
|
||||
$this->Clear();
|
||||
|
||||
$aSortedByLenImapFolders = array();
|
||||
foreach ($aUnsortedMailFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ &$oMailFolder)
|
||||
{
|
||||
$aSortedByLenImapFolders[$oMailFolder->FullNameRaw()] =& $oMailFolder;
|
||||
unset($oMailFolder);
|
||||
}
|
||||
unset($aUnsortedMailFolders);
|
||||
|
||||
$aAddedFolders = array();
|
||||
foreach ($aSortedByLenImapFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ $oMailFolder)
|
||||
{
|
||||
$sDelimiter = $oMailFolder->Delimiter();
|
||||
$aFolderExplode = \explode($sDelimiter, $oMailFolder->FullNameRaw());
|
||||
|
||||
if (1 < \count($aFolderExplode))
|
||||
{
|
||||
\array_pop($aFolderExplode);
|
||||
|
||||
$sNonExistenFolderFullNameRaw = '';
|
||||
foreach ($aFolderExplode as $sFolderExplodeItem)
|
||||
{
|
||||
$sNonExistenFolderFullNameRaw .= (0 < \strlen($sNonExistenFolderFullNameRaw))
|
||||
? $sDelimiter.$sFolderExplodeItem : $sFolderExplodeItem;
|
||||
|
||||
if (!isset($aSortedByLenImapFolders[$sNonExistenFolderFullNameRaw]))
|
||||
{
|
||||
$aAddedFolders[$sNonExistenFolderFullNameRaw] =
|
||||
Folder::NewNonExistenInstance($sNonExistenFolderFullNameRaw, $sDelimiter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aSortedByLenImapFolders = \array_merge($aSortedByLenImapFolders, $aAddedFolders);
|
||||
unset($aAddedFolders);
|
||||
|
||||
\uasort($aSortedByLenImapFolders, function ($oFolderA, $oFolderB) {
|
||||
return \strnatcmp($oFolderA->FullNameRaw(), $oFolderB->FullNameRaw());
|
||||
});
|
||||
|
||||
foreach ($aSortedByLenImapFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ &$oMailFolder)
|
||||
{
|
||||
$this->AddWithPositionSearch($oMailFolder);
|
||||
unset($oMailFolder);
|
||||
}
|
||||
|
||||
unset($aSortedByLenImapFolders);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mail\Folder $oMailFolder
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function AddWithPositionSearch($oMailFolder)
|
||||
{
|
||||
$oItemFolder = null;
|
||||
$bIsAdded = false;
|
||||
$aList =& $this->GetAsArray();
|
||||
|
||||
foreach ($aList as /* @var $oItemFolder \MailSo\Mail\Folder */ $oItemFolder)
|
||||
{
|
||||
if ($oMailFolder instanceof \MailSo\Mail\Folder &&
|
||||
0 === \strpos($oMailFolder->FullNameRaw(), $oItemFolder->FullNameRaw().$oItemFolder->Delimiter()))
|
||||
{
|
||||
if ($oItemFolder->SubFolders(true)->AddWithPositionSearch($oMailFolder))
|
||||
{
|
||||
$bIsAdded = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bIsAdded && $oMailFolder instanceof \MailSo\Mail\Folder)
|
||||
{
|
||||
$bIsAdded = true;
|
||||
$this->Add($oMailFolder);
|
||||
}
|
||||
|
||||
return $bIsAdded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable $fCallback
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function SortByCallback($fCallback)
|
||||
{
|
||||
if (\is_callable($fCallback))
|
||||
{
|
||||
$aList =& $this->GetAsArray();
|
||||
|
||||
\usort($aList, $fCallback);
|
||||
|
||||
foreach ($aList as &$oItemFolder)
|
||||
{
|
||||
if ($oItemFolder->HasSubFolders())
|
||||
{
|
||||
$oItemFolder->SubFolders()->SortByCallback($fCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1994
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/MailClient.php
Normal file
1994
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/MailClient.php
Normal file
File diff suppressed because it is too large
Load diff
739
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/Message.php
Normal file
739
rainloop/v/1.3.3.451/app/libraries/MailSo/Mail/Message.php
Normal file
|
|
@ -0,0 +1,739 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
*/
|
||||
class Message
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sFolder;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iUid;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sSubject;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sMessageId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sContentType;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iSize;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iInternalTimeStampInUTC;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iHeaderTimeStampInUTC;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sHeaderDate;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aFlags;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aFlagsLowerCase;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
private $oFrom;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
private $oSender;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
private $oReplyTo;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
private $oTo;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
private $oCc;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
private $oBcc;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sInReplyTo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sPlain;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sHtml;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mail\AttachmentCollection
|
||||
*/
|
||||
private $oAttachments;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aDraftInfo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sReferences;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iSensitivity;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iPriority;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sReadingConfirmation;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aThreads;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iParentThread;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iThreadsLen;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\Message
|
||||
*/
|
||||
public function Clear()
|
||||
{
|
||||
$this->sFolder = '';
|
||||
$this->iUid = 0;
|
||||
$this->sSubject = '';
|
||||
$this->sMessageId = '';
|
||||
$this->sContentType = '';
|
||||
$this->iSize = 0;
|
||||
$this->iInternalTimeStampInUTC = 0;
|
||||
$this->iHeaderTimeStampInUTC = 0;
|
||||
$this->sHeaderDate = '';
|
||||
$this->aFlags = array();
|
||||
$this->aFlagsLowerCase = array();
|
||||
|
||||
$this->oFrom = null;
|
||||
$this->oSender = null;
|
||||
$this->oReplyTo = null;
|
||||
$this->oTo = null;
|
||||
$this->oCc = null;
|
||||
$this->oBcc = null;
|
||||
|
||||
$this->sPlain = '';
|
||||
$this->sHtml = '';
|
||||
|
||||
$this->oAttachments = null;
|
||||
$this->aDraftInfo = null;
|
||||
|
||||
$this->sInReplyTo = '';
|
||||
$this->sReferences = '';
|
||||
|
||||
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::NOTHING;
|
||||
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
|
||||
$this->sReadingConfirmation = '';
|
||||
|
||||
$this->aThreads = array();
|
||||
$this->iThreadsLen = 0;
|
||||
$this->iParentThread = 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\Message
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Plain()
|
||||
{
|
||||
return $this->sPlain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Html()
|
||||
{
|
||||
return $this->sHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHtml
|
||||
*
|
||||
* @retun void
|
||||
*/
|
||||
public function SetHtml($sHtml)
|
||||
{
|
||||
$this->sHtml = $sHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Folder()
|
||||
{
|
||||
return $this->sFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function Uid()
|
||||
{
|
||||
return $this->iUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function MessageId()
|
||||
{
|
||||
return $this->sMessageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Subject()
|
||||
{
|
||||
return $this->sSubject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentType()
|
||||
{
|
||||
return $this->sContentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function Size()
|
||||
{
|
||||
return $this->iSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function InternalTimeStampInUTC()
|
||||
{
|
||||
return $this->iInternalTimeStampInUTC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function HeaderTimeStampInUTC()
|
||||
{
|
||||
return $this->iHeaderTimeStampInUTC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function HeaderDate()
|
||||
{
|
||||
return $this->sHeaderDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function Flags()
|
||||
{
|
||||
return $this->aFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function FlagsLowerCase()
|
||||
{
|
||||
return $this->aFlagsLowerCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function From()
|
||||
{
|
||||
return $this->oFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function Sensitivity()
|
||||
{
|
||||
return $this->iSensitivity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function Priority()
|
||||
{
|
||||
return $this->iPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function Sender()
|
||||
{
|
||||
return $this->oSender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function ReplyTo()
|
||||
{
|
||||
return $this->oReplyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function To()
|
||||
{
|
||||
return $this->oTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function Cc()
|
||||
{
|
||||
return $this->oCc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function Bcc()
|
||||
{
|
||||
return $this->oBcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\AttachmentCollection
|
||||
*/
|
||||
public function Attachments()
|
||||
{
|
||||
return $this->oAttachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function InReplyTo()
|
||||
{
|
||||
return $this->sInReplyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function References()
|
||||
{
|
||||
return $this->sReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ReadingConfirmation()
|
||||
{
|
||||
return $this->sReadingConfirmation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array | null
|
||||
*/
|
||||
public function DraftInfo()
|
||||
{
|
||||
return $this->aDraftInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function Threads()
|
||||
{
|
||||
return $this->aThreads;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aThreads
|
||||
*/
|
||||
public function SetThreads($aThreads)
|
||||
{
|
||||
$this->aThreads = \is_array($aThreads) ? $aThreads : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function ThreadsLen()
|
||||
{
|
||||
return $this->iThreadsLen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iThreadsLen
|
||||
*/
|
||||
public function SetThreadsLen($iThreadsLen)
|
||||
{
|
||||
$this->iThreadsLen = $iThreadsLen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function ParentThread()
|
||||
{
|
||||
return $this->iParentThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iParentThread
|
||||
*/
|
||||
public function SetParentThread($iParentThread)
|
||||
{
|
||||
$this->iParentThread = $iParentThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFolder
|
||||
* @param \MailSo\Imap\FetchResponse $oFetchResponse
|
||||
* @param \MailSo\Imap\BodyStructure $oBodyStructure = null
|
||||
*
|
||||
* @return \MailSo\Mail\Message
|
||||
*/
|
||||
public static function NewFetchResponseInstance($sFolder, $oFetchResponse, $oBodyStructure = null)
|
||||
{
|
||||
return self::NewInstance()->InitByFetchResponse($sFolder, $oFetchResponse, $oBodyStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFolder
|
||||
* @param \MailSo\Imap\FetchResponse $oFetchResponse
|
||||
* @param \MailSo\Imap\BodyStructure $oBodyStructure = null
|
||||
*
|
||||
* @return \MailSo\Mail\Message
|
||||
*/
|
||||
public function InitByFetchResponse($sFolder, $oFetchResponse, $oBodyStructure = null)
|
||||
{
|
||||
if (!$oBodyStructure)
|
||||
{
|
||||
$oBodyStructure = $oFetchResponse->GetFetchBodyStructure();
|
||||
}
|
||||
|
||||
$aTextParts = $oBodyStructure ? $oBodyStructure->SearchHtmlOrPlainParts() : array();
|
||||
|
||||
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
|
||||
$sSize = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::RFC822_SIZE);
|
||||
$sInternalDate = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::INTERNALDATE);
|
||||
$aFlags = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::FLAGS);
|
||||
|
||||
$this->sFolder = $sFolder;
|
||||
$this->iUid = \is_numeric($sUid) ? (int) $sUid : 0;
|
||||
$this->iSize = \is_numeric($sSize) ? (int) $sSize : 0;
|
||||
$this->aFlags = \is_array($aFlags) ? $aFlags : array();
|
||||
$this->aFlagsLowerCase = \array_map('strtolower', $this->aFlags);
|
||||
|
||||
$this->iInternalTimeStampInUTC =
|
||||
\MailSo\Base\DateTimeHelper::ParseInternalDateString($sInternalDate);
|
||||
|
||||
$sCharset = $oBodyStructure ? $oBodyStructure->SearchCharset() : '';
|
||||
|
||||
$sHeaders = $oFetchResponse->GetHeaderFieldsValue();
|
||||
if (0 < \strlen($sHeaders))
|
||||
{
|
||||
$oHeaders = \MailSo\Mime\HeaderCollection::NewInstance()->Parse($sHeaders);
|
||||
|
||||
$sContentTypeCharset = $oHeaders->ParameterValue(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\Parameter::CHARSET
|
||||
);
|
||||
|
||||
if (0 < \strlen($sContentTypeCharset))
|
||||
{
|
||||
$sCharset = $sContentTypeCharset;
|
||||
}
|
||||
|
||||
if (0 < \strlen($sCharset))
|
||||
{
|
||||
$oHeaders->SetParentCharset($sCharset);
|
||||
}
|
||||
|
||||
$this->sSubject = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SUBJECT, true);
|
||||
$this->sMessageId = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::MESSAGE_ID);
|
||||
$this->sContentType = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE);
|
||||
|
||||
$this->oFrom = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, true);
|
||||
$this->oTo = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::TO_, true);
|
||||
$this->oCc = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::CC, true);
|
||||
$this->oBcc = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::BCC, true);
|
||||
|
||||
$this->oSender = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::SENDER);
|
||||
$this->oReplyTo = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::REPLY_TO, true);
|
||||
|
||||
$this->sInReplyTo = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::IN_REPLY_TO);
|
||||
$this->sReferences = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::REFERENCES);
|
||||
|
||||
$sHeaderDate = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DATE);
|
||||
$this->sHeaderDate = $sHeaderDate;
|
||||
$this->iHeaderTimeStampInUTC = \MailSo\Base\DateTimeHelper::ParseRFC2822DateString($sHeaderDate);
|
||||
|
||||
// Sensitivity
|
||||
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::NOTHING;
|
||||
$sSensitivity = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SENSITIVITY);
|
||||
switch (\strtolower($sSensitivity))
|
||||
{
|
||||
case 'personal':
|
||||
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::PERSONAL;
|
||||
break;
|
||||
case 'private':
|
||||
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::PRIVATE_;
|
||||
break;
|
||||
case 'company-confidential':
|
||||
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::CONFIDENTIAL;
|
||||
break;
|
||||
}
|
||||
|
||||
// Priority
|
||||
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
|
||||
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_MSMAIL_PRIORITY);
|
||||
if (0 === \strlen($sPriority))
|
||||
{
|
||||
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::IMPORTANCE);
|
||||
}
|
||||
if (0 === \strlen($sPriority))
|
||||
{
|
||||
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_PRIORITY);
|
||||
}
|
||||
if (0 < \strlen($sPriority))
|
||||
{
|
||||
switch (\str_replace(' ', '', \strtolower($sPriority)))
|
||||
{
|
||||
case 'high':
|
||||
case '1(highest)':
|
||||
case '2(high)':
|
||||
case '1':
|
||||
case '2':
|
||||
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::HIGH;
|
||||
break;
|
||||
|
||||
case 'low':
|
||||
case '4(low)':
|
||||
case '5(lowest)':
|
||||
case '4':
|
||||
case '5':
|
||||
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::LOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ReadingConfirmation
|
||||
$this->sReadingConfirmation = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO);
|
||||
if (0 === \strlen($this->sReadingConfirmation))
|
||||
{
|
||||
$this->sReadingConfirmation = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO);
|
||||
}
|
||||
|
||||
$this->sReadingConfirmation = \trim($this->sReadingConfirmation);
|
||||
|
||||
$sDraftInfo = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_DRAFT_INFO);
|
||||
if (0 < \strlen($sDraftInfo))
|
||||
{
|
||||
$sType = '';
|
||||
$sFolder = '';
|
||||
$sUid = '';
|
||||
|
||||
\MailSo\Mime\ParameterCollection::NewInstance($sDraftInfo)
|
||||
->ForeachList(function ($oParameter) use (&$sType, &$sFolder, &$sUid) {
|
||||
|
||||
switch (\strtolower($oParameter->Name()))
|
||||
{
|
||||
case 'type':
|
||||
$sType = $oParameter->Value();
|
||||
break;
|
||||
case 'uid':
|
||||
$sUid = $oParameter->Value();
|
||||
break;
|
||||
case 'folder':
|
||||
$sFolder = \base64_decode($oParameter->Value());
|
||||
break;
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
if (0 < \strlen($sType) && 0 < \strlen($sFolder) && 0 < \strlen($sUid))
|
||||
{
|
||||
$this->aDraftInfo = array($sType, $sUid, $sFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($oFetchResponse->GetEnvelope())
|
||||
{
|
||||
if (0 === \strlen($sCharset) && $oBodyStructure)
|
||||
{
|
||||
$sCharset = $oBodyStructure->SearchCharset();
|
||||
}
|
||||
|
||||
if (0 === \strlen($sCharset))
|
||||
{
|
||||
$sCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1;
|
||||
}
|
||||
|
||||
// date, subject, from, sender, reply-to, to, cc, bcc, in-reply-to, message-id
|
||||
$this->sMessageId = $oFetchResponse->GetFetchEnvelopeValue(9, '');
|
||||
$this->sSubject = \MailSo\Base\Utils::DecodeHeaderValue($oFetchResponse->GetFetchEnvelopeValue(1, ''), $sCharset);
|
||||
|
||||
$this->oFrom = $oFetchResponse->GetFetchEnvelopeEmailCollection(2, $sCharset);
|
||||
$this->oSender = $oFetchResponse->GetFetchEnvelopeEmailCollection(3, $sCharset);
|
||||
$this->oReplyTo = $oFetchResponse->GetFetchEnvelopeEmailCollection(4, $sCharset);
|
||||
$this->oTo = $oFetchResponse->GetFetchEnvelopeEmailCollection(5, $sCharset);
|
||||
$this->oCc = $oFetchResponse->GetFetchEnvelopeEmailCollection(6, $sCharset);
|
||||
$this->oBcc = $oFetchResponse->GetFetchEnvelopeEmailCollection(7, $sCharset);
|
||||
$this->sInReplyTo = $oFetchResponse->GetFetchEnvelopeValue(8, '');
|
||||
}
|
||||
|
||||
if (\is_array($aTextParts) && 0 < \count($aTextParts))
|
||||
{
|
||||
$sHtmlParts = array();
|
||||
$sPlainParts = array();
|
||||
|
||||
foreach ($aTextParts as $oPart)
|
||||
{
|
||||
$sText = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY.'['.$oPart->PartID().']');
|
||||
if (\is_string($sText) && 0 < \strlen($sText))
|
||||
{
|
||||
$sTextCharset = $oPart->Charset();
|
||||
if (empty($sTextCharset))
|
||||
{
|
||||
$sTextCharset = $sCharset;
|
||||
}
|
||||
|
||||
$sText = \MailSo\Base\Utils::DecodeEncodingValue($sText, $oPart->MailEncodingName());
|
||||
$sText = \MailSo\Base\Utils::ConvertEncoding($sText, $sTextCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
$sText = \MailSo\Base\Utils::Utf8Clear($sText);
|
||||
|
||||
if ('text/html' === $oPart->ContentType())
|
||||
{
|
||||
$sHtmlParts[] = $sText;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sPlainParts[] = $sText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < \count($sHtmlParts))
|
||||
{
|
||||
$this->sHtml = \implode('<br />', $sHtmlParts);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sPlain = \implode("\n", $sPlainParts);
|
||||
}
|
||||
|
||||
unset($sHtmlParts, $sPlainParts);
|
||||
}
|
||||
|
||||
if ($oBodyStructure)
|
||||
{
|
||||
$aAttachmentsParts = $oBodyStructure->SearchAttachmentsParts();
|
||||
if ($aAttachmentsParts && 0 < count($aAttachmentsParts))
|
||||
{
|
||||
$this->oAttachments = AttachmentCollection::NewInstance();
|
||||
foreach ($aAttachmentsParts as /* @var $oAttachmentItem \MailSo\Imap\BodyStructure */ $oAttachmentItem)
|
||||
{
|
||||
$this->oAttachments->Add(
|
||||
\MailSo\Mail\Attachment::NewBodyStructureInstance($this->sFolder, $this->iUid, $oAttachmentItem)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo\Mail;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Mail
|
||||
*/
|
||||
class MessageCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $FolderHash;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $MessageCount;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $MessageUnseenCount;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $MessageResultCount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $FolderName;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $Offset;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $Limit;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Search;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $UidNext;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $NewMessages;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $LastCollapsedThreadUids;
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\MessageCollection
|
||||
*/
|
||||
public static function NewInstance()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mail\MessageCollection
|
||||
*/
|
||||
public function Clear()
|
||||
{
|
||||
parent::Clear();
|
||||
|
||||
$this->FolderHash = '';
|
||||
|
||||
$this->MessageCount = 0;
|
||||
$this->MessageUnseenCount = 0;
|
||||
$this->MessageResultCount = 0;
|
||||
|
||||
$this->FolderName = '';
|
||||
$this->Offset = 0;
|
||||
$this->Limit = 0;
|
||||
$this->Search = '';
|
||||
$this->UidNext = '';
|
||||
$this->NewMessages = array();
|
||||
|
||||
$this->LastCollapsedThreadUids = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue