コード例 #1
0
ファイル: manager.php プロジェクト: pkdevboxy/webmail-lite
 /**
  * @param int $iIdTenant
  *
  * @return bool
  */
 public function startMailboxMonitorPrev($iIdTenant)
 {
     $aData = $this->getHelpdeskMainSettings($iIdTenant);
     if (!empty($aData['AdminEmailAccount']) && 0 < $aData['HelpdeskFetcherType']) {
         $oApiUsers = $this->_getApiUsers();
         $oApiMail = $this->_getApiMail();
         $oApiFileCache = \CApi::Manager('filecache');
         $oApiFilestorage = \CApi::Manager('filestorage');
         if ($oApiUsers && $oApiMail && $oApiFileCache) {
             $oAccount = $oApiUsers->getAccountByEmail($aData['AdminEmailAccount']);
             if ($oAccount) {
                 $iPrevLastUid = $this->getHelpdeskMailboxLastUid($iIdTenant, \strtolower($oAccount->Email));
                 $iLastUid = 0;
                 $aData = $oApiMail->getMessagesForHelpdeskSynch($oAccount, 0 < $iPrevLastUid ? $iPrevLastUid + 1 : 0, $iLastUid);
                 if (0 < $iLastUid) {
                     $this->setHelpdeskMailboxLastUid($iIdTenant, \strtolower($oAccount->Email), $iLastUid);
                 }
                 if (is_array($aData) && 0 < count($aData)) {
                     foreach ($aData as $oMessage) {
                         $aMatch = array();
                         $oFrom = $oMessage->getFrom();
                         $aFrom = $oFrom ? $oFrom->GetAsArray() : array();
                         $oAttachments = $oMessage->getAttachments();
                         $aAttachments = $oAttachments ? $oAttachments->GetAsArray() : array();
                         $sSubject = $oMessage->getSubject();
                         if (is_array($aFrom) && 0 < count($aFrom) && !empty($sSubject) && preg_match('/\\[#([a-zA-Z0-9]+)#\\]/', $sSubject, $aMatch) && !empty($aMatch[1])) {
                             $oEmail = $aFrom[0];
                             $sEmail = $oEmail ? $oEmail->GetEmail() : '';
                             if (0 < \strlen($sEmail)) {
                                 $oHelpdeskUser = $this->getUserByEmail($iIdTenant, $sEmail);
                                 if ($oHelpdeskUser) {
                                     $sThreadHash = (string) $aMatch[1];
                                     if (!empty($sThreadHash)) {
                                         $iThreadID = $this->getThreadIdByHash($iIdTenant, $sThreadHash);
                                         if (0 < $iThreadID) {
                                             $oThread = $this->getThreadById($oHelpdeskUser, $iThreadID);
                                             if ($oThread) {
                                                 $sText = trim($oMessage->getHtml());
                                                 if (0 === strlen($sText)) {
                                                     $sText = trim($oMessage->getPlain());
                                                 } else {
                                                     $sText = \MailSo\Base\HtmlUtils::ConvertHtmlToPlain($sText);
                                                 }
                                                 $oPost = new \CHelpdeskPost();
                                                 $oPost->IdTenant = $oHelpdeskUser->IdTenant;
                                                 $oPost->IdOwner = $oHelpdeskUser->IdHelpdeskUser;
                                                 $oPost->IdHelpdeskThread = $oThread->IdHelpdeskThread;
                                                 $oPost->Type = \EHelpdeskPostType::Normal;
                                                 $oPost->SystemType = \EHelpdeskPostSystemType::None;
                                                 $oPost->Text = $sText;
                                                 $aResultAttachment = array();
                                                 if (is_array($aAttachments) && 0 < count($aAttachments)) {
                                                     foreach ($aAttachments as $oAttachment) {
                                                         $sUploadName = $oAttachment->getFileName(true);
                                                         $sTempName = md5($sUploadName . rand(1000, 9999));
                                                         $oApiMail->directMessageToStream($oAccount, function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($oHelpdeskUser, &$sTempName, $oApiFileCache) {
                                                             if (!$oApiFileCache->putFile($oHelpdeskUser, $sTempName, $rResource)) {
                                                                 $sTempName = '';
                                                             }
                                                         }, $oAttachment->getFolder(), $oAttachment->getUid(), $oAttachment->MimeIndex());
                                                         $rData = 0 < \strlen($sTempName) ? $oApiFileCache->getFile($oHelpdeskUser, $sTempName) : null;
                                                         if ($rData) {
                                                             $iFileSize = $oApiFileCache->fileSize($oHelpdeskUser, $sTempName);
                                                             $sThreadID = (string) $oThread->IdHelpdeskThread;
                                                             $sThreadID = str_pad($sThreadID, 2, '0', STR_PAD_LEFT);
                                                             $sThreadIDSubFolder = substr($sThreadID, 0, 2);
                                                             $sThreadFolderName = API_HELPDESK_PUBLIC_NAME . '/' . $sThreadIDSubFolder . '/' . $sThreadID;
                                                             $oApiFilestorage->createFolder($oHelpdeskUser, \EFileStorageType::Corporate, '', $sThreadFolderName);
                                                             $oApiFilestorage->createFile($oHelpdeskUser, \EFileStorageTypeStr::Corporate, $sThreadFolderName, $sUploadName, $rData, false);
                                                             if (is_resource($rData)) {
                                                                 @fclose($rData);
                                                             }
                                                             $oAttachment = new \CHelpdeskAttachment();
                                                             $oAttachment->IdHelpdeskThread = $oThread->IdHelpdeskThread;
                                                             $oAttachment->IdHelpdeskPost = $oPost->IdHelpdeskPost;
                                                             $oAttachment->IdOwner = $oHelpdeskUser->IdHelpdeskUser;
                                                             $oAttachment->IdTenant = $oHelpdeskUser->IdTenant;
                                                             $oAttachment->FileName = $sUploadName;
                                                             $oAttachment->SizeInBytes = $iFileSize;
                                                             $oAttachment->encodeHash($oHelpdeskUser, $sThreadFolderName);
                                                             $oApiFileCache->clear($oHelpdeskUser, $sTempName);
                                                             $aResultAttachment[] = $oAttachment;
                                                         }
                                                     }
                                                     if (is_array($aResultAttachment) && 0 < count($aResultAttachment)) {
                                                         $oPost->Attachments = $aResultAttachment;
                                                     }
                                                 }
                                                 $this->createPost($oHelpdeskUser, $oThread, $oPost, false, false);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         unset($oMessage);
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Actions.php プロジェクト: nsine/webmail-lite
 /**
  * @return bool
  */
 public function PostPdfFromHtml()
 {
     $oAccount = $this->getAccountFromParam();
     if ($oAccount) {
         $sSubject = (string) $this->getParamValue('Subject', '');
         $sHtml = (string) $this->getParamValue('Html', '');
         include_once PSEVEN_APP_ROOT_PATH . 'libraries/other/CssToInlineStyles.php';
         $oCssToInlineStyles = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($sHtml);
         $oCssToInlineStyles->setEncoding('utf-8');
         $oCssToInlineStyles->setUseInlineStylesBlock(true);
         $this->RawOutputHeaders(true, 'application/pdf', $sSubject . '.pdf');
         include_once PSEVEN_APP_ROOT_PATH . 'libraries/dompdf/dompdf_config.inc.php';
         $oDomPdf = new \DOMPDF();
         $oDomPdf->load_html('<html><head></head><body>' . \MailSo\Base\HtmlUtils::ClearHtmlSimple($oCssToInlineStyles->convert(), true, true) . '</body></html>');
         $oDomPdf->render();
         $oDomPdf->stream($sSubject . '.pdf', array('Attachment' => false));
         return true;
     }
     return false;
 }
コード例 #3
0
ファイル: HtmlUtils.php プロジェクト: nsdown/rainloop-webmail
 /**
  * @param string $sHtml
  * @param array $aFoundCids = array()
  * @param array|null $mFoundDataURL = null
  * @param array $aFoundedContentLocationUrls = array()
  *
  * @return string
  */
 public static function BuildHtml($sHtml, &$aFoundCids = array(), &$mFoundDataURL = null, &$aFoundedContentLocationUrls = array())
 {
     $oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml);
     unset($sHtml);
     $aNodes = $oDom->getElementsByTagName('*');
     foreach ($aNodes as $oElement) {
         $sTagNameLower = \strtolower($oElement->tagName);
         if ($oElement->hasAttribute('data-x-src-cid')) {
             $sCid = $oElement->getAttribute('data-x-src-cid');
             $oElement->removeAttribute('data-x-src-cid');
             if (!empty($sCid)) {
                 $aFoundCids[] = $sCid;
                 @$oElement->removeAttribute('src');
                 $oElement->setAttribute('src', 'cid:' . $sCid);
             }
         }
         if ($oElement->hasAttribute('data-x-src-location')) {
             $sSrc = $oElement->getAttribute('data-x-src-location');
             $oElement->removeAttribute('data-x-src-location');
             if (!empty($sSrc)) {
                 $aFoundedContentLocationUrls[] = $sSrc;
                 @$oElement->removeAttribute('src');
                 $oElement->setAttribute('src', $sSrc);
             }
         }
         if ($oElement->hasAttribute('data-x-broken-src')) {
             $oElement->setAttribute('src', $oElement->getAttribute('data-x-broken-src'));
             $oElement->removeAttribute('data-x-broken-src');
         }
         if ($oElement->hasAttribute('data-x-src')) {
             $oElement->setAttribute('src', $oElement->getAttribute('data-x-src'));
             $oElement->removeAttribute('data-x-src');
         }
         if ($oElement->hasAttribute('data-x-href')) {
             $oElement->setAttribute('href', $oElement->getAttribute('data-x-href'));
             $oElement->removeAttribute('data-x-href');
         }
         if ($oElement->hasAttribute('data-x-additional-src')) {
             $oElement->removeAttribute('data-x-additional-src');
         }
         if ($oElement->hasAttribute('data-x-additional-style-url')) {
             $oElement->removeAttribute('data-x-additional-style-url');
         }
         if ($oElement->hasAttribute('data-x-style-cid-name') && $oElement->hasAttribute('data-x-style-cid')) {
             $sCidName = $oElement->getAttribute('data-x-style-cid-name');
             $sCid = $oElement->getAttribute('data-x-style-cid');
             $oElement->removeAttribute('data-x-style-cid-name');
             $oElement->removeAttribute('data-x-style-cid');
             if (!empty($sCidName) && !empty($sCid) && \in_array($sCidName, array('background-image', 'background', 'list-style-image', 'content'))) {
                 $sStyles = '';
                 if ($oElement->hasAttribute('style')) {
                     $sStyles = \trim(\trim($oElement->getAttribute('style')), ';');
                 }
                 $sBack = $sCidName . ': url(cid:' . $sCid . ')';
                 $sStyles = \preg_replace('/' . \preg_quote($sCidName, '/') . ':\\s?[^;]+/i', $sBack, $sStyles);
                 if (false === \strpos($sStyles, $sBack)) {
                     $sStyles .= empty($sStyles) ? '' : '; ';
                     $sStyles .= $sBack;
                 }
                 $oElement->setAttribute('style', $sStyles);
                 $aFoundCids[] = $sCid;
             }
         }
         if ($oElement->hasAttribute('data-original')) {
             $oElement->removeAttribute('data-original');
         }
         if ($oElement->hasAttribute('data-x-div-type')) {
             $oElement->removeAttribute('data-x-div-type');
         }
         if ($oElement->hasAttribute('data-x-style-url')) {
             $sAddStyles = $oElement->getAttribute('data-x-style-url');
             $oElement->removeAttribute('data-x-style-url');
             if (!empty($sAddStyles)) {
                 $sStyles = '';
                 if ($oElement->hasAttribute('style')) {
                     $sStyles = \trim(\trim($oElement->getAttribute('style')), ';');
                 }
                 $oElement->setAttribute('style', (empty($sStyles) ? '' : $sStyles . '; ') . $sAddStyles);
             }
         }
         if ('img' === $sTagNameLower && \is_array($mFoundDataURL)) {
             $sSrc = $oElement->getAttribute('src');
             if ('data:image/' === \strtolower(\substr($sSrc, 0, 11))) {
                 $sHash = \md5($sSrc);
                 $mFoundDataURL[$sHash] = $sSrc;
                 $oElement->setAttribute('src', 'cid:' . $sHash);
             }
         }
     }
     $sResult = $oDom->saveHTML();
     unset($oDom);
     $sResult = \MailSo\Base\HtmlUtils::ClearTags($sResult);
     $sResult = \MailSo\Base\HtmlUtils::ClearBodyAndHtmlTag($sResult);
     return '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>' . '<body>' . \trim($sResult) . '</body></html>';
 }
コード例 #4
0
 /**
  * @param mixed $mResponse
  * @param string $sParent
  * @param array $aParameters = array()
  *
  * @return mixed
  */
 protected function responseObject($mResponse, $sParent = '', $aParameters = array())
 {
     $mResult = $mResponse;
     if (\is_object($mResponse)) {
         $bHook = true;
         $self = $this;
         $sClassName = \get_class($mResponse);
         $bHasSimpleJsonFunc = \method_exists($mResponse, 'ToSimpleJSON');
         $bThumb = $this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS);
         $oAccountCache = null;
         $fGetAccount = function () use($self, &$oAccountCache) {
             if (null === $oAccountCache) {
                 $oAccount = $self->getAccountFromToken(false);
                 $oAccountCache = $oAccount;
             }
             return $oAccountCache;
         };
         $aCheckableFoldersCache = null;
         $fGetCheckableFolder = function () use($self, &$aCheckableFoldersCache) {
             if (null === $aCheckableFoldersCache) {
                 $oAccount = $self->getAccountFromToken(false);
                 $oSettingsLocal = $self->SettingsProvider(true)->Load($oAccount);
                 $sCheckable = $oSettingsLocal->GetConf('CheckableFolder', '[]');
                 $aCheckable = @\json_decode($sCheckable);
                 if (!\is_array($aCheckable)) {
                     $aCheckable = array();
                 }
                 $aCheckableFoldersCache = $aCheckable;
             }
             return $aCheckableFoldersCache;
         };
         if ($bHasSimpleJsonFunc) {
             $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true));
         } else {
             if ('MailSo\\Mail\\Message' === $sClassName) {
                 $oAccount = \call_user_func($fGetAccount);
                 $iDateTimeStampInUTC = $mResponse->InternalTimeStampInUTC();
                 if (0 === $iDateTimeStampInUTC || !!$this->Config()->Get('labs', 'date_from_headers', false)) {
                     $iDateTimeStampInUTC = $mResponse->HeaderTimeStampInUTC();
                     if (0 === $iDateTimeStampInUTC) {
                         $iDateTimeStampInUTC = $mResponse->InternalTimeStampInUTC();
                     }
                 }
                 $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Subject' => \trim(\MailSo\Base\Utils::Utf8Clear($mResponse->Subject())), 'MessageId' => $mResponse->MessageId(), 'Size' => $mResponse->Size(), 'DateTimeStampInUTC' => $iDateTimeStampInUTC, 'ReplyTo' => $this->responseObject($mResponse->ReplyTo(), $sParent, $aParameters), 'From' => $this->responseObject($mResponse->From(), $sParent, $aParameters), 'To' => $this->responseObject($mResponse->To(), $sParent, $aParameters), 'Cc' => $this->responseObject($mResponse->Cc(), $sParent, $aParameters), 'Bcc' => $this->responseObject($mResponse->Bcc(), $sParent, $aParameters), 'Sender' => $this->responseObject($mResponse->Sender(), $sParent, $aParameters), 'DeliveredTo' => $this->responseObject($mResponse->DeliveredTo(), $sParent, $aParameters), 'Priority' => $mResponse->Priority(), 'Threads' => $mResponse->Threads(), 'Sensitivity' => $mResponse->Sensitivity(), 'ExternalProxy' => false, 'ReadReceipt' => ''));
                 $mResult['SubjectParts'] = $this->explodeSubject($mResult['Subject']);
                 $oAttachments = $mResponse->Attachments();
                 $iAttachmentsCount = $oAttachments ? $oAttachments->Count() : 0;
                 $mResult['HasAttachments'] = 0 < $iAttachmentsCount;
                 $mResult['AttachmentsSpecData'] = $mResult['HasAttachments'] ? $oAttachments->SpecData() : array();
                 $sSubject = $mResult['Subject'];
                 $mResult['Hash'] = \md5($mResult['Folder'] . $mResult['Uid']);
                 $mResult['RequestHash'] = \RainLoop\Utils::EncodeKeyValuesQ(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeType' => 'message/rfc822', 'FileName' => (0 === \strlen($sSubject) ? 'message-' . $mResult['Uid'] : \MailSo\Base\Utils::ClearXss($sSubject)) . '.eml'));
                 // Flags
                 $aFlags = $mResponse->FlagsLowerCase();
                 $mResult['IsSeen'] = \in_array('\\seen', $aFlags);
                 $mResult['IsFlagged'] = \in_array('\\flagged', $aFlags);
                 $mResult['IsAnswered'] = \in_array('\\answered', $aFlags);
                 $mResult['IsDeleted'] = \in_array('\\deleted', $aFlags);
                 $sForwardedFlag = $this->Config()->Get('labs', 'imap_forwarded_flag', '');
                 $sReadReceiptFlag = $this->Config()->Get('labs', 'imap_read_receipt_flag', '');
                 $mResult['IsForwarded'] = 0 < \strlen($sForwardedFlag) && \in_array(\strtolower($sForwardedFlag), $aFlags);
                 $mResult['IsReadReceipt'] = 0 < \strlen($sReadReceiptFlag) && \in_array(\strtolower($sReadReceiptFlag), $aFlags);
                 if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::COMPOSER, $oAccount)) {
                     $mResult['IsReadReceipt'] = true;
                 }
                 $mResult['TextPartIsTrimmed'] = false;
                 if ('Message' === $sParent) {
                     $oAttachments = $mResponse->Attachments();
                     $bHasExternals = false;
                     $mFoundedCIDs = array();
                     $aContentLocationUrls = array();
                     $mFoundedContentLocationUrls = array();
                     if ($oAttachments && 0 < $oAttachments->Count()) {
                         $aList =& $oAttachments->GetAsArray();
                         foreach ($aList as $oAttachment) {
                             if ($oAttachment) {
                                 $sContentLocation = $oAttachment->ContentLocation();
                                 if ($sContentLocation && 0 < \strlen($sContentLocation)) {
                                     $aContentLocationUrls[] = $oAttachment->ContentLocation();
                                 }
                             }
                         }
                     }
                     $sPlain = '';
                     $sHtml = \trim($mResponse->Html());
                     if (0 === \strlen($sHtml)) {
                         $sPlain = \trim($mResponse->Plain());
                     }
                     $mResult['DraftInfo'] = $mResponse->DraftInfo();
                     $mResult['InReplyTo'] = $mResponse->InReplyTo();
                     $mResult['References'] = $mResponse->References();
                     $fAdditionalDomReader = null;
                     if (0 < \strlen($sHtml) && $this->Config()->Get('labs', 'emogrifier', false)) {
                         if (!\class_exists('Pelago\\Emogrifier', false)) {
                             include_once APP_VERSION_ROOT_PATH . 'app/libraries/emogrifier/Emogrifier.php';
                         }
                         if (\class_exists('Pelago\\Emogrifier', false)) {
                             $fAdditionalDomReader = function ($oDom) {
                                 $oEmogrifier = new \Pelago\Emogrifier();
                                 $oEmogrifier->preserveEncoding = false;
                                 return $oEmogrifier->emogrify($oDom);
                             };
                         }
                     }
                     $fAdditionalExternalFilter = null;
                     if (!!$this->Config()->Get('labs', 'use_local_proxy_for_external_images', false)) {
                         $fAdditionalExternalFilter = function ($sUrl) {
                             return './?/ProxyExternal/' . \RainLoop\Utils::EncodeKeyValuesQ(array('Rnd' => \md5(\microtime(true)), 'Token' => \RainLoop\Utils::GetConnectionToken(), 'Url' => $sUrl)) . '/';
                         };
                     }
                     $sHtml = \preg_replace_callback('/(<pre[^>]*>)([\\s\\S\\r\\n\\t]*?)(<\\/pre>)/mi', function ($aMatches) {
                         return \preg_replace('/[\\r\\n]+/', '<br />', $aMatches[1] . \trim($aMatches[2]) . $aMatches[3]);
                     }, $sHtml);
                     $mResult['Html'] = 0 === \strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $mFoundedCIDs, $aContentLocationUrls, $mFoundedContentLocationUrls, false, false, $fAdditionalExternalFilter, $fAdditionalDomReader, !!$this->Config()->Get('labs', 'try_to_detect_hidden_images', false));
                     $mResult['ExternalProxy'] = null !== $fAdditionalExternalFilter;
                     $mResult['Plain'] = $sPlain;
                     //					$mResult['Plain'] = 0 === \strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain);
                     $mResult['TextHash'] = \md5($mResult['Html'] . $mResult['Plain']);
                     $mResult['TextPartIsTrimmed'] = $mResponse->TextPartIsTrimmed();
                     $mResult['PgpSigned'] = $mResponse->PgpSigned();
                     $mResult['PgpEncrypted'] = $mResponse->PgpEncrypted();
                     $mResult['PgpSignature'] = $mResponse->PgpSignature();
                     unset($sHtml, $sPlain);
                     $mResult['HasExternals'] = $bHasExternals;
                     $mResult['HasInternals'] = \is_array($mFoundedCIDs) && 0 < \count($mFoundedCIDs) || \is_array($mFoundedContentLocationUrls) && 0 < \count($mFoundedContentLocationUrls);
                     $mResult['FoundedCIDs'] = $mFoundedCIDs;
                     $mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, \array_merge($aParameters, array('FoundedCIDs' => $mFoundedCIDs, 'FoundedContentLocationUrls' => $mFoundedContentLocationUrls)));
                     $mResult['ReadReceipt'] = $mResponse->ReadReceipt();
                     if (0 < \strlen($mResult['ReadReceipt']) && !$mResult['IsReadReceipt']) {
                         if (0 < \strlen($mResult['ReadReceipt'])) {
                             try {
                                 $oReadReceipt = \MailSo\Mime\Email::Parse($mResult['ReadReceipt']);
                                 if (!$oReadReceipt) {
                                     $mResult['ReadReceipt'] = '';
                                 }
                             } catch (\Exception $oException) {
                                 unset($oException);
                             }
                         }
                         if (0 < \strlen($mResult['ReadReceipt']) && '1' === $this->Cacher($oAccount)->Get(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $mResult['Folder'], $mResult['Uid']), '0')) {
                             $mResult['ReadReceipt'] = '';
                         }
                     }
                 }
             } else {
                 if ('MailSo\\Mime\\Email' === $sClassName) {
                     $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetDisplayName()), 'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail(true)), 'DkimStatus' => $mResponse->GetDkimStatus(), 'DkimValue' => $mResponse->GetDkimValue()));
                 } else {
                     if ('RainLoop\\Providers\\AddressBook\\Classes\\Contact' === $sClassName) {
                         $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContact' => $mResponse->IdContact, 'Display' => \MailSo\Base\Utils::Utf8Clear($mResponse->Display), 'ReadOnly' => $mResponse->ReadOnly, 'IdPropertyFromSearch' => $mResponse->IdPropertyFromSearch, 'Properties' => $this->responseObject($mResponse->Properties, $sParent, $aParameters)));
                     } else {
                         if ('RainLoop\\Providers\\AddressBook\\Classes\\Tag' === $sClassName) {
                             $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContactTag' => $mResponse->IdContactTag, 'Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->Name), 'ReadOnly' => $mResponse->ReadOnly));
                         } else {
                             if ('RainLoop\\Providers\\AddressBook\\Classes\\Property' === $sClassName) {
                                 // Simple hack
                                 if ($mResponse && $mResponse->IsWeb()) {
                                     $mResponse->Value = \preg_replace('/(skype|ftp|http[s]?)\\\\:\\/\\//i', '$1://', $mResponse->Value);
                                 }
                                 $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdProperty' => $mResponse->IdProperty, 'Type' => $mResponse->Type, 'TypeStr' => $mResponse->TypeStr, 'Value' => \MailSo\Base\Utils::Utf8Clear($mResponse->Value)));
                             } else {
                                 if ('MailSo\\Mail\\Attachment' === $sClassName) {
                                     $oAccount = $this->getAccountFromToken(false);
                                     $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && \is_array($aParameters['FoundedCIDs']) && 0 < \count($aParameters['FoundedCIDs']) ? $aParameters['FoundedCIDs'] : null;
                                     $mFoundedContentLocationUrls = isset($aParameters['FoundedContentLocationUrls']) && \is_array($aParameters['FoundedContentLocationUrls']) && 0 < \count($aParameters['FoundedContentLocationUrls']) ? $aParameters['FoundedContentLocationUrls'] : null;
                                     if ($mFoundedCIDs || $mFoundedContentLocationUrls) {
                                         $mFoundedCIDs = \array_merge($mFoundedCIDs ? $mFoundedCIDs : array(), $mFoundedContentLocationUrls ? $mFoundedContentLocationUrls : array());
                                         $mFoundedCIDs = 0 < \count($mFoundedCIDs) ? $mFoundedCIDs : null;
                                     }
                                     $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Framed' => false, 'MimeIndex' => (string) $mResponse->MimeIndex(), 'MimeType' => $mResponse->MimeType(), 'FileName' => \MailSo\Base\Utils::ClearFileName(\MailSo\Base\Utils::ClearXss($mResponse->FileName(true))), 'EstimatedSize' => $mResponse->EstimatedSize(), 'CID' => $mResponse->Cid(), 'ContentLocation' => $mResponse->ContentLocation(), 'IsInline' => $mResponse->IsInline(), 'IsThumbnail' => $bThumb, 'IsLinked' => $mFoundedCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundedCIDs) || $mFoundedContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundedContentLocationUrls)));
                                     $mResult['Framed'] = $this->isFileHasFramedPreview($mResult['FileName']);
                                     if ($mResult['IsThumbnail']) {
                                         $mResult['IsThumbnail'] = $this->isFileHasThumbnail($mResult['FileName']);
                                     }
                                     $mResult['Download'] = \RainLoop\Utils::EncodeKeyValuesQ(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeIndex' => $mResult['MimeIndex'], 'MimeType' => $mResult['MimeType'], 'FileName' => $mResult['FileName'], 'Framed' => $mResult['Framed']));
                                 } else {
                                     if ('MailSo\\Mail\\Folder' === $sClassName) {
                                         $aExtended = null;
                                         //				$mStatus = $mResponse->Status();
                                         //				if (\is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT']))
                                         //				{
                                         //					$aExtended = array(
                                         //						'MessageCount' => (int) $mStatus['MESSAGES'],
                                         //						'MessageUnseenCount' => (int) $mStatus['UNSEEN'],
                                         //						'UidNext' => (string) $mStatus['UIDNEXT'],
                                         //						'Hash' => $this->MailClient()->GenerateFolderHash(
                                         //							$mResponse->FullNameRaw(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'],
                                         //								empty($mStatus['HIGHESTMODSEQ']) ? '' : $mStatus['HIGHESTMODSEQ'])
                                         //					);
                                         //				}
                                         $aCheckableFolder = \call_user_func($fGetCheckableFolder);
                                         if (!\is_array($aCheckableFolder)) {
                                             $aCheckableFolder = array();
                                         }
                                         $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => $mResponse->Name(), 'FullName' => $mResponse->FullName(), 'FullNameRaw' => $mResponse->FullNameRaw(), 'FullNameHash' => $this->hashFolderFullName($mResponse->FullNameRaw(), $mResponse->FullName()), 'Delimiter' => (string) $mResponse->Delimiter(), 'HasVisibleSubFolders' => $mResponse->HasVisibleSubFolders(), 'IsSubscribed' => $mResponse->IsSubscribed(), 'IsExists' => $mResponse->IsExists(), 'IsSelectable' => $mResponse->IsSelectable(), 'Flags' => $mResponse->FlagsLowerCase(), 'Checkable' => \in_array($mResponse->FullNameRaw(), $aCheckableFolder), 'Extended' => $aExtended, 'SubFolders' => $this->responseObject($mResponse->SubFolders(), $sParent, $aParameters)));
                                     } else {
                                         if ('MailSo\\Mail\\MessageCollection' === $sClassName) {
                                             $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('MessageCount' => $mResponse->MessageCount, 'MessageUnseenCount' => $mResponse->MessageUnseenCount, 'MessageResultCount' => $mResponse->MessageResultCount, 'Folder' => $mResponse->FolderName, 'FolderHash' => $mResponse->FolderHash, 'UidNext' => $mResponse->UidNext, 'ThreadUid' => $mResponse->ThreadUid, 'NewMessages' => $this->responseObject($mResponse->NewMessages), 'Filtered' => $mResponse->Filtered, 'Offset' => $mResponse->Offset, 'Limit' => $mResponse->Limit, 'Search' => $mResponse->Search));
                                         } else {
                                             if ('MailSo\\Mail\\AttachmentCollection' === $sClassName) {
                                                 $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('InlineCount' => $mResponse->InlineCount()));
                                             } else {
                                                 if ('MailSo\\Mail\\FolderCollection' === $sClassName) {
                                                     $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Namespace' => $mResponse->GetNamespace(), 'FoldersHash' => isset($mResponse->FoldersHash) ? $mResponse->FoldersHash : '', 'IsThreadsSupported' => $mResponse->IsThreadsSupported, 'Optimized' => $mResponse->Optimized, 'CountRec' => $mResponse->CountRec(), 'SystemFolders' => isset($mResponse->SystemFolders) && \is_array($mResponse->SystemFolders) ? $mResponse->SystemFolders : array()));
                                                 } else {
                                                     if ($mResponse instanceof \MailSo\Base\Collection) {
                                                         $aList =& $mResponse->GetAsArray();
                                                         if (100 < \count($aList) && $mResponse instanceof \MailSo\Mime\EmailCollection) {
                                                             $aList = \array_slice($aList, 0, 100);
                                                         }
                                                         $mResult = $this->responseObject($aList, $sParent, $aParameters);
                                                         $bHook = false;
                                                     } else {
                                                         $mResult = '["' . \get_class($mResponse) . '"]';
                                                         $bHook = false;
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($bHook) {
             $this->Plugins()->RunHook('filter.response-object', array($sClassName, $mResult), false);
         }
     } else {
         if (\is_array($mResponse)) {
             foreach ($mResponse as $iKey => $oItem) {
                 $mResponse[$iKey] = $this->responseObject($oItem, $sParent, $aParameters);
             }
             $mResult = $mResponse;
         }
     }
     unset($mResponse);
     return $mResult;
 }
コード例 #5
0
ファイル: ActionsBase.php プロジェクト: Git-Host/email
 /**
  * @param \CAccount $oAccount
  * @param mixed $mResponse
  * @param string $sParent
  * @param array $aParameters = array()
  *
  * @return mixed
  */
 protected function responseObject($oAccount, $mResponse, $sParent, $aParameters = array())
 {
     $mResult = $mResponse;
     if (is_object($mResponse)) {
         $sClassName = get_class($mResponse);
         if ('CApiMailMessage' === $sClassName) {
             $iTrimmedLimit = \CApi::GetConf('labs.message-body-size-limit', 0);
             $oAttachments = $mResponse->getAttachments();
             $iInternalTimeStampInUTC = $mResponse->getInternalTimeStamp();
             $iReceivedOrDateTimeStampInUTC = $mResponse->getReceivedOrDateTimeStamp();
             $aFlags = $mResponse->getFlagsLowerCase();
             $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Folder' => $mResponse->getFolder(), 'Uid' => $mResponse->getUid(), 'Subject' => $mResponse->getSubject(), 'MessageId' => $mResponse->getMessageId(), 'Size' => $mResponse->getSize(), 'TextSize' => $mResponse->getTextSize(), 'InternalTimeStampInUTC' => $iInternalTimeStampInUTC, 'ReceivedOrDateTimeStampInUTC' => $iReceivedOrDateTimeStampInUTC, 'TimeStampInUTC' => \CApi::GetConf('labs.use-date-from-headers', false) && 0 < $iReceivedOrDateTimeStampInUTC ? $iReceivedOrDateTimeStampInUTC : $iInternalTimeStampInUTC, 'From' => $this->responseObject($oAccount, $mResponse->getFrom(), $sParent, $aParameters), 'To' => $this->responseObject($oAccount, $mResponse->getTo(), $sParent, $aParameters), 'Cc' => $this->responseObject($oAccount, $mResponse->getCc(), $sParent, $aParameters), 'Bcc' => $this->responseObject($oAccount, $mResponse->getBcc(), $sParent, $aParameters), 'Sender' => $this->responseObject($oAccount, $mResponse->getSender(), $sParent, $aParameters), 'ReplyTo' => $this->responseObject($oAccount, $mResponse->getReplyTo(), $sParent, $aParameters), 'IsSeen' => in_array('\\seen', $aFlags), 'IsFlagged' => in_array('\\flagged', $aFlags), 'IsAnswered' => in_array('\\answered', $aFlags), 'IsForwarded' => false, 'HasAttachments' => $oAttachments && $oAttachments->hasNotInlineAttachments(), 'HasVcardAttachment' => $oAttachments && $oAttachments->hasVcardAttachment(), 'HasIcalAttachment' => $oAttachments && $oAttachments->hasIcalAttachment(), 'Priority' => $mResponse->getPriority(), 'DraftInfo' => $mResponse->getDraftInfo(), 'Sensitivity' => $mResponse->getSensitivity()));
             $mResult['TrimmedTextSize'] = $mResult['TextSize'];
             if (0 < $iTrimmedLimit && $mResult['TrimmedTextSize'] > $iTrimmedLimit) {
                 $mResult['TrimmedTextSize'] = $iTrimmedLimit;
             }
             $sLowerForwarded = strtolower(\CApi::GetConf('webmail.forwarded-flag-name', ''));
             if (!empty($sLowerForwarded)) {
                 $mResult['IsForwarded'] = in_array($sLowerForwarded, $aFlags);
             }
             $mResult['Hash'] = \CApi::EncodeKeyValues(array('AccountID' => $oAccount ? $oAccount->IdAccount : 0, 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeType' => 'message/rfc822', 'FileName' => $mResult['Subject'] . '.eml'));
             if ('MessageGet' === $sParent || 'MessagesGetBodies' === $sParent) {
                 $mResult['Headers'] = \MailSo\Base\Utils::Utf8Clear($mResponse->getHeaders());
                 $mResult['InReplyTo'] = $mResponse->getInReplyTo();
                 $mResult['References'] = $mResponse->getReferences();
                 $mResult['ReadingConfirmation'] = $mResponse->getReadingConfirmation();
                 if (!empty($mResult['ReadingConfirmation']) && in_array('$readconfirm', $aFlags)) {
                     $mResult['ReadingConfirmation'] = '';
                 }
                 $bHasExternals = false;
                 $aFoundedCIDs = array();
                 $sPlain = '';
                 $sHtml = trim($mResponse->getHtml());
                 if (0 === strlen($sHtml)) {
                     $sPlain = $mResponse->getPlain();
                 }
                 $aContentLocationUrls = array();
                 $aFoundedContentLocationUrls = array();
                 if ($oAttachments && 0 < $oAttachments->Count()) {
                     $aList =& $oAttachments->GetAsArray();
                     foreach ($aList as $oAttachment) {
                         if ($oAttachment) {
                             $sContentLocation = $oAttachment->getContentLocation();
                             if ($sContentLocation && 0 < \strlen($sContentLocation)) {
                                 $aContentLocationUrls[] = $oAttachment->getContentLocation();
                             }
                         }
                     }
                 }
                 $iTextSizeLimit = 500000;
                 if ($iTextSizeLimit < \strlen($sHtml)) {
                     $iSpacePost = \strpos($sHtml, ' ', $iTextSizeLimit);
                     $sHtml = \substr($sHtml, 0, false !== $iSpacePost && $iSpacePost > $iTextSizeLimit ? $iSpacePost : $iTextSizeLimit);
                 }
                 if ($iTextSizeLimit < \strlen($sPlain)) {
                     $iSpacePost = \strpos($sPlain, ' ', $iTextSizeLimit);
                     $sPlain = \substr($sPlain, 0, false !== $iSpacePost && $iSpacePost > $iTextSizeLimit ? $iSpacePost : $iTextSizeLimit);
                 }
                 if (0 < \strlen($sHtml) && \CApi::GetConf('labs.webmail.display-inline-css', false)) {
                     include_once PSEVEN_APP_ROOT_PATH . 'libraries/other/CssToInlineStyles.php';
                     $oCssToInlineStyles = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($sHtml);
                     $oCssToInlineStyles->setEncoding('utf-8');
                     $oCssToInlineStyles->setUseInlineStylesBlock(true);
                     $mResult['Html'] = \MailSo\Base\HtmlUtils::ClearHtml($oCssToInlineStyles->convert(), $bHasExternals, $aFoundedCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, false, true);
                 } else {
                     $mResult['Html'] = 0 === strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $aFoundedCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, false, true);
                 }
                 $mResult['Trimmed'] = false;
                 $mResult['Plain'] = 0 === strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain);
                 $mResult['PlainRaw'] = \trim($sPlain);
                 $mResult['Rtl'] = 0 < \strlen($mResult['Plain']) ? \MailSo\Base\Utils::IsRTL($mResult['Plain']) : false;
                 if (0 < $iTrimmedLimit && 'Messages' === $sParent) {
                     if ($iTrimmedLimit < strlen($mResult['Plain'])) {
                         $iPos = strpos($mResult['Plain'], ' ', $iTrimmedLimit);
                         if (false !== $iPos && $iTrimmedLimit <= $iPos) {
                             $mResult['Plain'] = substr($mResult['Plain'], 0, $iPos);
                             $mResult['Trimmed'] = true;
                         }
                     }
                     if ($iTrimmedLimit < strlen($mResult['Html'])) {
                         $iPos = strpos($mResult['Html'], ' <', $iTrimmedLimit);
                         if (false !== $iPos && $iTrimmedLimit <= $iPos) {
                             $mResult['Html'] = substr($mResult['Html'], 0, $iPos) . '<!-- cutted -->';
                             $mResult['Trimmed'] = true;
                         }
                     }
                 }
                 $mResult['ICAL'] = $this->responseObject($oAccount, $mResponse->getExtend('ICAL'), $sParent, $aParameters);
                 $mResult['VCARD'] = $this->responseObject($oAccount, $mResponse->getExtend('VCARD'), $sParent, $aParameters);
                 $mResult['Safety'] = $mResponse->getSafety();
                 $mResult['HasExternals'] = $bHasExternals;
                 $mResult['FoundedCIDs'] = $aFoundedCIDs;
                 $mResult['FoundedContentLocationUrls'] = $aFoundedContentLocationUrls;
                 $mResult['Attachments'] = $this->responseObject($oAccount, $oAttachments, $sParent, array_merge($aParameters, array('FoundedCIDs' => $aFoundedCIDs, 'FoundedContentLocationUrls' => $aFoundedContentLocationUrls)));
                 //					$mResult['Html'] = \MailSo\Base\Utils::Utf8Clear($mResult['Html']);
                 //					$mResult['Plain'] = \MailSo\Base\Utils::Utf8Clear($mResult['Plain']);
             } else {
                 $mResult['@Object'] = 'Object/MessageListItem';
                 $mResult['Threads'] = $mResponse->getThreads();
             }
             $mResult['Custom'] = $this->responseObject($oAccount, $mResponse->getCustomList(), $sParent, $aParameters);
             $mResult['Subject'] = \MailSo\Base\Utils::Utf8Clear($mResult['Subject']);
         } else {
             if ('CApiMailIcs' === $sClassName) {
                 $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Uid' => $mResponse->Uid, 'Sequence' => $mResponse->Sequence, 'Attendee' => $mResponse->Attendee, 'File' => $mResponse->File, 'Type' => $mResponse->Type, 'Location' => $mResponse->Location, 'Description' => \MailSo\Base\LinkFinder::NewInstance()->Text($mResponse->Description)->UseDefaultWrappers(true)->CompileText(), 'When' => $mResponse->When, 'CalendarId' => $mResponse->CalendarId));
             } else {
                 if ('CApiMailVcard' === $sClassName) {
                     $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Uid' => $mResponse->Uid, 'File' => $mResponse->File, 'Name' => $mResponse->Name, 'Email' => $mResponse->Email, 'Exists' => $mResponse->Exists));
                 } else {
                     if ('CFilter' === $sClassName) {
                         $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Enable' => $mResponse->Enable, 'Field' => $mResponse->Field, 'Filter' => $mResponse->Filter, 'Condition' => $mResponse->Condition, 'Action' => $mResponse->Action, 'FolderFullName' => $mResponse->FolderFullName));
                     } else {
                         if ('CHelpdeskThread' === $sClassName) {
                             $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdHelpdeskThread' => $mResponse->IdHelpdeskThread, 'ThreadHash' => $mResponse->StrHelpdeskThreadHash, 'IdOwner' => $mResponse->IdOwner, 'Owner' => $mResponse->Owner, 'Type' => $mResponse->Type, 'Subject' => $mResponse->Subject, 'IsRead' => $mResponse->IsRead, 'IsArchived' => $mResponse->IsArchived, 'ItsMe' => $mResponse->ItsMe, 'HasAttachments' => $mResponse->HasAttachments, 'PostCount' => $mResponse->PostCount, 'Created' => $mResponse->Created, 'Updated' => $mResponse->Updated));
                         } else {
                             if ('CHelpdeskPost' === $sClassName) {
                                 $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdHelpdeskPost' => $mResponse->IdHelpdeskPost, 'IdHelpdeskThread' => $mResponse->IdHelpdeskThread, 'IdOwner' => $mResponse->IdOwner, 'Owner' => $mResponse->Owner, 'Attachments' => $this->responseObject($oAccount, $mResponse->Attachments, $sParent), 'IsThreadOwner' => $mResponse->IsThreadOwner, 'ItsMe' => $mResponse->ItsMe, 'Type' => $mResponse->Type, 'SystemType' => $mResponse->SystemType, 'Text' => \MailSo\Base\HtmlUtils::ConvertPlainToHtml($mResponse->Text), 'Created' => $mResponse->Created));
                             } else {
                                 if ('CHelpdeskAttachment' === $sClassName) {
                                     $iThumbnailLimit = 1024 * 1024 * 2;
                                     // 2MB
                                     /* @var $mResponse CHelpdeskAttachment */
                                     $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdHelpdeskAttachment' => $mResponse->IdHelpdeskAttachment, 'IdHelpdeskPost' => $mResponse->IdHelpdeskPost, 'IdHelpdeskThread' => $mResponse->IdHelpdeskThread, 'SizeInBytes' => $mResponse->SizeInBytes, 'FileName' => $mResponse->FileName, 'MimeType' => \MailSo\Base\Utils::MimeContentType($mResponse->FileName), 'Thumb' => \CApi::GetConf('labs.allow-thumbnail', true) && $mResponse->SizeInBytes < $iThumbnailLimit && \api_Utils::IsGDImageMimeTypeSuppoted(\MailSo\Base\Utils::MimeContentType($mResponse->FileName), $mResponse->FileName), 'Hash' => $mResponse->Hash, 'Content' => $mResponse->Content, 'Created' => $mResponse->Created));
                                 } else {
                                     if ('CFetcher' === $sClassName) {
                                         /* @var $mResponse \CFetcher */
                                         $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdFetcher' => $mResponse->IdFetcher, 'IdAccount' => $mResponse->IdAccount, 'IsEnabled' => $mResponse->IsEnabled, 'IsLocked' => $mResponse->IsLocked, 'Folder' => $mResponse->Folder, 'Name' => $mResponse->Name, 'Email' => $mResponse->Email, 'Signature' => $mResponse->Signature, 'SignatureOptions' => $mResponse->SignatureOptions, 'LeaveMessagesOnServer' => $mResponse->LeaveMessagesOnServer, 'IncomingMailServer' => $mResponse->IncomingMailServer, 'IncomingMailPort' => $mResponse->IncomingMailPort, 'IncomingMailLogin' => $mResponse->IncomingMailLogin, 'IsOutgoingEnabled' => $mResponse->IsOutgoingEnabled, 'OutgoingMailServer' => $mResponse->OutgoingMailServer, 'OutgoingMailPort' => $mResponse->OutgoingMailPort, 'OutgoingMailAuth' => $mResponse->OutgoingMailAuth, 'IncomingMailSsl' => $mResponse->IncomingMailSecurity === \MailSo\Net\Enumerations\ConnectionSecurityType::SSL, 'OutgoingMailSsl' => $mResponse->OutgoingMailSecurity === \MailSo\Net\Enumerations\ConnectionSecurityType::SSL));
                                     } else {
                                         if ('CApiMailFolder' === $sClassName) {
                                             $aExtended = null;
                                             $mStatus = $mResponse->getStatus();
                                             if (is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])) {
                                                 $aExtended = array('MessageCount' => (int) $mStatus['MESSAGES'], 'MessageUnseenCount' => (int) $mStatus['UNSEEN'], 'UidNext' => (string) $mStatus['UIDNEXT'], 'Hash' => \api_Utils::GenerateFolderHash($mResponse->getRawFullName(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT']));
                                             }
                                             $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Type' => $mResponse->getType(), 'Name' => $mResponse->getName(), 'FullName' => $mResponse->getFullName(), 'FullNameRaw' => $mResponse->getRawFullName(), 'FullNameHash' => md5($mResponse->getRawFullName()), 'Delimiter' => $mResponse->getDelimiter(), 'IsSubscribed' => $oAccount->isExtensionEnabled(\CAccount::IgnoreSubscribeStatus) ? true : $mResponse->isSubscribed(), 'IsSelectable' => $mResponse->isSelectable(), 'Exists' => $mResponse->exists(), 'Extended' => $aExtended, 'SubFolders' => $this->responseObject($oAccount, $mResponse->getSubFolders(), $sParent, $aParameters)));
                                         } else {
                                             if ('CApiMailAttachment' === $sClassName) {
                                                 $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && is_array($aParameters['FoundedCIDs']) ? $aParameters['FoundedCIDs'] : null;
                                                 $mFoundedContentLocationUrls = isset($aParameters['FoundedContentLocationUrls']) && \is_array($aParameters['FoundedContentLocationUrls']) && 0 < \count($aParameters['FoundedContentLocationUrls']) ? $aParameters['FoundedContentLocationUrls'] : null;
                                                 if ($mFoundedCIDs || $mFoundedContentLocationUrls) {
                                                     $aFoundedCIDs = \array_merge($mFoundedCIDs ? $mFoundedCIDs : array(), $mFoundedContentLocationUrls ? $mFoundedContentLocationUrls : array());
                                                     $aFoundedCIDs = 0 < \count($mFoundedCIDs) ? $mFoundedCIDs : null;
                                                 }
                                                 $sMimeType = strtolower(trim($mResponse->getMimeType()));
                                                 $sMimeIndex = strtolower(trim($mResponse->getMimeIndex()));
                                                 $sContentTransferEncoding = strtolower(trim($mResponse->getEncoding()));
                                                 $sFileName = $mResponse->getFileName(true);
                                                 $iEstimatedSize = $mResponse->getEstimatedSize();
                                                 $iThumbnailLimit = 1024 * 1024 * 2;
                                                 // 2MB //TODO
                                                 if (in_array($sMimeType, array('application/octet-stream'))) {
                                                     $sMimeType = \MailSo\Base\Utils::MimeContentType($sFileName);
                                                 }
                                                 $sCid = \trim(\trim($mResponse->getCid()), '<>');
                                                 $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('FileName' => $sFileName, 'MimeType' => $sMimeType, 'MimePartIndex' => 'message/rfc822' === $sMimeType && ('base64' === $sContentTransferEncoding || 'quoted-printable' === $sContentTransferEncoding) ? '' : $sMimeIndex, 'EstimatedSize' => $iEstimatedSize, 'CID' => $sCid, 'ContentLocation' => $mResponse->getContentLocation(), 'Thumb' => \CApi::GetConf('labs.allow-thumbnail', true) && $iEstimatedSize < $iThumbnailLimit && \api_Utils::IsGDImageMimeTypeSuppoted($sMimeType, $sFileName), 'Expand' => \CApi::isExpandMimeTypeSupported($sMimeType, $sFileName), 'Iframed' => \CApi::isIframedMimeTypeSupported($sMimeType, $sFileName), 'Content' => $mResponse->getContent(), 'IsInline' => $mResponse->isInline(), 'IsLinked' => !empty($sCid) && $mFoundedCIDs && \in_array($sCid, $mFoundedCIDs) || $mFoundedContentLocationUrls && \in_array(\trim($mResponse->getContentLocation()), $mFoundedContentLocationUrls)));
                                                 $mResult['Hash'] = \CApi::EncodeKeyValues(array('Iframed' => $mResult['Iframed'], 'AccountID' => $oAccount ? $oAccount->IdAccount : 0, 'Folder' => $mResponse->getFolder(), 'Uid' => $mResponse->getUid(), 'MimeIndex' => $sMimeIndex, 'MimeType' => $sMimeType, 'FileName' => $mResponse->getFileName(true)));
                                             } else {
                                                 if ('MailSo\\Mime\\Email' === $sClassName) {
                                                     $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('DisplayName' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetDisplayName()), 'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail())));
                                                 } else {
                                                     if ('CApiMailMessageCollection' === $sClassName) {
                                                         $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Uids' => $mResponse->Uids, 'UidNext' => $mResponse->UidNext, 'FolderHash' => $mResponse->FolderHash, 'MessageCount' => $mResponse->MessageCount, 'MessageUnseenCount' => $mResponse->MessageUnseenCount, 'MessageResultCount' => $mResponse->MessageResultCount, 'FolderName' => $mResponse->FolderName, 'Offset' => $mResponse->Offset, 'Limit' => $mResponse->Limit, 'Search' => $mResponse->Search, 'Filters' => $mResponse->Filters, 'New' => $mResponse->New));
                                                     } else {
                                                         if ('CIdentity' === $sClassName) {
                                                             $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdIdentity' => $mResponse->IdIdentity, 'IdAccount' => $mResponse->IdAccount, 'Default' => $mResponse->Default, 'Enabled' => $mResponse->Enabled, 'Email' => $mResponse->Email, 'FriendlyName' => $mResponse->FriendlyName, 'UseSignature' => $mResponse->UseSignature, 'Signature' => $mResponse->Signature));
                                                         } else {
                                                             if ('CApiMailFolderCollection' === $sClassName) {
                                                                 $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Namespace' => $mResponse->GetNamespace()));
                                                             } else {
                                                                 if ('CContactListItem' === $sClassName) {
                                                                     $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdUser' => $oAccount->IdUser, 'Id' => $mResponse->Id, 'Name' => $mResponse->Name, 'Email' => $mResponse->Email, 'Emails' => $mResponse->Emails, 'Phones' => $mResponse->Phones, 'UseFriendlyName' => $mResponse->UseFriendlyName, 'IsGroup' => $mResponse->IsGroup, 'IsOrganization' => $mResponse->IsOrganization, 'ReadOnly' => $mResponse->ReadOnly, 'ItsMe' => $mResponse->ItsMe, 'Global' => $mResponse->Global, 'ForSharedToAll' => $mResponse->ForSharedToAll, 'SharedToAll' => $mResponse->SharedToAll, 'Frequency' => $mResponse->Frequency, 'AgeScore' => $mResponse->AgeScore));
                                                                 } else {
                                                                     if ('CContact' === $sClassName) {
                                                                         $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdUser' => $mResponse->IdUser, 'IdContact' => $mResponse->IdContact, 'IdContactStr' => $mResponse->IdContactStr, 'Global' => $mResponse->Global, 'ItsMe' => $mResponse->ItsMe, 'PrimaryEmail' => $mResponse->PrimaryEmail, 'UseFriendlyName' => $mResponse->UseFriendlyName, 'GroupsIds' => $mResponse->GroupsIds, 'FullName' => $mResponse->FullName, 'Title' => $mResponse->Title, 'FirstName' => $mResponse->FirstName, 'LastName' => $mResponse->LastName, 'NickName' => $mResponse->NickName, 'Skype' => $mResponse->Skype, 'Facebook' => $mResponse->Facebook, 'HomeEmail' => $mResponse->HomeEmail, 'HomeStreet' => $mResponse->HomeStreet, 'HomeCity' => $mResponse->HomeCity, 'HomeState' => $mResponse->HomeState, 'HomeZip' => $mResponse->HomeZip, 'HomeCountry' => $mResponse->HomeCountry, 'HomePhone' => $mResponse->HomePhone, 'HomeFax' => $mResponse->HomeFax, 'HomeMobile' => $mResponse->HomeMobile, 'HomeWeb' => $mResponse->HomeWeb, 'BusinessEmail' => $mResponse->BusinessEmail, 'BusinessCompany' => $mResponse->BusinessCompany, 'BusinessStreet' => $mResponse->BusinessStreet, 'BusinessCity' => $mResponse->BusinessCity, 'BusinessState' => $mResponse->BusinessState, 'BusinessZip' => $mResponse->BusinessZip, 'BusinessCountry' => $mResponse->BusinessCountry, 'BusinessJobTitle' => $mResponse->BusinessJobTitle, 'BusinessDepartment' => $mResponse->BusinessDepartment, 'BusinessOffice' => $mResponse->BusinessOffice, 'BusinessPhone' => $mResponse->BusinessPhone, 'BusinessMobile' => $mResponse->BusinessMobile, 'BusinessFax' => $mResponse->BusinessFax, 'BusinessWeb' => $mResponse->BusinessWeb, 'OtherEmail' => $mResponse->OtherEmail, 'Notes' => $mResponse->Notes, 'BirthdayDay' => $mResponse->BirthdayDay, 'BirthdayMonth' => $mResponse->BirthdayMonth, 'BirthdayYear' => $mResponse->BirthdayYear, 'ReadOnly' => $mResponse->ReadOnly, 'ETag' => $mResponse->ETag, 'SharedToAll' => $mResponse->SharedToAll));
                                                                     } else {
                                                                         if ('CGroup' === $sClassName) {
                                                                             $aContacts = $this->ApiContacts()->getContactItems($mResponse->IdUser, \EContactSortField::Name, \ESortOrder::ASC, 0, 299, '', '', $mResponse->IdGroup);
                                                                             $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdUser' => $mResponse->IdUser, 'IdGroup' => $mResponse->IdGroup, 'IdGroupStr' => $mResponse->IdGroupStr, 'Name' => $mResponse->Name, 'IsOrganization' => $mResponse->IsOrganization, 'Email' => $mResponse->Email, 'Company' => $mResponse->Company, 'Street' => $mResponse->Street, 'City' => $mResponse->City, 'State' => $mResponse->City, 'Zip' => $mResponse->Zip, 'Country' => $mResponse->Country, 'Phone' => $mResponse->Phone, 'Fax' => $mResponse->Fax, 'Web' => $mResponse->Web, 'Contacts' => $this->responseObject($oAccount, $aContacts, $sParent, $aParameters)));
                                                                         } else {
                                                                             if ($mResponse instanceof \MailSo\Base\Collection) {
                                                                                 $aCollection = $mResponse->GetAsArray();
                                                                                 if (150 < \count($aCollection) && $mResponse instanceof \MailSo\Mime\EmailCollection) {
                                                                                     $aCollection = \array_slice($aCollection, 0, 150);
                                                                                 }
                                                                                 $mResult = $this->responseObject($oAccount, $aCollection, $sParent, $aParameters);
                                                                                 unset($aCollection);
                                                                             } else {
                                                                                 if ('CSocial' === $sClassName) {
                                                                                     $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), $mResponse->toArray());
                                                                                 } else {
                                                                                     if ('CFileStorageItem' === $sClassName) {
                                                                                         $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Id' => $mResponse->Id, 'Type' => $mResponse->TypeStr, 'Path' => $mResponse->Path, 'FullPath' => $mResponse->FullPath, 'Name' => $mResponse->Name, 'Size' => $mResponse->Size, 'IsFolder' => $mResponse->IsFolder, 'IsLink' => $mResponse->IsLink, 'LinkType' => $mResponse->LinkType, 'LinkUrl' => $mResponse->LinkUrl, 'LastModified' => $mResponse->LastModified, 'ContentType' => $mResponse->ContentType, 'Iframed' => $mResponse->Iframed, 'Thumb' => $mResponse->Thumb, 'ThumbnailLink' => $mResponse->ThumbnailLink, 'OembedHtml' => $mResponse->OembedHtml, 'Hash' => $mResponse->Hash, 'Shared' => $mResponse->Shared, 'Owner' => $mResponse->Owner, 'Content' => $mResponse->Content, 'IsExternal' => $mResponse->IsExternal));
                                                                                     } else {
                                                                                         $mResult = '[' . $sClassName . ']';
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         if (is_array($mResponse)) {
             foreach ($mResponse as $iKey => $oItem) {
                 $mResponse[$iKey] = $this->responseObject($oAccount, $oItem, $sParent, $aParameters);
             }
             $mResult = $mResponse;
         }
     }
     unset($mResponse);
     return $mResult;
 }
コード例 #6
0
ファイル: Actions.php プロジェクト: sunhaolin/rainloop
 /**
  * @param mixed $mResponse
  * @param string $sParent
  * @param array $aParameters = array()
  *
  * @return mixed
  */
 protected function responseObject($mResponse, $sParent = '', $aParameters = array())
 {
     $mResult = $mResponse;
     if (\is_object($mResponse)) {
         $bHook = true;
         $sClassName = \get_class($mResponse);
         $bHasSimpleJsonFunc = \method_exists($mResponse, 'ToSimpleJSON');
         $bThumb = $this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS);
         if ($bHasSimpleJsonFunc) {
             $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true));
         } else {
             if ('MailSo\\Mail\\Message' === $sClassName) {
                 $oAccount = $this->getAccountFromToken(false);
                 $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Subject' => \trim(\MailSo\Base\Utils::Utf8Clear($mResponse->Subject())), 'MessageId' => $mResponse->MessageId(), 'Size' => $mResponse->Size(), 'DateTimeStampInUTC' => !!$this->Config()->Get('labs', 'date_from_headers', false) ? $mResponse->HeaderTimeStampInUTC() : $mResponse->InternalTimeStampInUTC(), 'ReplyTo' => $this->responseObject($mResponse->ReplyTo(), $sParent, $aParameters), 'From' => $this->responseObject($mResponse->From(), $sParent, $aParameters), 'To' => $this->responseObject($mResponse->To(), $sParent, $aParameters), 'Cc' => $this->responseObject($mResponse->Cc(), $sParent, $aParameters), 'Bcc' => $this->responseObject($mResponse->Bcc(), $sParent, $aParameters), 'Sender' => $this->responseObject($mResponse->Sender(), $sParent, $aParameters), 'DeliveredTo' => $this->responseObject($mResponse->DeliveredTo(), $sParent, $aParameters), 'Priority' => $mResponse->Priority(), 'Threads' => $mResponse->Threads(), 'ThreadsLen' => $mResponse->ThreadsLen(), 'ParentThread' => $mResponse->ParentThread(), 'Sensitivity' => $mResponse->Sensitivity(), 'ExternalProxy' => false, 'ReadReceipt' => ''));
                 $mResult['SubjectParts'] = $this->explodeSubject($mResult['Subject']);
                 $oAttachments = $mResponse->Attachments();
                 $iAttachmentsCount = $oAttachments ? $oAttachments->Count() : 0;
                 $mResult['HasAttachments'] = 0 < $iAttachmentsCount;
                 $mResult['AttachmentsMainType'] = '';
                 if (0 < $iAttachmentsCount) {
                     switch (true) {
                         case $iAttachmentsCount === $oAttachments->ImageCount():
                             $mResult['AttachmentsMainType'] = 'image';
                             break;
                         case $iAttachmentsCount === $oAttachments->ArchiveCount():
                             $mResult['AttachmentsMainType'] = 'archive';
                             break;
                         case $iAttachmentsCount === $oAttachments->PdfCount():
                             $mResult['AttachmentsMainType'] = 'pdf';
                             break;
                         case $iAttachmentsCount === $oAttachments->DocCount():
                             $mResult['AttachmentsMainType'] = 'doc';
                             break;
                         case $iAttachmentsCount === $oAttachments->CertificateCount():
                             $mResult['AttachmentsMainType'] = 'certificate';
                             break;
                     }
                 }
                 $sSubject = $mResult['Subject'];
                 $mResult['Hash'] = \md5($mResult['Folder'] . $mResult['Uid']);
                 $mResult['RequestHash'] = \RainLoop\Utils::EncodeKeyValues(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeType' => 'message/rfc822', 'FileName' => (0 === \strlen($sSubject) ? 'message-' . $mResult['Uid'] : \MailSo\Base\Utils::ClearXss($sSubject)) . '.eml'));
                 // Flags
                 $aFlags = $mResponse->FlagsLowerCase();
                 $mResult['IsSeen'] = \in_array('\\seen', $aFlags);
                 $mResult['IsFlagged'] = \in_array('\\flagged', $aFlags);
                 $mResult['IsAnswered'] = \in_array('\\answered', $aFlags);
                 $mResult['IsDeleted'] = \in_array('\\deleted', $aFlags);
                 $sForwardedFlag = $this->Config()->Get('labs', 'imap_forwarded_flag', '');
                 $sReadReceiptFlag = $this->Config()->Get('labs', 'imap_read_receipt_flag', '');
                 $mResult['IsForwarded'] = 0 < \strlen($sForwardedFlag) && \in_array(\strtolower($sForwardedFlag), $aFlags);
                 $mResult['IsReadReceipt'] = 0 < \strlen($sReadReceiptFlag) && \in_array(\strtolower($sReadReceiptFlag), $aFlags);
                 $mResult['TextPartIsTrimmed'] = false;
                 if ('Message' === $sParent) {
                     $oAttachments = $mResponse->Attachments();
                     $bHasExternals = false;
                     $mFoundedCIDs = array();
                     $aContentLocationUrls = array();
                     $mFoundedContentLocationUrls = array();
                     if ($oAttachments && 0 < $oAttachments->Count()) {
                         $aList =& $oAttachments->GetAsArray();
                         foreach ($aList as $oAttachment) {
                             if ($oAttachment) {
                                 $sContentLocation = $oAttachment->ContentLocation();
                                 if ($sContentLocation && 0 < \strlen($sContentLocation)) {
                                     $aContentLocationUrls[] = $oAttachment->ContentLocation();
                                 }
                             }
                         }
                     }
                     $sPlain = '';
                     $sHtml = \trim($mResponse->Html());
                     if (0 === \strlen($sHtml)) {
                         $sPlain = \trim($mResponse->Plain());
                     }
                     $mResult['DraftInfo'] = $mResponse->DraftInfo();
                     $mResult['InReplyTo'] = $mResponse->InReplyTo();
                     $mResult['References'] = $mResponse->References();
                     $fAdditionalExternalFilter = null;
                     if (!!$this->Config()->Get('labs', 'use_local_proxy_for_external_images', false)) {
                         $fAdditionalExternalFilter = function ($sUrl) {
                             return './?/ProxyExternal/' . \RainLoop\Utils::EncodeKeyValues(array('Rnd' => \md5(\microtime(true)), 'Token' => \RainLoop\Utils::GetConnectionToken(), 'Url' => $sUrl)) . '/';
                         };
                     }
                     $mResult['Html'] = 0 === \strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $mFoundedCIDs, $aContentLocationUrls, $mFoundedContentLocationUrls, false, false, $fAdditionalExternalFilter);
                     $mResult['ExternalProxy'] = null !== $fAdditionalExternalFilter;
                     $mResult['Plain'] = $sPlain;
                     //					$mResult['Plain'] = 0 === \strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain);
                     $mResult['TextHash'] = \md5($mResult['Html'] . $mResult['Plain']);
                     $mResult['TextPartIsTrimmed'] = $mResponse->TextPartIsTrimmed();
                     $mResult['PgpSigned'] = $mResponse->PgpSigned();
                     $mResult['PgpEncrypted'] = $mResponse->PgpEncrypted();
                     $mResult['PgpSignature'] = $mResponse->PgpSignature();
                     unset($sHtml, $sPlain);
                     $mResult['HasExternals'] = $bHasExternals;
                     $mResult['HasInternals'] = \is_array($mFoundedCIDs) && 0 < \count($mFoundedCIDs) || \is_array($mFoundedContentLocationUrls) && 0 < \count($mFoundedContentLocationUrls);
                     $mResult['FoundedCIDs'] = $mFoundedCIDs;
                     $mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, \array_merge($aParameters, array('FoundedCIDs' => $mFoundedCIDs, 'FoundedContentLocationUrls' => $mFoundedContentLocationUrls)));
                     $mResult['ReadReceipt'] = $mResponse->ReadReceipt();
                     if (0 < \strlen($mResult['ReadReceipt']) && !$mResult['IsReadReceipt']) {
                         if (0 < \strlen($mResult['ReadReceipt'])) {
                             try {
                                 $oReadReceipt = \MailSo\Mime\Email::Parse($mResult['ReadReceipt']);
                                 if (!$oReadReceipt) {
                                     $mResult['ReadReceipt'] = '';
                                 }
                             } catch (\Exception $oException) {
                                 unset($oException);
                             }
                         }
                         if (0 < \strlen($mResult['ReadReceipt']) && '1' === $this->Cacher($oAccount)->Get(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $mResult['Folder'], $mResult['Uid']), '0')) {
                             $mResult['ReadReceipt'] = '';
                         }
                     }
                 }
             } else {
                 if ('MailSo\\Mime\\Email' === $sClassName) {
                     $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetDisplayName()), 'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail(true)), 'DkimStatus' => $mResponse->GetDkimStatus(), 'DkimValue' => $mResponse->GetDkimValue()));
                 } else {
                     if ('RainLoop\\Providers\\AddressBook\\Classes\\Contact' === $sClassName) {
                         $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContact' => $mResponse->IdContact, 'Display' => \MailSo\Base\Utils::Utf8Clear($mResponse->Display), 'ReadOnly' => $mResponse->ReadOnly, 'IdPropertyFromSearch' => $mResponse->IdPropertyFromSearch, 'Properties' => $this->responseObject($mResponse->Properties, $sParent, $aParameters)));
                     } else {
                         if ('RainLoop\\Providers\\AddressBook\\Classes\\Tag' === $sClassName) {
                             $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContactTag' => $mResponse->IdContactTag, 'Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->Name), 'ReadOnly' => $mResponse->ReadOnly));
                         } else {
                             if ('RainLoop\\Providers\\AddressBook\\Classes\\Property' === $sClassName) {
                                 // Simple hack
                                 if ($mResponse && $mResponse->IsWeb()) {
                                     $mResponse->Value = \preg_replace('/(skype|ftp|http[s]?)\\\\:\\/\\//i', '$1://', $mResponse->Value);
                                 }
                                 $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdProperty' => $mResponse->IdProperty, 'Type' => $mResponse->Type, 'TypeStr' => $mResponse->TypeStr, 'Value' => \MailSo\Base\Utils::Utf8Clear($mResponse->Value)));
                             } else {
                                 if ('MailSo\\Mail\\Attachment' === $sClassName) {
                                     $oAccount = $this->getAccountFromToken(false);
                                     $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && \is_array($aParameters['FoundedCIDs']) && 0 < \count($aParameters['FoundedCIDs']) ? $aParameters['FoundedCIDs'] : null;
                                     $mFoundedContentLocationUrls = isset($aParameters['FoundedContentLocationUrls']) && \is_array($aParameters['FoundedContentLocationUrls']) && 0 < \count($aParameters['FoundedContentLocationUrls']) ? $aParameters['FoundedContentLocationUrls'] : null;
                                     if ($mFoundedCIDs || $mFoundedContentLocationUrls) {
                                         $mFoundedCIDs = \array_merge($mFoundedCIDs ? $mFoundedCIDs : array(), $mFoundedContentLocationUrls ? $mFoundedContentLocationUrls : array());
                                         $mFoundedCIDs = 0 < \count($mFoundedCIDs) ? $mFoundedCIDs : null;
                                     }
                                     $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Framed' => false, 'MimeIndex' => (string) $mResponse->MimeIndex(), 'MimeType' => $mResponse->MimeType(), 'FileName' => \MailSo\Base\Utils::ClearFileName(\MailSo\Base\Utils::ClearXss($mResponse->FileName(true))), 'EstimatedSize' => $mResponse->EstimatedSize(), 'CID' => $mResponse->Cid(), 'ContentLocation' => $mResponse->ContentLocation(), 'IsInline' => $mResponse->IsInline(), 'IsThumbnail' => $bThumb, 'IsLinked' => $mFoundedCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundedCIDs) || $mFoundedContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundedContentLocationUrls)));
                                     $mResult['Framed'] = $this->isFileHasFramedPreview($mResult['FileName']);
                                     if ($mResult['IsThumbnail']) {
                                         $mResult['IsThumbnail'] = $this->isFileHasThumbnail($mResult['FileName']);
                                     }
                                     $mResult['Download'] = \RainLoop\Utils::EncodeKeyValues(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeIndex' => $mResult['MimeIndex'], 'MimeType' => $mResult['MimeType'], 'FileName' => $mResult['FileName'], 'Framed' => $mResult['Framed']));
                                 } else {
                                     if ('MailSo\\Mail\\Folder' === $sClassName) {
                                         $aExtended = null;
                                         $mStatus = $mResponse->Status();
                                         if (\is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])) {
                                             $aExtended = array('MessageCount' => (int) $mStatus['MESSAGES'], 'MessageUnseenCount' => (int) $mStatus['UNSEEN'], 'UidNext' => (string) $mStatus['UIDNEXT'], 'Hash' => \MailSo\Mail\MailClient::GenerateHash($mResponse->FullNameRaw(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT']));
                                         }
                                         $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => $mResponse->Name(), 'FullName' => $mResponse->FullName(), 'FullNameRaw' => $mResponse->FullNameRaw(), 'FullNameHash' => $this->hashFolderFullName($mResponse->FullNameRaw(), $mResponse->FullName()), 'Delimiter' => (string) $mResponse->Delimiter(), 'HasVisibleSubFolders' => $mResponse->HasVisibleSubFolders(), 'IsSubscribed' => $mResponse->IsSubscribed(), 'IsExists' => $mResponse->IsExists(), 'IsSelectable' => $mResponse->IsSelectable(), 'Flags' => $mResponse->FlagsLowerCase(), 'Extended' => $aExtended, 'SubFolders' => $this->responseObject($mResponse->SubFolders(), $sParent, $aParameters)));
                                     } else {
                                         if ('MailSo\\Mail\\MessageCollection' === $sClassName) {
                                             $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('MessageCount' => $mResponse->MessageCount, 'MessageUnseenCount' => $mResponse->MessageUnseenCount, 'MessageResultCount' => $mResponse->MessageResultCount, 'Folder' => $mResponse->FolderName, 'FolderHash' => $mResponse->FolderHash, 'UidNext' => $mResponse->UidNext, 'NewMessages' => $this->responseObject($mResponse->NewMessages), 'LastCollapsedThreadUids' => $mResponse->LastCollapsedThreadUids, 'Offset' => $mResponse->Offset, 'Limit' => $mResponse->Limit, 'Search' => $mResponse->Search));
                                         } else {
                                             if ('MailSo\\Mail\\AttachmentCollection' === $sClassName) {
                                                 $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('InlineCount' => $mResponse->InlineCount()));
                                             } else {
                                                 if ('MailSo\\Mail\\FolderCollection' === $sClassName) {
                                                     $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Namespace' => $mResponse->GetNamespace(), 'FoldersHash' => isset($mResponse->FoldersHash) ? $mResponse->FoldersHash : '', 'IsThreadsSupported' => $mResponse->IsThreadsSupported, 'Optimized' => $mResponse->Optimized, 'SystemFolders' => isset($mResponse->SystemFolders) && \is_array($mResponse->SystemFolders) ? $mResponse->SystemFolders : array()));
                                                 } else {
                                                     if ($mResponse instanceof \MailSo\Base\Collection) {
                                                         $aList =& $mResponse->GetAsArray();
                                                         if (100 < \count($aList) && $mResponse instanceof \MailSo\Mime\EmailCollection) {
                                                             $aList = \array_slice($aList, 0, 100);
                                                         }
                                                         $mResult = $this->responseObject($aList, $sParent, $aParameters);
                                                         $bHook = false;
                                                     } else {
                                                         if ('RainLoop\\Providers\\AddressBook\\Classes\\Group' === $sClassName) {
                                                             $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdGroup' => $mResponse->IdGroup, 'Name' => $mResponse->Name, 'Contacts' => $this->responseObject($mResponse->Contacts, $sParent, $aParameters)));
                                                         } else {
                                                             if ('RainLoop\\Providers\\AddressBook\\Classes\\GroupContact' === $sClassName) {
                                                                 $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContact' => $mResponse->IdContact, 'IdGroup' => $mResponse->IdGroup, 'Name' => $mResponse->Name, 'Email' => $mResponse->Email, 'Phone' => $mResponse->Phone));
                                                             } else {
                                                                 $mResult = '["' . \get_class($mResponse) . '"]';
                                                                 $bHook = false;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($bHook) {
             $this->Plugins()->RunHook('filter.response-object', array($sClassName, $mResult), false);
         }
     } else {
         if (\is_array($mResponse)) {
             foreach ($mResponse as $iKey => $oItem) {
                 $mResponse[$iKey] = $this->responseObject($oItem, $sParent, $aParameters);
             }
             $mResult = $mResponse;
         }
     }
     unset($mResponse);
     return $mResult;
 }