Small fixes (Release commit)

This commit is contained in:
RainLoop Team 2014-11-05 23:40:20 +04:00
parent 8747ea59ac
commit eb30a1fe27
16 changed files with 155 additions and 55 deletions

View file

@ -63,7 +63,7 @@ class FolderCollection extends \MailSo\Base\Collection
*
* @return \MailSo\Mail\Folder|null
*/
public function &GetByFullNameRaw($sFullNameRaw)
public function GetByFullNameRaw($sFullNameRaw)
{
$mResult = null;
foreach ($this->aItems as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
@ -73,6 +73,18 @@ class FolderCollection extends \MailSo\Base\Collection
$mResult = $oFolder;
break;
}
else if ($oFolder->HasSubFolders())
{
$mResult = $oFolder->SubFolders(true)->GetByFullNameRaw($sFullNameRaw);
if ($mResult)
{
break;
}
else
{
$mResult = null;
}
}
}
return $mResult;
@ -97,7 +109,7 @@ class FolderCollection extends \MailSo\Base\Collection
return $this;
}
/**
* @param array $aUnsortedMailFolders
*

View file

@ -2095,41 +2095,45 @@ class MailClient
}
/**
* @param string $sFolderNameInUtf
* @param string $sFolderNameInUtf8
* @param string $sFolderParentFullNameRaw = ''
* @param bool $bSubscribeOnCreation = true
* @param string $sDelimiter = ''
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderCreate($sFolderNameInUtf, $sFolderParentFullNameRaw = '', $bSubscribeOnCreation = true)
public function FolderCreate($sFolderNameInUtf8, $sFolderParentFullNameRaw = '', $bSubscribeOnCreation = true, $sDelimiter = '')
{
if (!\MailSo\Base\Validator::NotEmptyString($sFolderNameInUtf, true) ||
if (!\MailSo\Base\Validator::NotEmptyString($sFolderNameInUtf8, true) ||
!\is_string($sFolderParentFullNameRaw))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$sFolderNameInUtf = trim($sFolderNameInUtf);
$sFolderNameInUtf8 = \trim($sFolderNameInUtf8);
$aFolders = $this->oImapClient->FolderList('', 0 === \strlen(\trim($sFolderParentFullNameRaw)) ? 'INBOX' : $sFolderParentFullNameRaw);
if (!\is_array($aFolders) || !isset($aFolders[0]))
if (0 === \strlen($sDelimiter) || 0 < \strlen(\trim($sFolderParentFullNameRaw)))
{
// TODO
throw new \MailSo\Mail\Exceptions\RuntimeException(
0 === \strlen(trim($sFolderParentFullNameRaw))
? 'Cannot get folder delimiter'
: 'Cannot create folder in non-existen parent folder');
$aFolders = $this->oImapClient->FolderList('', 0 === \strlen(\trim($sFolderParentFullNameRaw)) ? 'INBOX' : $sFolderParentFullNameRaw);
if (!\is_array($aFolders) || !isset($aFolders[0]))
{
// TODO
throw new \MailSo\Mail\Exceptions\RuntimeException(
0 === \strlen(trim($sFolderParentFullNameRaw))
? 'Cannot get folder delimiter'
: 'Cannot create folder in non-existen parent folder');
}
$sDelimiter = $aFolders[0]->Delimiter();
if (0 < \strlen($sDelimiter) && 0 < \strlen(\trim($sFolderParentFullNameRaw)))
{
$sFolderParentFullNameRaw .= $sDelimiter;
}
}
$sDelimiter = $aFolders[0]->Delimiter();
if (0 < \strlen($sDelimiter) && 0 < \strlen(\trim($sFolderParentFullNameRaw)))
{
$sFolderParentFullNameRaw .= $sDelimiter;
}
$sFullNameRawToCreate = \MailSo\Base\Utils::ConvertEncoding($sFolderNameInUtf,
$sFullNameRawToCreate = \MailSo\Base\Utils::ConvertEncoding($sFolderNameInUtf8,
\MailSo\Base\Enumerations\Charset::UTF_8,
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP);