Promises (first look)

Thread dropdown
Small fixes
This commit is contained in:
RainLoop Team 2015-03-14 03:10:00 +04:00
parent dd41d30f9b
commit c23ba31e17
61 changed files with 12442 additions and 130 deletions

View file

@ -2217,6 +2217,16 @@ END;
));
}
/**
* @param string $sIp
*
* @return bool
*/
public static function ValidateIP($sIp)
{
return !empty($sIp) && $sIp === @\filter_var($sIp, FILTER_VALIDATE_IP);
}
/**
* @return \Net_IDNA2
*/

View file

@ -154,6 +154,26 @@ class MailClient
return $this->oImapClient->IsLoggined();
}
/**
* @return string
*/
private function getEnvelopeOrHeadersRequestStringForSimpleList()
{
return \MailSo\Imap\Enumerations\FetchType::BuildBodyCustomHeaderRequest(array(
\MailSo\Mime\Enumerations\Header::RETURN_PATH,
\MailSo\Mime\Enumerations\Header::RECEIVED,
\MailSo\Mime\Enumerations\Header::MIME_VERSION,
\MailSo\Mime\Enumerations\Header::FROM_,
\MailSo\Mime\Enumerations\Header::TO_,
\MailSo\Mime\Enumerations\Header::CC,
\MailSo\Mime\Enumerations\Header::SENDER,
\MailSo\Mime\Enumerations\Header::REPLY_TO,
\MailSo\Mime\Enumerations\Header::DATE,
\MailSo\Mime\Enumerations\Header::SUBJECT,
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE
), true);
}
/**
* @return string
*/
@ -1622,11 +1642,12 @@ class MailClient
* @param \MailSo\Mail\MessageCollection &$oMessageCollection
* @param array $aRequestIndexOrUids
* @param bool $bIndexAsUid
* @param bool $bSimple = false
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageListByRequestIndexOrUids(&$oMessageCollection, $aRequestIndexOrUids, $bIndexAsUid)
public function MessageListByRequestIndexOrUids(&$oMessageCollection, $aRequestIndexOrUids, $bIndexAsUid, $bSimple = false)
{
if (\is_array($aRequestIndexOrUids) && 0 < \count($aRequestIndexOrUids))
{
@ -1637,7 +1658,8 @@ class MailClient
\MailSo\Imap\Enumerations\FetchType::INTERNALDATE,
\MailSo\Imap\Enumerations\FetchType::FLAGS,
\MailSo\Imap\Enumerations\FetchType::BODYSTRUCTURE,
$this->getEnvelopeOrHeadersRequestString()
$bSimple ? $this->getEnvelopeOrHeadersRequestStringForSimpleList() :
$this->getEnvelopeOrHeadersRequestString()
), \MailSo\Base\Utils::PrepearFetchSequence($aRequestIndexOrUids), $bIndexAsUid);
if (\is_array($aFetchResponse) && 0 < \count($aFetchResponse))
@ -1862,6 +1884,33 @@ class MailClient
return \array_map('trim', $aResult);
}
/**
* @param string $sFolderName
* @param array $aUids
*
* @return \MailSo\Mail\MessageCollection
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageListSimple($sFolderName, $aUids)
{
if (0 === \strlen($sFolderName) || !\MailSo\Base\Validator::NotEmptyArray($aUids))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->oImapClient->FolderExamine($sFolderName);
$oMessageCollection = \MailSo\Mail\MessageCollection::NewInstance();
$oMessageCollection->FolderName = $sFolderName;
$this->MessageListByRequestIndexOrUids($oMessageCollection, $aUids, true, true);
return $oMessageCollection->GetAsArray();
}
/**
* @param string $sFolderName
* @param int $iOffset = 0

View file

@ -1520,7 +1520,8 @@ class Actions
$aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
$aResult['DropboxApiKey'] = (string) $oConfig->Get('social', 'dropbox_api_key', '');
$aResult['SubscriptionEnabled'] = \MailSo\Base\Utils::ValidateDomain($aResult['AdminDomain']);
$aResult['SubscriptionEnabled'] = \MailSo\Base\Utils::ValidateDomain($aResult['AdminDomain']) ||
\MailSo\Base\Utils::ValidateIP($aResult['AdminDomain']);
$aResult['WeakPassword'] = $oConfig->ValidatePassword('12345');
$aResult['CoreAccess'] = $this->rainLoopCoreAccess();
@ -5478,6 +5479,40 @@ class Actions
return $this->DefaultResponse(__FUNCTION__, $oMessageList);
}
/**
* @return array
*
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoMessageListSimple()
{
// \sleep(2);
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList);
$sFolder = $this->GetActionParam('Folder', '');
$aUids = $this->GetActionParam('Uids', null);
if (0 === \strlen($sFolder) || !\is_array($aUids))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::InvalidInputArgument);
}
$this->initMailClientConnection();
$aMessageList = array();
try
{
$aMessageList = $this->MailClient()->MessageListSimple($sFolder, $aUids);
}
catch (\Exception $oException)
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList, $oException);
}
return $this->DefaultResponse(__FUNCTION__, $aMessageList);
}
/**
* @param \RainLoop\Model\Account $oAccount
* @param bool $bWithDraftInfo = true