Read Receipt (#41)

This commit is contained in:
RainLoop Team 2014-01-04 04:20:07 +04:00
parent 1dc5a45564
commit b100560cd8
37 changed files with 883 additions and 461 deletions

View file

@ -213,29 +213,35 @@ class MailClient
* @param bool $bIndexIsUid
* @param string $sMessageFlag
* @param bool $bSetAction = true
* @param bool $sSkipUnsupportedFlag = false
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
* @throws \MailSo\Mail\Exceptions\Exception
*/
public function MessageSetFlag($sFolderName, $aIndexRange, $bIndexIsUid, $sMessageFlag, $bSetAction = true)
public function MessageSetFlag($sFolderName, $aIndexRange, $bIndexIsUid, $sMessageFlag, $bSetAction = true, $sSkipUnsupportedFlag = false)
{
$this->oImapClient->FolderSelect($sFolderName);
$oFolderInfo = $this->oImapClient->FolderCurrentInformation();
if (!$oFolderInfo || !$oFolderInfo->IsFlagSupported($sMessageFlag))
{
throw new \MailSo\Mail\Exceptions\RuntimeException('Message flag is not supported.');
if (!$sSkipUnsupportedFlag)
{
throw new \MailSo\Mail\Exceptions\RuntimeException('Message flag is not supported.');
}
}
else
{
$sStoreAction = $bSetAction
? \MailSo\Imap\Enumerations\StoreAction::ADD_FLAGS_SILENT
: \MailSo\Imap\Enumerations\StoreAction::REMOVE_FLAGS_SILENT
;
$sStoreAction = $bSetAction
? \MailSo\Imap\Enumerations\StoreAction::ADD_FLAGS_SILENT
: \MailSo\Imap\Enumerations\StoreAction::REMOVE_FLAGS_SILENT
;
$sIndexRange = \implode(',', $aIndexRange);
$this->oImapClient->MessageStoreFlag($sIndexRange, $bIndexIsUid, array($sMessageFlag), $sStoreAction);
$sIndexRange = \implode(',', $aIndexRange);
$this->oImapClient->MessageStoreFlag($sIndexRange, $bIndexIsUid, array($sMessageFlag), $sStoreAction);
}
}
/**

View file

@ -136,7 +136,12 @@ class Message
/**
* @var string
*/
private $sReadingConfirmation;
private $sDeliveryReceipt;
/**
* @var string
*/
private $sReadReceipt;
/**
* @var array
@ -196,7 +201,8 @@ class Message
$this->iSensitivity = \MailSo\Mime\Enumerations\Sensitivity::NOTHING;
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
$this->sReadingConfirmation = '';
$this->sDeliveryReceipt = '';
$this->sReadReceipt = '';
$this->aThreads = array();
$this->iThreadsLen = 0;
@ -415,12 +421,28 @@ class Message
return $this->sReferences;
}
/**
* @return string
*/
public function DeliveryReceipt()
{
return $this->sDeliveryReceipt;
}
/**
* @return string
*/
public function ReadReceipt()
{
return $this->sReadReceipt;
}
/**
* @return string
*/
public function ReadingConfirmation()
{
return $this->sReadingConfirmation;
return $this->ReadReceipt();
}
/**
@ -615,15 +637,16 @@ class Message
}
}
// ReadingConfirmation
$this->sReadingConfirmation = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO);
if (0 === \strlen($this->sReadingConfirmation))
// Delivery Receipt
$this->sDeliveryReceipt = \trim($oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::RETURN_RECEIPT_TO));
// Read Receipt
$this->sReadReceipt = \trim($oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO));
if (empty($this->sReadReceipt))
{
$this->sReadingConfirmation = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO);
$this->sReadReceipt = \trim($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))
{

View file

@ -37,6 +37,7 @@ class Header
const SENSITIVITY = 'Sensitivity';
const RETURN_RECEIPT_TO = 'Return-Receipt-To';
const DISPOSITION_NOTIFICATION_TO = 'Disposition-Notification-To';
const X_CONFIRM_READING_TO = 'X-Confirm-Reading-To';

View file

@ -248,7 +248,7 @@ class Message
*
* @return \MailSo\Mime\Message
*/
public function SetReadConfirmation($sEmail)
public function SetReadReceipt($sEmail)
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO] = $sEmail;
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO] = $sEmail;
@ -256,6 +256,16 @@ class Message
return $this;
}
/**
* @param string $sEmail
*
* @return \MailSo\Mime\Message
*/
public function SetReadConfirmation($sEmail)
{
return $this->SetReadReceipt($sEmail);
}
/**
* @param int $iValue
*