/** * @param int $iUserId * @param string $sTempFileName * @param int $iParsedCount * @return int */ public function Import($iUserId, $sTempFileName, &$iParsedCount) { $iCount = -1; $iParsedCount = 0; if (file_exists($sTempFileName)) { $aCsv = api_Utils::CsvToArray($sTempFileName); if (is_array($aCsv)) { $iCount = 0; foreach ($aCsv as $aCsvItem) { set_time_limit(30); $this->oParser->Reset(); $oContact = new CContact(); $oContact->IdUser = $iUserId; $this->oParser->SetContainer($aCsvItem); $aParameters = $this->oParser->GetParameters(); foreach ($aParameters as $sPropertyName => $mValue) { if ($oContact->IsProperty($sPropertyName)) { $oContact->{$sPropertyName} = $mValue; } } if (0 === strlen($oContact->FullName)) { $oContact->FullName = trim($oContact->FirstName . ' ' . $oContact->LastName); } $iParsedCount++; $oContact->__SKIP_VALIDATE__ = true; if ($this->oApiContactsManager->CreateContact($oContact)) { $iCount++; } unset($oContact, $aParameters, $aCsvItem); } } } return $iCount; }
/** * @param int $iUserId * @param string $sTempFileName * @param int $iParsedCount * @param int $iGroupId * @param bool $bIsShared * @return int */ public function Import($iUserId, $sTempFileName, &$iParsedCount, $iGroupId, $bIsShared) { $iCount = -1; $iParsedCount = 0; if (file_exists($sTempFileName)) { $aCsv = api_Utils::CsvToArray($sTempFileName); if (is_array($aCsv)) { $oApiUsersManager = CApi::Manager('users'); $oAccount = $oApiUsersManager->GetDefaultAccount($iUserId); $iCount = 0; foreach ($aCsv as $aCsvItem) { set_time_limit(30); $this->oParser->Reset(); $oContact = new CContact(); $oContact->IdUser = $iUserId; $this->oParser->SetContainer($aCsvItem); $aParameters = $this->oParser->GetParameters(); foreach ($aParameters as $sPropertyName => $mValue) { if ($oContact->IsProperty($sPropertyName)) { $oContact->{$sPropertyName} = $mValue; } } if (0 === strlen($oContact->FullName)) { $oContact->FullName = trim($oContact->FirstName . ' ' . $oContact->LastName); } if (0 !== strlen($oContact->HomeEmail)) { $oContact->PrimaryEmail = \EPrimaryEmailType::Home; $oContact->ViewEmail = $oContact->HomeEmail; } else { if (0 !== strlen($oContact->BusinessEmail)) { $oContact->PrimaryEmail = \EPrimaryEmailType::Business; $oContact->ViewEmail = $oContact->BusinessEmail; } else { if (0 !== strlen($oContact->OtherEmail)) { $oContact->PrimaryEmail = \EPrimaryEmailType::Other; $oContact->ViewEmail = $oContact->OtherEmail; } } } if (strlen($oContact->BirthdayYear) === 2) { $oDt = DateTime::createFromFormat('y', $oContact->BirthdayYear); $oContact->BirthdayYear = $oDt->format('Y'); } $iParsedCount++; $oContact->__SKIP_VALIDATE__ = true; if ($oAccount) { $oContact->IdDomain = $oAccount->IdDomain; $oContact->IdTenant = $oAccount->IdTenant; } $oContact->SharedToAll = $bIsShared; $oContact->GroupsIds = array($iGroupId); if ($this->oApiContactsManager->CreateContact($oContact)) { $iCount++; } unset($oContact, $aParameters, $aCsvItem); } } } return $iCount; }
/** * @param string $sHashID * @param array $aParams * * @return string|bool */ public function createMin($sHashID, $aParams) { $mResult = false; $sNewMin = ''; if (is_string($sHashID) && 0 < strlen($sHashID) && false !== $this->getMinByID($sHashID)) { return false; } while (true) { $sNewMin = api_Utils::GenerateShortHashString(10); if (false === $this->getMinByHash($sNewMin)) { break; } } if (0 < strlen($sNewMin)) { $aParams['__hash_id__'] = $sHashID; $aParams['__hash__'] = $sNewMin; $aParams['__time__'] = time(); $aParams['__time_update__'] = time(); if ($this->oConnection->Execute($this->oCommandCreator->createMin($sNewMin, md5($sHashID), @\json_encode($aParams)))) { $mResult = $sNewMin; } } $this->throwDbExceptionIfExist(); return $mResult; }
public function getQuotaInfo() { $Size = 0; $aResult = \api_Utils::GetDirectorySize($this->path); if ($aResult && $aResult['size']) { $Size = (int) $aResult['size']; } return array($Size, 0); }
/** * @staticvar CLdapConnector|null $oLdap * @param CAccount $oAccount * @return CLdapConnector|bool */ private function Ldap($oAccount) { // if ($oAccount) // { // // TODO // $aCustomFields = $oAccount->CustomFields; // $aCustomFields['LdapPabUrl'] = 'ldap://192.168.0.197:389/ou=TestUser2,ou=PAB,dc=example,dc=com'; // $aCustomFields['LdapPabUrl'] = 'ldap://jes7dir.netvision.net.il:389/ou=24606995,ou=People,o=netvision.net.il,o=NVxSP,o=pab'; // $oAccount->CustomFields = $aCustomFields; // } static $aLdap = array(); if (!$oAccount || !isset($oAccount->CustomFields) || empty($oAccount->CustomFields['LdapPabUrl'])) { return false; } $sPabUrl = $oAccount->CustomFields['LdapPabUrl']; $aPabUrl = api_Utils::LdapUriParse($sPabUrl); if (isset($aLdap[$sPabUrl]) && $aLdap[$sPabUrl]) { return $aLdap[$sPabUrl]; } if (!extension_loaded('ldap')) { CApi::Log('LDAP: Can\'t load LDAP extension.', ELogLevel::Error); return false; } if (!class_exists('CLdapConnector')) { CApi::Inc('common.ldap'); } $oLdap = new CLdapConnector($aPabUrl['search_dn']); $oLdap = $oLdap->Connect((string) $aPabUrl['host'], (int) $aPabUrl['port'], (string) CApi::GetConf('contacts.ldap.bind-dn', ''), (string) CApi::GetConf('contacts.ldap.bind-password', '')) ? $oLdap : false; if ($oLdap) { if (!$oLdap->Search('(objectClass=*)')) { CApi::Log('LDAP: Init PabUrl Entry'); $sNewDn = $oLdap->GetSearchDN(); $aDnExplode = ldap_explode_dn($sNewDn, 1); $sOu = isset($aDnExplode[0]) ? trim($aDnExplode[0]) : ''; $aPabUrlEntry = CApi::GetConf('contacts.ldap.pab-url-entry', array('objectClass' => array('top', 'organizationalUnit'))); if (isset($aPabUrlEntry['objectClass'])) { $aPabUrlEntry['ou'] = $sOu; if (0 < strlen($sOu)) { if (!$oLdap->Add('', $aPabUrlEntry)) { $oLdap = false; } } else { CApi::Log('LDAP: empty Ou in SearchDn = ' . $sNewDn); $oLdap = false; } } else { CApi::Log('LDAP: pab-url-entry format error'); CApi::Log(print_r($aPabUrlEntry, true)); $oLdap = false; } } } $aLdap[$sPabUrl] = $oLdap; return $oLdap; }
public function SystemLogging(ap_Standard_Screen &$oScreen) { $this->oSettings->GetConf('Common/LoggingLevel'); $this->oSettings->GetConf('Common/EnableEventLogging'); $oScreen->Data->SetValue('ch_EnableDebugLogging', $this->oSettings->GetConf('Common/EnableLogging')); $iLogLevel = $this->oSettings->GetConf('Common/LoggingLevel'); $oScreen->Data->SetValue('selVerbosityFull', ELogLevel::Full === $iLogLevel); $oScreen->Data->SetValue('selVerbosityWarning', ELogLevel::Warning === $iLogLevel); $oScreen->Data->SetValue('selVerbosityError', ELogLevel::Error === $iLogLevel); $oScreen->Data->SetValue('selVerbositySpec', ELogLevel::Spec === $iLogLevel); $oScreen->Data->SetValue('ch_EnableUserActivityLogging', $this->oSettings->GetConf('Common/EnableEventLogging')); $aSize = $this->oModule->GetLogsSize(); $oScreen->Data->SetValue('DownloadLogSize', '(' . api_Utils::GetFriendlySize($aSize[0]) . ')'); $oScreen->Data->SetValue('DownloadUserActivityLogSize', '(' . api_Utils::GetFriendlySize($aSize[1]) . ')'); $oScreen->Data->SetValue('MaxViewSize', CApi::GetConf('log.max-view-size', 100) . 'KB'); }
/** * @return void */ public function Handle() { $sVersion = file_get_contents(PSEVEN_APP_ROOT_PATH . 'VERSION'); define('PSEVEN_APP_VERSION', $sVersion); if (!class_exists('MailSo\\Version')) { echo 'MailSo'; return ''; } else { if (!class_exists('\\CApi') || !\CApi::IsValid()) { echo 'AfterLogic API'; return ''; } } $sPathInfo = \trim(\trim($this->oHttp->GetServer('PATH_INFO', '')), ' /'); if (!empty($sPathInfo)) { if ('dav' === \substr($sPathInfo, 0, 3)) { $this->oActions->PathInfoDav(); return ''; } } /* @var $oApiIntegrator \CApiIntegratorManager */ $oApiIntegrator = \CApi::Manager('integrator'); // ------ Redirect to HTTPS $oSettings =& \CApi::GetSettings(); $bRedirectToHttps = $oSettings->GetConf('Common/RedirectToHttps'); $bHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== "off" || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == "443"; if ($bRedirectToHttps && !$bHttps) { header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } // ------ /* @var $oApiCapability \CApiCapabilityManager */ $oApiCapability = \CApi::Manager('capability'); $sResult = ''; $sQuery = \trim(\trim($this->oHttp->GetServer('QUERY_STRING', '')), ' /'); \CApi::Plugin()->RunQueryHandle($sQuery); $iPos = \strpos($sQuery, '&'); if (0 < $iPos) { $sQuery = \substr($sQuery, 0, $iPos); } $aPaths = explode('/', $sQuery); if (0 < count($aPaths) && !empty($aPaths[0])) { $sFirstPart = strtolower($aPaths[0]); if ('ping' === $sFirstPart) { @header('Content-Type: text/plain; charset=utf-8'); $sResult = 'Pong'; } else { if ('pull' === $sFirstPart) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { pclose(popen("start /B git pull", "r")); } else { exec("git pull > /dev/null 2>&1 &"); } \CApi::Location('./'); } else { if ('ajax' === $sFirstPart) { @ob_start(); $aResponseItem = null; $sAction = $this->oHttp->GetPost('Action', null); try { \CApi::Log('AJAX: Action: ' . $sAction); if ('SystemGetAppData' !== $sAction && \CApi::GetConf('labs.webmail.csrftoken-protection', true) && !$this->validateToken()) { throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidToken); } else { if (!empty($sAction)) { $sMethodName = 'Ajax' . $sAction; $this->oActions->SetActionParams($this->oHttp->GetPostAsArray()); if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) { $aResponseItem = call_user_func(array($this->oActions, $sMethodName)); } if (\CApi::Plugin()->JsonHookExists($sMethodName)) { $aResponseItem = \CApi::Plugin()->RunJsonHook($this->oActions, $sMethodName, $aResponseItem); } } } if (!is_array($aResponseItem)) { throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError); } } catch (\Exception $oException) { //if ($oException instanceof \ProjectCore\Exceptions\ClientException && // \ProjectCore\Notifications::AuthError === $oException->getCode()) //{ // $oApiIntegrator = /* @var $oApiIntegrator \CApiIntegratorManager */ \CApi::Manager('integrator'); // $oApiIntegrator->setLastErrorCode(\ProjectCore\Notifications::AuthError); // $oApiIntegrator->logoutAccount(); //} \CApi::LogException($oException); $sAction = empty($sAction) ? 'Unknown' : $sAction; $aAdditionalParams = null; if ($oException instanceof \ProjectCore\Exceptions\ClientException) { $aAdditionalParams = $oException->GetObjectParams(); } $aResponseItem = $this->oActions->ExceptionResponse(null, $sAction, $oException, $aAdditionalParams); } @header('Content-Type: application/json; charset=utf-8'); \CApi::Plugin()->RunHook('ajax.response-result', array($sAction, &$aResponseItem)); $sResult = \MailSo\Base\Utils::Php2js($aResponseItem, \CApi::MailSoLogger()); // \CApi::Log('AJAX: Response: '.$sResult); } else { if ('upload' === $sFirstPart) { @ob_start(); $aResponseItem = null; $sAction = empty($aPaths[1]) ? '' : $aPaths[1]; if ($this->oHttp->IsPut()) { $rPutData = fopen("php://input", "r"); $aFilePath = array_slice($aPaths, 3); $sFilePath = implode('/', $aFilePath); $this->oActions->SetActionParams(array('FileData' => array('name' => basename($sFilePath), 'size' => (int) $this->oHttp->GetHeader('Content-Length'), 'tmp_name' => $rPutData), 'AdditionalData' => json_encode(array('Type' => empty($aPaths[2]) ? 'personal' : strtolower($aPaths[2]), 'CalendarID' => empty($aPaths[2]) ? '' : strtolower($aPaths[2]), 'Folder' => dirname($sFilePath), 'Path' => dirname($sFilePath), 'GroupId' => '', 'IsShared' => false)), 'IsExt' => '1' === (string) $this->oHttp->GetQuery('IsExt', '0') ? '1' : '0', 'TenantHash' => (string) $this->oHttp->GetQuery('TenantHash', ''), 'AuthToken' => $this->oHttp->GetHeader('Auth-Token'), 'AccountID' => empty($aPaths[2]) ? '0' : strtolower($aPaths[2]))); try { $sMethodName = 'Upload' . $sAction; if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) { $aResponseItem = call_user_func(array($this->oActions, $sMethodName)); } if (!is_array($aResponseItem) && empty($sError)) { throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError); } } catch (\Exception $oException) { \CApi::LogException($oException); $aResponseItem = $this->oActions->ExceptionResponse(null, 'Upload', $oException); $sError = 'exception'; } if (0 < strlen($sError)) { $aResponseItem['Error'] = $sError; } } else { try { $sMethodName = 'Upload' . $sAction; if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) { $sError = ''; $sInputName = 'jua-uploader'; $iError = UPLOAD_ERR_OK; $_FILES = isset($_FILES) ? $_FILES : null; if (isset($_FILES, $_FILES[$sInputName], $_FILES[$sInputName]['name'], $_FILES[$sInputName]['tmp_name'], $_FILES[$sInputName]['size'], $_FILES[$sInputName]['type'])) { $iError = isset($_FILES[$sInputName]['error']) ? (int) $_FILES[$sInputName]['error'] : UPLOAD_ERR_OK; if (UPLOAD_ERR_OK === $iError) { $this->oActions->SetActionParams(array('AccountID' => $this->oHttp->GetPost('AccountID', ''), 'FileData' => $_FILES[$sInputName], 'AdditionalData' => $this->oHttp->GetPost('AdditionalData', null), 'IsExt' => '1' === (string) $this->oHttp->GetPost('IsExt', '0') ? '1' : '0', 'TenantHash' => (string) $this->oHttp->GetPost('TenantHash', ''), 'Token' => $this->oHttp->GetPost('Token', ''), 'AuthToken' => $this->oHttp->GetPost('AuthToken', ''))); \CApi::LogObject($this->oActions->GetActionParams()); $aResponseItem = call_user_func(array($this->oActions, $sMethodName)); } else { $sError = $this->oActions->convertUploadErrorToString($iError); } } else { if (!isset($_FILES) || !is_array($_FILES) || 0 === count($_FILES)) { $sError = 'size'; } else { $sError = 'unknown'; } } } if (!is_array($aResponseItem) && empty($sError)) { throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::UnknownError); } } catch (\Exception $oException) { \CApi::LogException($oException); $aResponseItem = $this->oActions->ExceptionResponse(null, 'Upload', $oException); $sError = 'exception'; } if (0 < strlen($sError)) { $aResponseItem['Error'] = $sError; } } @ob_get_clean(); @header('Content-Type: text/html; charset=utf-8'); $sResult = \MailSo\Base\Utils::Php2js($aResponseItem); } else { if ('speclogon' === $sFirstPart || 'speclogoff' === $sFirstPart) { \CApi::SpecifiedUserLogging('speclogon' === $sFirstPart); \CApi::Location('./'); } else { if ('sso' === $sFirstPart) { $oApiIntegratorManager = \CApi::Manager('integrator'); try { $sHash = $this->oHttp->GetRequest('hash'); if (!empty($sHash)) { $sData = \CApi::Cacher()->get('SSO:' . $sHash, true); $aData = \CApi::DecodeKeyValues($sData); if (!empty($aData['Email']) && isset($aData['Password'], $aData['Login'])) { $oAccount = $oApiIntegratorManager->loginToAccount($aData['Email'], $aData['Password'], $aData['Login']); if ($oAccount) { $oApiIntegratorManager->setAccountAsLoggedIn($oAccount); } } } else { $oApiIntegratorManager->logoutAccount(); } } catch (\Exception $oExc) { \CApi::LogException($oExc); } \CApi::Location('./'); } else { if ('autodiscover' === $sFirstPart) { $oSettings =& \CApi::GetSettings(); $sInput = \file_get_contents('php://input'); \CApi::Log('#autodiscover:'); \CApi::LogObject($sInput); $aMatches = array(); $aEmailAddress = array(); \preg_match("/\\<AcceptableResponseSchema\\>(.*?)\\<\\/AcceptableResponseSchema\\>/i", $sInput, $aMatches); \preg_match("/\\<EMailAddress\\>(.*?)\\<\\/EMailAddress\\>/", $sInput, $aEmailAddress); if (!empty($aMatches[1]) && !empty($aEmailAddress[1])) { $sIncMailServer = trim($oSettings->GetConf('WebMail/ExternalHostNameOfLocalImap')); $sOutMailServer = trim($oSettings->GetConf('WebMail/ExternalHostNameOfLocalSmtp')); if (0 < \strlen($sIncMailServer) && 0 < \strlen($sOutMailServer)) { $iIncMailPort = 143; $iOutMailPort = 25; $aMatch = array(); if (\preg_match('/:([\\d]+)$/', $sIncMailServer, $aMatch) && !empty($aMatch[1]) && is_numeric($aMatch[1])) { $sIncMailServer = preg_replace('/:[\\d]+$/', $sIncMailServer, ''); $iIncMailPort = (int) $aMatch[1]; } $aMatch = array(); if (\preg_match('/:([\\d]+)$/', $sOutMailServer, $aMatch) && !empty($aMatch[1]) && is_numeric($aMatch[1])) { $sOutMailServer = preg_replace('/:[\\d]+$/', $sOutMailServer, ''); $iOutMailPort = (int) $aMatch[1]; } $sResult = \implode("\n", array('<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">', ' <Response xmlns="' . $aMatches[1] . '">', ' <Account>', ' <AccountType>email</AccountType>', ' <Action>settings</Action>', ' <Protocol>', ' <Type>IMAP</Type>', ' <Server>' . $sIncMailServer . '</Server>', ' <LoginName>' . $aEmailAddress[1] . '</LoginName>', ' <Port>' . $iIncMailPort . '</Port>', ' <SSL>' . (993 === $iIncMailPort ? 'on' : 'off') . '</SSL>', ' <SPA>off</SPA>', ' <AuthRequired>on</AuthRequired>', ' </Protocol>', ' <Protocol>', ' <Type>SMTP</Type>', ' <Server>' . $sOutMailServer . '</Server>', ' <LoginName>' . $aEmailAddress[1] . '</LoginName>', ' <Port>' . $iOutMailPort . '</Port>', ' <SSL>' . (465 === $iOutMailPort ? 'on' : 'off') . '</SSL>', ' <SPA>off</SPA>', ' <AuthRequired>on</AuthRequired>', ' </Protocol>', ' </Account>', ' </Response>', '</Autodiscover>')); } } if (empty($sResult)) { $usec = $sec = 0; list($usec, $sec) = \explode(' ', microtime()); $sResult = \implode("\n", array('<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">', empty($aMatches[1]) ? ' <Response>' : ' <Response xmlns="' . $aMatches[1] . '">', ' <Error Time="' . \gmdate('H:i:s', $sec) . \substr($usec, 0, \strlen($usec) - 2) . '" Id="2477272013">', ' <ErrorCode>600</ErrorCode>', ' <Message>Invalid Request</Message>', ' <DebugData />', ' </Error>', ' </Response>', '</Autodiscover>')); } header('Content-Type: text/xml'); $sResult = '<' . '?xml version="1.0" encoding="utf-8"?' . '>' . "\n" . $sResult; \CApi::Log(''); \CApi::Log($sResult); } else { if ('profile' === $sFirstPart) { /* @var $oApiIosManager \CApiIosManager */ $oApiIosManager = \CApi::Manager('ios'); $oAccount = $oApiIntegrator->getLogginedDefaultAccount(); $mResultProfile = $oApiIosManager && $oAccount ? $oApiIosManager->generateXMLProfile($oAccount) : false; if ($mResultProfile !== false) { header('Content-type: application/x-apple-aspen-config; chatset=utf-8'); header('Content-Disposition: attachment; filename="afterlogic.mobileconfig"'); echo $mResultProfile; } else { \CApi::Location('./?IOS/Error'); } } else { if ('ios' === $sFirstPart) { $sResult = file_get_contents(PSEVEN_APP_ROOT_PATH . 'templates/Ios.html'); $iUserId = $oApiIntegrator->getLogginedUserId(); if (0 < $iUserId) { $oAccount = $oApiIntegrator->getLogginedDefaultAccount(); $bError = isset($aPaths[1]) && 'error' === strtolower($aPaths[1]); // TODO @setcookie('skip_ios', '1', time() + 3600 * 3600, '/', null, null, true); $sResult = strtr($sResult, array('{{IOS/HELLO}}' => \CApi::ClientI18N('IOS/HELLO', $oAccount), '{{IOS/DESC_P1}}' => \CApi::ClientI18N('IOS/DESC_P1', $oAccount), '{{IOS/DESC_P2}}' => \CApi::ClientI18N('IOS/DESC_P2', $oAccount), '{{IOS/DESC_P3}}' => \CApi::ClientI18N('IOS/DESC_P3', $oAccount), '{{IOS/DESC_P4}}' => \CApi::ClientI18N('IOS/DESC_P4', $oAccount), '{{IOS/DESC_P5}}' => \CApi::ClientI18N('IOS/DESC_P5', $oAccount), '{{IOS/DESC_P6}}' => \CApi::ClientI18N('IOS/DESC_P6', $oAccount), '{{IOS/DESC_P7}}' => \CApi::ClientI18N('IOS/DESC_P7', $oAccount), '{{IOS/DESC_BUTTON_YES}}' => \CApi::ClientI18N('IOS/DESC_BUTTON_YES', $oAccount), '{{IOS/DESC_BUTTON_SKIP}}' => \CApi::ClientI18N('IOS/DESC_BUTTON_SKIP', $oAccount), '{{IOS/DESC_BUTTON_OPEN}}' => \CApi::ClientI18N('IOS/DESC_BUTTON_OPEN', $oAccount), '{{AppVersion}}' => PSEVEN_APP_VERSION, '{{IntegratorLinks}}' => $oApiIntegrator->buildHeadersLink())); } else { \CApi::Location('./'); } } else { if ('raw' === $sFirstPart) { $sAction = empty($aPaths[1]) ? '' : $aPaths[1]; try { if (!empty($sAction)) { $sMethodName = 'Raw' . $sAction; if (method_exists($this->oActions, $sMethodName)) { $this->oActions->SetActionParams(array('AccountID' => empty($aPaths[2]) || '0' === (string) $aPaths[2] ? '' : $aPaths[2], 'RawKey' => empty($aPaths[3]) ? '' : $aPaths[3], 'IsExt' => empty($aPaths[4]) ? '0' : ('1' === (string) $aPaths[4] ? '1' : 0), 'TenantHash' => empty($aPaths[5]) ? '' : $aPaths[5], 'AuthToken' => empty($aPaths[6]) ? '' : $aPaths[6])); if (!call_user_func(array($this->oActions, $sMethodName))) { \CApi::Log('False result.', \ELogLevel::Error); } } else { \CApi::Log('Invalid action.', \ELogLevel::Error); } } else { \CApi::Log('Empty action.', \ELogLevel::Error); } } catch (\Exception $oException) { \CApi::LogException($oException, \ELogLevel::Error); $this->oHttp->StatusHeader(404); } } else { if ('post' === $sFirstPart) { $sAction = $this->oHttp->GetPost('Action'); try { if (!empty($sAction)) { $sMethodName = 'Post' . $sAction; if (method_exists($this->oActions, $sMethodName) && is_callable(array($this->oActions, $sMethodName))) { $this->oActions->SetActionParams($this->oHttp->GetPostAsArray()); if (!call_user_func(array($this->oActions, $sMethodName))) { \CApi::Log('False result.', \ELogLevel::Error); } } else { \CApi::Log('Invalid action.', \ELogLevel::Error); } } else { \CApi::Log('Empty action.', \ELogLevel::Error); } } catch (\Exception $oException) { \CApi::LogException($oException, \ELogLevel::Error); } } else { if (\CApi::IsHelpdeskModule()) { $sResult = $this->indexHTML(true, $this->oHttp->GetQuery('helpdesk')); } else { if ($this->oHttp->HasQuery('invite')) { $aInviteValues = \CApi::DecodeKeyValues($this->oHttp->GetQuery('invite')); $oApiUsersManager = \CApi::Manager('users'); $oApiCalendarManager = \CApi::Manager('calendar'); if (isset($aInviteValues['organizer'])) { $oAccountOrganizer = $oApiUsersManager->getAccountByEmail($aInviteValues['organizer']); if (isset($oAccountOrganizer, $aInviteValues['attendee'], $aInviteValues['calendarId'], $aInviteValues['eventId'], $aInviteValues['action'])) { $oCalendar = $oApiCalendarManager->getCalendar($oAccountOrganizer, $aInviteValues['calendarId']); if ($oCalendar) { $oEvent = $oApiCalendarManager->getEvent($oAccountOrganizer, $aInviteValues['calendarId'], $aInviteValues['eventId']); if ($oEvent && is_array($oEvent) && 0 < count($oEvent) && isset($oEvent[0])) { if (is_string($sResult)) { $sResult = file_get_contents(PSEVEN_APP_ROOT_PATH . 'templates/CalendarEventInviteExternal.html'); $dt = new \DateTime(); $dt->setTimestamp($oEvent[0]['startTS']); if (!$oEvent[0]['allDay']) { $sDefaultTimeZone = new \DateTimeZone($oAccountOrganizer->getDefaultStrTimeZone()); $dt->setTimezone($sDefaultTimeZone); } $sAction = $aInviteValues['action']; $sActionColor = 'green'; $sActionText = ''; switch (strtoupper($sAction)) { case 'ACCEPTED': $sActionColor = 'green'; $sActionText = 'Accepted'; break; case 'DECLINED': $sActionColor = 'red'; $sActionText = 'Declined'; break; case 'TENTATIVE': $sActionColor = '#A0A0A0'; $sActionText = 'Tentative'; break; } $sDateFormat = 'm/d/Y'; $sTimeFormat = 'h:i A'; switch ($oAccountOrganizer->User->DefaultDateFormat) { case \EDateFormat::DDMMYYYY: $sDateFormat = 'd/m/Y'; break; case \EDateFormat::DD_MONTH_YYYY: $sDateFormat = 'd/m/Y'; break; default: $sDateFormat = 'm/d/Y'; break; } switch ($oAccountOrganizer->User->DefaultTimeFormat) { case \ETimeFormat::F24: $sTimeFormat = 'H:i'; break; case \EDateFormat::DD_MONTH_YYYY: \ETimeFormat::F12; $sTimeFormat = 'h:i A'; break; default: $sTimeFormat = 'h:i A'; break; } $sDateTime = $dt->format($sDateFormat . ' ' . $sTimeFormat); $mResult = array('{{COLOR}}' => $oCalendar->Color, '{{EVENT_NAME}}' => $oEvent[0]['subject'], '{{EVENT_BEGIN}}' => ucfirst(\CApi::ClientI18N('REMINDERS/EVENT_BEGIN', $oAccountOrganizer)), '{{EVENT_DATE}}' => $sDateTime, '{{CALENDAR}}' => ucfirst(\CApi::ClientI18N('REMINDERS/CALENDAR', $oAccountOrganizer)), '{{CALENDAR_NAME}}' => $oCalendar->DisplayName, '{{EVENT_DESCRIPTION}}' => $oEvent[0]['description'], '{{EVENT_ACTION}}' => $sActionText, '{{ACTION_COLOR}}' => $sActionColor); $sResult = strtr($sResult, $mResult); } else { \CApi::Log('Empty template.', \ELogLevel::Error); } } else { \CApi::Log('Event not found.', \ELogLevel::Error); } } else { \CApi::Log('Calendar not found.', \ELogLevel::Error); } $sAttendee = $aInviteValues['attendee']; if (!empty($sAttendee)) { $oApiCalendarManager->updateAppointment($oAccountOrganizer, $aInviteValues['calendarId'], $aInviteValues['eventId'], $sAttendee, $aInviteValues['action']); } } } } else { if (\CApi::IsCalendarPubModule()) { $sResult = $this->indexHTML(false, '', $this->oHttp->GetQuery('calendar-pub')); } else { if (\CApi::IsFilesPubModule()) { $sResult = $this->indexHTML(false, '', '', $this->oHttp->GetQuery('files-pub')); } else { if ('min' === $sFirstPart || 'window' === $sFirstPart) { $sAction = empty($aPaths[1]) ? '' : $aPaths[1]; try { if (!empty($sAction)) { $sMethodName = $aPaths[0] . $sAction; if (method_exists($this->oActions, $sMethodName)) { if ('Min' === $aPaths[0]) { $oMinManager = \CApi::Manager('min'); $mHashResult = $oMinManager->getMinByHash(empty($aPaths[2]) ? '' : $aPaths[2]); $this->oActions->SetActionParams(array('Result' => $mHashResult, 'Hash' => empty($aPaths[2]) ? '' : $aPaths[2])); } else { $this->oActions->SetActionParams(array('AccountID' => empty($aPaths[2]) || '0' === (string) $aPaths[2] ? '' : $aPaths[2], 'RawKey' => empty($aPaths[3]) ? '' : $aPaths[3])); } $mResult = call_user_func(array($this->oActions, $sMethodName)); $sTemplate = isset($mResult['Template']) && !empty($mResult['Template']) && is_string($mResult['Template']) ? $mResult['Template'] : null; if (!empty($sTemplate) && is_array($mResult) && file_exists(PSEVEN_APP_ROOT_PATH . $sTemplate)) { $sResult = file_get_contents(PSEVEN_APP_ROOT_PATH . $sTemplate); if (is_string($sResult)) { $sResult = strtr($sResult, $mResult); } else { \CApi::Log('Empty template.', \ELogLevel::Error); } } else { if (!empty($sTemplate)) { \CApi::Log('Empty template.', \ELogLevel::Error); } else { if (true === $mResult) { $sResult = ''; } else { \CApi::Log('False result.', \ELogLevel::Error); } } } } else { \CApi::Log('Invalid action.', \ELogLevel::Error); } } else { \CApi::Log('Empty action.', \ELogLevel::Error); } } catch (\Exception $oException) { \CApi::LogException($oException); } } else { if ('twilio' === $sFirstPart) { $sResult = $this->oTwilio->getTwiML($aPaths, $this->oHttp); } else { if ('plugins' === $sFirstPart) { $sType = !empty($aPaths[1]) ? trim($aPaths[1]) : ''; if ('js' === $sType) { @header('Content-Type: application/javascript; charset=utf-8'); $sResult = \CApi::Plugin()->CompileJs(); } else { if ('images' === $sType) { if (!empty($aPaths[2]) && !empty($aPaths[3])) { $oPlugin = \CApi::Plugin()->GetPluginByName($aPaths[2]); if ($oPlugin) { echo $oPlugin->GetImage($aPaths[3]); exit; } } } else { if ('fonts' === $sType) { if (!empty($aPaths[2]) && !empty($aPaths[3])) { $oPlugin = \CApi::Plugin()->GetPluginByName($aPaths[2]); if ($oPlugin) { echo $oPlugin->GetFont($aPaths[3]); exit; } } } } } } else { if ('postlogin' === $sFirstPart && \CApi::GetConf('labs.allow-post-login', false)) { $oSettings =& \CApi::GetSettings(); $sEmail = trim((string) $this->oHttp->GetRequest('Email', '')); $sLogin = (string) $this->oHttp->GetRequest('Login', ''); $sPassword = (string) $this->oHttp->GetRequest('Password', ''); $sAtDomain = trim($oSettings->GetConf('WebMail/LoginAtDomainValue')); if (\ELoginFormType::Login === (int) $oSettings->GetConf('WebMail/LoginFormType') && 0 < strlen($sAtDomain)) { $sEmail = \api_Utils::GetAccountNameFromEmail($sLogin) . '@' . $sAtDomain; $sLogin = $sEmail; } if (0 !== strlen($sPassword) && 0 !== strlen($sEmail . $sLogin)) { try { $oAccount = $oApiIntegrator->loginToAccount($sEmail, $sPassword, $sLogin); } catch (\Exception $oException) { $iErrorCode = \ProjectCore\Notifications::UnknownError; if ($oException instanceof \CApiManagerException) { switch ($oException->getCode()) { case \Errs::WebMailManager_AccountDisabled: case \Errs::WebMailManager_AccountWebmailDisabled: $iErrorCode = \ProjectCore\Notifications::AuthError; break; case \Errs::UserManager_AccountAuthenticationFailed: case \Errs::WebMailManager_AccountAuthentication: case \Errs::WebMailManager_NewUserRegistrationDisabled: case \Errs::WebMailManager_AccountCreateOnLogin: case \Errs::Mail_AccountAuthentication: case \Errs::Mail_AccountLoginFailed: $iErrorCode = \ProjectCore\Notifications::AuthError; break; case \Errs::UserManager_AccountConnectToMailServerFailed: case \Errs::WebMailManager_AccountConnectToMailServerFailed: case \Errs::Mail_AccountConnectToMailServerFailed: $iErrorCode = \ProjectCore\Notifications::MailServerError; break; case \Errs::UserManager_LicenseKeyInvalid: case \Errs::UserManager_AccountCreateUserLimitReached: case \Errs::UserManager_LicenseKeyIsOutdated: case \Errs::TenantsManager_AccountCreateUserLimitReached: $iErrorCode = \ProjectCore\Notifications::LicenseProblem; break; case \Errs::Db_ExceptionError: $iErrorCode = \ProjectCore\Notifications::DataBaseError; break; } } $sRedirectUrl = \CApi::GetConf('labs.post-login-error-redirect-url', './'); \CApi::Location($sRedirectUrl . '?error=' . $iErrorCode); exit; } if ($oAccount instanceof \CAccount) { $oApiIntegrator->setAccountAsLoggedIn($oAccount); } } \CApi::Location('./'); } else { if ('mobile' === $sFirstPart) { if ($oApiIntegrator && $oApiCapability && $oApiCapability->isNotLite()) { $oApiIntegrator->setMobile(true); } \CApi::Location('./'); } else { @ob_start(); \CApi::Plugin()->RunServiceHandle($sFirstPart, $aPaths); $sResult = @ob_get_clean(); if (0 === strlen($sResult)) { $sResult = $this->getIndexHTML(); } } } } } } } } } } } } } } } } } } } } } } else { $sResult = $this->getIndexHTML(); } // Output result echo $sResult; }
/** * @param string $sKey * * @return mixed */ protected function parseGetConf($sKey) { $mValue = null; $sKey = strtolower($sKey); if (isset($this->aLowerMap[$sKey])) { if (array_key_exists($sKey, $this->aContainer)) { $mValue = $this->aContainer[$sKey]; } else { $mValue = $this->aLowerMap[$sKey][0]; } $aType = $this->aLowerMap[$sKey]; switch ($aType[1]) { case 'string': $mValue = api_Utils::EncodeSpecialXmlChars((string) $mValue); break; case 'int': $mValue = (int) $mValue; break; case 'bool': $mValue = (bool) $mValue ? 'On' : 'Off'; break; case 'spec': $mValue = $this->specBackConver($sKey, $mValue); break; } } return $mValue; }
public function AjaxSocialAccountListGet() { $mResult['Result'] = false; $oTenant = null; $oAccount = \api_Utils::GetDefaultAccount(); $oApiTenants = \CApi::Manager('tenants'); if ($oAccount && $oApiTenants) { $oTenant = 0 < $oAccount->IdTenant ? $oApiTenants->getTenantById($oAccount->IdTenant) : $oApiTenants->getDefaultGlobalTenant(); } if ($oTenant) { $oApiSocial = \CApi::Manager('social'); $mResult['Result'] = $oApiSocial->getSocials($oAccount->IdAccount); } return $mResult; }
/** * Obtains a list of specific messages. * * @param CAccount $oAccount Account object. * @param string $sFolderFullNameRaw Raw full name of the folder. * @param array $aUids List of message UIDs. * * @return CApiMailMessageCollection * * @throws CApiInvalidArgumentException */ public function getMessageListByUids($oAccount, $sFolderFullNameRaw, $aUids) { if (0 === strlen($sFolderFullNameRaw) || !is_array($aUids) || 0 === count($aUids)) { throw new CApiInvalidArgumentException(); } $oMessageCollection = false; $oImapClient =& $this->_getImapClient($oAccount); $oImapClient->FolderExamine($sFolderFullNameRaw); $aList = $this->_getFolderInformation($oImapClient, $sFolderFullNameRaw); $iMessageRealCount = $aList[0]; $iMessageUnseenCount = $aList[1]; $sUidNext = $aList[2]; $oMessageCollection = CApiMailMessageCollection::createInstance(); $oMessageCollection->FolderName = $sFolderFullNameRaw; $oMessageCollection->Offset = 0; $oMessageCollection->Limit = 0; $oMessageCollection->Search = ''; $oMessageCollection->UidNext = $sUidNext; if (0 < $iMessageRealCount) { $bIndexAsUid = true; $aIndexOrUids = $aUids; if (is_array($aIndexOrUids)) { $oMessageCollection->MessageCount = $iMessageRealCount; $oMessageCollection->MessageUnseenCount = $iMessageUnseenCount; $oMessageCollection->MessageSearchCount = $oMessageCollection->MessageCount; $oMessageCollection->MessageResultCount = $oMessageCollection->MessageCount; if (0 < count($aIndexOrUids)) { $aRequestIndexOrUids = $aIndexOrUids; if ($bIndexAsUid) { $oMessageCollection->Uids = $aRequestIndexOrUids; } if (is_array($aRequestIndexOrUids) && 0 < count($aRequestIndexOrUids)) { $aFetchResponse = $oImapClient->Fetch(array(\MailSo\Imap\Enumerations\FetchType::INDEX, \MailSo\Imap\Enumerations\FetchType::UID, \MailSo\Imap\Enumerations\FetchType::RFC822_SIZE, \MailSo\Imap\Enumerations\FetchType::INTERNALDATE, \MailSo\Imap\Enumerations\FetchType::FLAGS, \MailSo\Imap\Enumerations\FetchType::BODYSTRUCTURE, \MailSo\Imap\Enumerations\FetchType::BODY_HEADER_PEEK), implode(',', $aRequestIndexOrUids), $bIndexAsUid); if (is_array($aFetchResponse) && 0 < count($aFetchResponse)) { $aFetchIndexArray = array(); $oFetchResponseItem = null; foreach ($aFetchResponse as &$oFetchResponseItem) { $aFetchIndexArray[$bIndexAsUid ? $oFetchResponseItem->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID) : $oFetchResponseItem->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::INDEX)] =& $oFetchResponseItem; unset($oFetchResponseItem); } foreach ($aRequestIndexOrUids as $iFUid) { if (isset($aFetchIndexArray[$iFUid])) { $oMailMessage = CApiMailMessage::createInstance($oMessageCollection->FolderName, $aFetchIndexArray[$iFUid]); if (!$bIndexAsUid) { $oMessageCollection->Uids[] = $oMailMessage->getUid(); } $oMessageCollection->Add($oMailMessage); unset($oMailMessage); } } } } } } } $oMessageCollection->FolderHash = api_Utils::GenerateFolderHash($sFolderFullNameRaw, $oMessageCollection->MessageCount, $oMessageCollection->MessageUnseenCount, $oMessageCollection->UidNext); return $oMessageCollection; }
/** * @param string $sName * @return string */ public function GetParamTagValueByName($sName) { $oParam =& $this->getParamNodeByName($sName); return null !== $oParam ? api_Utils::DecodeSpecialXmlChars($oParam->Value) : ''; }
/** * @return bool */ public function RawIframe() { $sEncodedUrl = $this->getParamValue('RawKey', ''); $sUrl = urldecode($sEncodedUrl); $sUrl = trim(trim($sUrl), '/\\?'); $aParts = null; if (!empty($sUrl)) { $aParts = explode('/', $sUrl); } if (is_array($aParts) && isset($aParts[0], $aParts[1], $aParts[2], $aParts[3])) { $aValues = \CApi::DecodeKeyValues($aParts[3]); if (isset($aValues['Iframed'], $aValues['Name'], $aValues['AccountID']) && (!isset($aValues['MimeType']) || !isset($aValues['FileName']))) { $aValues['FileName'] = $aValues['Name']; $aValues['MimeType'] = \api_Utils::MimeContentType($aValues['FileName']); } if (isset($aValues['Iframed'], $aValues['MimeType'], $aValues['FileName']) && $aValues['Iframed'] && \CApi::isIframedMimeTypeSupported($aValues['MimeType'], $aValues['FileName'])) { $oAccount = $this->getAccountFromParam(false); if ($oAccount) { $sNewUrl = ''; $sNewHash = ''; $sResultUrl = ''; $aSubParts = \CApi::DecodeKeyValues($aParts[3]); if (isset($aSubParts['Iframed']) && (int) $aParts[2] === (int) $oAccount->IdAccount && 0 < $oAccount->IdAccount) { $aSubParts['Time'] = \time(); $sNewHash = \CApi::EncodeKeyValues($aSubParts); } if (!empty($sNewHash)) { $aParts[3] = $sNewHash; $sNewUrl = rtrim(trim($this->oHttp->GetFullUrl()), '/') . '/?/' . implode('/', $aParts); \CApi::Plugin()->RunHook('webmail.filter.iframed-attachments-url', array(&$sResultUrl, $sNewUrl, $aValues['MimeType'], $aValues['FileName'])); if (empty($sResultUrl) && \CApi::GetConf('labs.allow-officeapps-viewer', true)) { $sResultUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' . urlencode($sNewUrl); } } if (!empty($sResultUrl)) { header('Content-Type: text/html', true); echo '<html style="height: 100%; width: 100%; margin: 0; padding: 0"><head></head><body' . ' style="height: 100%; width: 100%; margin: 0; padding: 0">' . '<iframe style="height: 100%; width: 100%; margin: 0; padding: 0; border: 0" src="' . $sResultUrl . '"></iframe></body></html>'; return true; } } } } return false; }
public function getFullQuotaInfo() { $iFreeSize = 0; $sRootPath = $this->getRootPath(\EFileStorageTypeStr::Personal); $aSize = \api_Utils::GetDirectorySize($sRootPath); $iUsageSize = (int) $aSize['size']; $sRootPath = $this->getRootPath(\EFileStorageTypeStr::Corporate); $aSize = \api_Utils::GetDirectorySize($sRootPath); $iUsageSize += (int) $aSize['size']; $oAccount = $this->getAccount(); if ($oAccount) { $oTenant = $this->getTenant(); if ($oTenant) { $iFreeSize = $oTenant->FilesUsageDynamicQuotaInMB * 1024 * 1024 - $iUsageSize; } } return array($iUsageSize, $iFreeSize); }
/** * @param string $sLogin * @param string $sAtChar = '@' */ public function InitLoginAndEmail($sLogin, $sAtChar = '@') { $this->Email = ''; $this->IncomingMailLogin = $sLogin; $sLoginPart = api_Utils::GetAccountNameFromEmail($sLogin); $sDomainPart = api_Utils::GetDomainFromEmail($sLogin); $sDomainName = $this->Domain->IsDefaultDomain || $this->Domain->IsDefaultTenantDomain ? $sDomainPart : $this->Domain->Name; if (!empty($sDomainName)) { $this->Email = $sLoginPart . $sAtChar . $sDomainName; if ($this->Domain && $this->Domain->IsInternal && 0 < strlen($this->Domain->Name)) { $this->IncomingMailLogin = $sLoginPart . $sAtChar . $this->Domain->Name; } } }
/** * @param CAcount $oAccount * @param array $aFilters * * @return bool */ public function updateSieveFilters($oAccount, $aFilters) { $sFilters = "#sieve filter\n\n"; if ($oAccount) { foreach ($aFilters as $oFilter) { if ('' === trim($oFilter->Filter)) { continue; } if (EFilterAction::MoveToFolder === $oFilter->Action && '' === trim($oFilter->FolderFullName)) { continue; } $aFields = array(); switch ($oFilter->Field) { default: case EFilterFiels::From: $aFields[] = 'From'; break; case EFilterFiels::To: $aFields[] = 'To'; $aFields[] = 'CC'; break; case EFilterFiels::Subject: $aFields[] = 'Subject'; break; } // condition foreach ($aFields as $iIndex => $sField) { $aFields[$iIndex] = '"' . $this->_quoteValue($sField) . '"'; } $sCondition = ''; $sFields = implode(',', $aFields); switch ($oFilter->Condition) { case EFilterCondition::ContainSubstring: $sCondition = 'if header :contains [' . $sFields . '] "' . $this->_quoteValue($oFilter->Filter) . '" {'; break; case EFilterCondition::ContainExactPhrase: $sCondition = 'if header :is [' . $sFields . '] "' . $this->_quoteValue($oFilter->Filter) . '" {'; break; case EFilterCondition::NotContainSubstring: $sCondition = 'if not header :contains [' . $sFields . '] "' . $this->_quoteValue($oFilter->Filter) . '" {'; break; } // folder $sFolderFullName = ''; if (EFilterAction::MoveToFolder === $oFilter->Action) { $sFolderFullName = api_Utils::ConvertEncoding($oFilter->FolderFullName, 'utf7-imap', $this->sSieveFolderCharset); } // action $sAction = ''; switch ($oFilter->Action) { case EFilterAction::DeleteFromServerImmediately: $sAction = 'discard ;'; $sAction .= 'stop ;'; break; case EFilterAction::MoveToFolder: $sAction = 'fileinto "' . $this->_quoteValue($sFolderFullName) . '" ;' . "\n"; $sAction .= 'stop ;'; break; } $sEnd = '}'; if (!$oFilter->Enable) { $sCondition = '#' . $sCondition; $sAction = '#' . $sAction; $sEnd = '#' . $sEnd; } $sFilters .= "\n" . '#sieve_filter:' . implode(';', array($oFilter->Enable ? '1' : '0', $oFilter->Condition, $oFilter->Field, $oFilter->Filter, $oFilter->Action, $sFolderFullName)) . "\n"; $sFilters .= $sCondition . "\n"; $sFilters .= $sAction . "\n"; $sFilters .= $sEnd . "\n"; } $sFilters = $sFilters . "\n" . '#end sieve filter' . "\n"; return $this->setFiltersRawData($oAccount, $sFilters); } return false; }
/** * @return bool */ public function hasGdSupport() { return api_Utils::HasGdSupport(); }
public function GetFile($oAccount, $sType, $sPath, $sName, &$bResult, &$bBreak) { $oClient = $this->GetClient($oAccount, $sType); if ($oClient) { $bResult = false; $bBreak = true; $oDrive = new Google_Service_Drive($oClient); $oFile = $oDrive->files->get($sName); \api_Utils::PopulateGoogleDriveFileInfo($oFile); $oRequest = new Google_Http_Request($oFile->downloadUrl, 'GET', null, null); $oClientAuth = $oClient->getAuth(); $oClientAuth->sign($oRequest); $oHttpRequest = $oClientAuth->authenticatedRequest($oRequest); if ($oHttpRequest->getResponseHttpCode() === 200) { $bResult = fopen('php://memory', 'r+'); fwrite($bResult, $oHttpRequest->getResponseBody()); rewind($bResult); } } }
public static function Process($mResult) { $sSocialRedirect = ''; if (isset($_COOKIE["SocialRedirect"])) { $sSocialRedirect = $_COOKIE["SocialRedirect"]; @setcookie('SocialRedirect', null); } if ($sSocialRedirect === 'helpdesk') { self::SetValuesToCookie($mResult); $sTenantHash = self::GetTenantHashFromCookie(); if ($sTenantHash) { \CApi::Location('./?helpdesk=' . $sTenantHash); } else { \CApi::Location('./?helpdesk'); } } else { $oAccount = \api_Utils::GetDefaultAccount(); if ($oAccount) { $oApiSocial = \CApi::Manager('social'); $oSocial = new \CSocial(); $oSocial->IdAccount = $oAccount->IdAccount; switch ($mResult['type']) { case 'google': $oSocial->Type = \ESocialType::Google; $oSocial->AccessToken = $mResult['access_token']; $oSocial->RefreshToken = $mResult['refresh_token']; break; case 'dropbox': $oSocial->Type = \ESocialType::Dropbox; $oSocial->AccessToken = $mResult['access_token']; break; } $oSocial->IdSocial = $mResult['id']; $oSocial->Name = $mResult['name']; $bCreateResult = $oApiSocial->CreateSocial($oSocial); echo "<script>" . "if (typeof(window.opener.servicesSettingsViewModelCallback) !== 'undefined')" . "{" . "window.opener.servicesSettingsViewModelCallback('" . $mResult['type'] . "', " . $bCreateResult . ");" . "window.close();" . "}" . "</script>"; } } }
/** * @return string */ public static function DataPath() { $dataPath = 'data'; if (!defined('API_DATA_FOLDER') && @file_exists(CApi::WebMailPath() . 'inc_settings_path.php')) { include CApi::WebMailPath() . 'inc_settings_path.php'; } if (!defined('API_DATA_FOLDER') && isset($dataPath) && null !== $dataPath) { define('API_DATA_FOLDER', api_Utils::GetFullPath($dataPath, CApi::WebMailPath())); } return defined('API_DATA_FOLDER') ? API_DATA_FOLDER : ''; }
/** * @param object $oObject * @param object $oHelper * @return array */ public static function DbInsertArrays($oObject, $oHelper) { $aResult = array(false, false); $sQueryParams = ''; $bUseLogQueryParams = (bool) CApi::GetConf('labs.db.log-query-params', false); $oObject->initBeforeChange(); $aStaticMap = $oObject->getMap(); $aMap = api_AContainer::DbWriteKeys($aStaticMap, true); $aDbKeys = array_keys($aMap); $aResult[0] = array_map(array(&$oHelper, 'EscapeColumn'), $aDbKeys); $aDbValues = array_values($aMap); foreach ($aDbValues as $iIndex => $sKey) { $mValue = $oObject->{$sKey}; if (isset($aStaticMap[$sKey][0])) { if ('password' === $aStaticMap[$sKey][0]) { $mValue = api_Utils::EncodePassword($mValue); } else { if ('datetime' === $aStaticMap[$sKey][0]) { $mValue = $oHelper->TimeStampToDateFormat($mValue); } else { if ('serialize' === $aStaticMap[$sKey][0]) { $mValue = '' === $mValue ? '' : serialize($mValue); } } } } $aDbValues[$iIndex] = is_string($mValue) ? $oHelper->EscapeString($mValue) : (int) $mValue; if ($bUseLogQueryParams) { $sDbKey = isset($aDbKeys[$iIndex]) ? $aDbKeys[$iIndex] : '!unknown!'; $sQueryParams .= API_CRLF . API_TAB . $sDbKey . ' = ' . $aDbValues[$iIndex]; } } $aResult[1] = $aDbValues; if ($bUseLogQueryParams) { CApi::Log($sQueryParams); } return $aResult; }
/** * @param int $iUserId * @param int $iTenantId = 0 * @param bool $bAddGlobal = true * @return bool|array */ public function GetAllContactsNamesWithPhones($iUserId, $iTenantId = 0, $bAddGlobal = true) { $mNames = false; if ($this->oConnection->Execute($this->oCommandCreator->GetAllContactsNamesWithPhones($iUserId, $iTenantId, $bAddGlobal))) { $mNames = array(); while (false !== ($oRow = $this->oConnection->GetNextRecord())) { $sName = trim($oRow->fullname); if (0 === strlen($sName)) { $sName = trim($oRow->firstname); $sName .= ' ' . trim($oRow->surname); $sName = trim($sName); } if (0 === strlen($sName)) { $sName = trim($oRow->view_email); } if (0 < strlen($sName)) { $sPhone = trim($oRow->b_phone); if (0 < strlen($sPhone)) { $sPhone = api_Utils::ClearPhone($sPhone); if (0 < strlen($sPhone)) { $mNames[$sPhone] = $sName; } } $sPhone = trim($oRow->h_phone); if (0 < strlen($sPhone)) { $sPhone = api_Utils::ClearPhone($sPhone); if (0 < strlen($sPhone)) { $mNames[$sPhone] = $sName; } } $sPhone = trim($oRow->h_mobile); if (0 < strlen($sPhone)) { $sPhone = api_Utils::ClearPhone($sPhone); if (0 < strlen($sPhone)) { $mNames[$sPhone] = $sName; } } } } } return $mNames; }
/** * @param string $sName */ function PrintEncodedHtmlValue($sName) { echo api_Utils::EncodeSpecialXmlChars($this->GetValueAsString($sName)); }
/** * @param string $sLine * @return bool */ public function WriteLine($sLine, $aHideValues = array()) { $sLine = $sLine . "\r\n"; $sLogLine = 0 < count($aHideValues) ? str_replace($aHideValues, '*******', $sLine) : $sLine; CApi::Log('NET > ' . api_Utils::ShowCRLF($sLogLine)); if (!@fputs($this->rConnect, $sLine)) { CApi::Log('NET[Error] < Could not send user request', ELogLevel::Error); return false; } return true; }
/** * @param array $aTenantIds * * @return string */ function deleteTenants($aTenantIds) { $aIds = api_Utils::SetTypeArrayValue($aTenantIds, 'int'); $sSql = 'DELETE FROM %sawm_tenants WHERE id_tenant in (%s)'; return sprintf($sSql, $this->prefix(), implode(',', $aIds)); }
/** * @param CAccount $oAccount * @param array $aNumbers * @param bool $bUseCache = true * @return array */ public function getNamesByCallersNumbers($oAccount, $aNumbers, $bUseCache = true) { $mResult = false; $oApiContactsManager = CApi::Manager('contactsmain'); if (is_array($aNumbers) && 0 < count($aNumbers) && $oAccount && $oApiContactsManager) { $bFromCache = false; $sCacheKey = ''; $mNamesResult = null; $oApiFileCache = $bUseCache ? CApi::Manager('filecache') : false; if ($oApiFileCache) { $sCacheKey = $this->_generateCacheFileName($oAccount->IdUser); if (!empty($sCacheKey)) { $sData = $oApiFileCache->get($oAccount, $sCacheKey); if (!empty($sData)) { $mNamesResult = @json_decode($sData, true); if (!is_array($mNamesResult)) { $mNamesResult = null; } else { $bFromCache = true; CApi::Log('Cache: get contacts names from cache (count:' . count($mNamesResult) . ')'); } } } } if (!is_array($mNamesResult)) { $mNamesResult = $oApiContactsManager->GetAllContactsNamesWithPhones($oAccount); } if (is_array($mNamesResult)) { if (!$bFromCache && $oApiFileCache && 0 < strlen($sCacheKey)) { $oApiFileCache->put($oAccount, $sCacheKey, @json_encode($mNamesResult)); CApi::Log('Cache: save contacts names to cache (count:' . count($mNamesResult) . ')'); } $aNormNumbers = array(); foreach ($aNumbers as $sNumber) { $aNormNumbers[$sNumber] = api_Utils::ClearPhone($sNumber); } foreach ($aNormNumbers as $sInputNumber => $sClearNumber) { $aNormNumbers[$sInputNumber] = isset($mNamesResult[$sClearNumber]) ? $mNamesResult[$sClearNumber] : ''; } $mResult = $aNormNumbers; } } else { if (is_array($aNumbers)) { $mResult = array(); } } return $mResult; }
/** * @param CAccount $oAccount * * @return array */ private function appDataUserSettings($oAccount) { $aResult = array(); if ($oAccount) { $oSettings =& CApi::GetSettings(); $oApiCapabilityManager = CApi::Manager('capability'); /* @var $oApiCapabilityManager CApiCapabilityManager */ $aResult['IdUser'] = $oAccount->User->IdUser; $aResult['MailsPerPage'] = (int) $oAccount->User->MailsPerPage; $aResult['ContactsPerPage'] = (int) $oAccount->User->ContactsPerPage; $aResult['AutoCheckMailInterval'] = (int) $oAccount->User->AutoCheckMailInterval; $aResult['DefaultEditor'] = (int) $oAccount->User->DefaultEditor; $aResult['Layout'] = 0; $aResult['LoginsCount'] = $oAccount->User->LoginsCount; $aResult['CanLoginWithPassword'] = $oAccount->canLoginWithPassword(); if ($oAccount->User->LoginsCount === 1) { $oApiSocialManager = CApi::Manager('social'); $aSocials = $oApiSocialManager->getSocials($oAccount->IdAccount); if (count($aSocials) > 0) { $aResult['SocialName'] = $aSocials[0]->Name; } } $aResult['DefaultTheme'] = $oAccount->User->DefaultSkin; $aResult['DefaultLanguage'] = $oAccount->User->DefaultLanguage; $aResult['DefaultLanguageShort'] = api_Utils::ConvertLanguageNameToShort($oAccount->User->DefaultLanguage); $aResult['DefaultDateFormat'] = $oAccount->User->DefaultDateFormat; $aResult['DefaultTimeFormat'] = $oAccount->User->DefaultTimeFormat; $aResult['AllowCompose'] = (bool) $oAccount->AllowCompose; $aResult['AllowReply'] = (bool) $oAccount->AllowReply; $aResult['AllowForward'] = (bool) $oAccount->AllowForward; $aFetcherDomains = CApi::GetConf('labs.fetchers.domains', array()); $aResult['AllowFetcher'] = CApi::GetConf('labs.fetchers', false) && ($oAccount->Domain->IsInternal || \in_array($oAccount->IncomingMailServer, $aFetcherDomains)); $iSaveMail = $oSettings->GetConf('WebMail/SaveMail'); $iSaveMail = ESaveMail::Always !== $iSaveMail ? $oAccount->User->SaveMail : ESaveMail::Always; $aResult['SaveMail'] = (int) $iSaveMail; $aResult['ThreadsEnabled'] = !!$oAccount->Domain->UseThreads; $aResult['UseThreads'] = false; $aResult['SaveRepliedMessagesToCurrentFolder'] = false; $aResult['DesktopNotifications'] = (bool) $oAccount->User->DesktopNotifications; $aResult['AllowChangeInputDirection'] = (bool) $oAccount->User->AllowChangeInputDirection; $aResult['EnableOpenPgp'] = (bool) $oAccount->User->EnableOpenPgp; $aResult['AllowAutosaveInDrafts'] = (bool) $oAccount->User->AllowAutosaveInDrafts; $aResult['AutosignOutgoingEmails'] = (bool) $oAccount->User->AutosignOutgoingEmails; $aResult['EmailNotification'] = !empty($oAccount->User->EmailNotification) ? $oAccount->User->EmailNotification : $oAccount->Email; if ($aResult['ThreadsEnabled']) { $aResult['UseThreads'] = (bool) $oAccount->User->UseThreads; $aResult['SaveRepliedMessagesToCurrentFolder'] = (bool) $oAccount->User->SaveRepliedMessagesToCurrentFolder; } $aResult['OutlookSyncEnable'] = $oApiCapabilityManager->isOutlookSyncSupported($oAccount); $aResult['MobileSyncEnable'] = $oApiCapabilityManager->isMobileSyncSupported($oAccount); $aResult['ShowPersonalContacts'] = $oApiCapabilityManager->isPersonalContactsSupported($oAccount); $aResult['ShowGlobalContacts'] = $oApiCapabilityManager->isGlobalContactsSupported($oAccount, true); $aResult['IsCollaborationSupported'] = $oApiCapabilityManager->isCollaborationSupported(); $aResult['AllowFilesSharing'] = (bool) CApi::GetConf('labs.files-sharing', false); $aResult['IsFilesSupported'] = $oApiCapabilityManager->isFilesSupported($oAccount); $aResult['IsHelpdeskSupported'] = $oApiCapabilityManager->isHelpdeskSupported($oAccount); $aResult['IsHelpdeskAgent'] = $aResult['IsHelpdeskSupported']; // TODO $aResult['AllowHelpdeskNotifications'] = (bool) $oAccount->User->AllowHelpdeskNotifications; $aResult['HelpdeskSignature'] = (string) $oAccount->User->HelpdeskSignature; $aResult['HelpdeskSignatureEnable'] = (bool) $oAccount->User->HelpdeskSignatureEnable; $aResult['LastLogin'] = 0; if ($oSettings->GetConf('WebMail/EnableLastLoginNotification')) { $aResult['LastLogin'] = $oAccount->User->LastLogin; } $aResult['AllowVoice'] = false; $aResult['VoiceProvider'] = ''; $aResult['SipRealm'] = ''; $aResult['SipWebsocketProxyUrl'] = ''; $aResult['SipOutboundProxyUrl'] = ''; $aResult['SipCallerID'] = ''; $aResult['TwilioNumber'] = ''; $aResult['TwilioEnable'] = true; $aResult['SipEnable'] = true; $aResult['SipImpi'] = ''; $aResult['SipPassword'] = ''; $aResult['FilesEnable'] = $oAccount->User->FilesEnable; $oApiTenants = CApi::Manager('tenants'); /* @var $oApiTenants CApiTenantsManager */ if ($oApiTenants) { $oTenant = 0 < $oAccount->IdTenant ? $oApiTenants->getTenantById($oAccount->IdTenant) : $oApiTenants->getDefaultGlobalTenant(); if ($oTenant) { if ($oTenant->SipAllowConfiguration && $oTenant->SipAllow && $oTenant->isSipSupported() && $oApiCapabilityManager->isSipSupported($oAccount)) { $aResult['AllowVoice'] = $oTenant->SipAllow; if ($aResult['AllowVoice']) { $aResult['AllowVoice'] = $oAccount->User->SipEnable; } $aResult['VoiceProvider'] = 'sip'; $aResult['SipRealm'] = (string) $oTenant->SipRealm; $aResult['SipWebsocketProxyUrl'] = (string) $oTenant->SipWebsocketProxyUrl; $aResult['SipOutboundProxyUrl'] = (string) $oTenant->SipOutboundProxyUrl; $aResult['SipCallerID'] = (string) $oTenant->SipCallerID; $aResult['SipEnable'] = $oAccount->User->SipEnable; $aResult['SipImpi'] = $oAccount->User->SipImpi; $aResult['SipPassword'] = $oAccount->User->SipPassword; } else { if ($oTenant->TwilioAllowConfiguration && $oTenant->TwilioAllow && $oTenant->isTwilioSupported() && $oApiCapabilityManager->isTwilioSupported($oAccount)) { $aResult['AllowVoice'] = $oTenant->TwilioAllow; if ($aResult['AllowVoice']) { $aResult['AllowVoice'] = $oAccount->User->TwilioEnable; } $aResult['VoiceProvider'] = 'twilio'; $aResult['TwilioNumber'] = $oAccount->User->TwilioNumber; $aResult['TwilioEnable'] = $oAccount->User->TwilioEnable; } } } if ($aResult['VoiceProvider'] === 'sip' && (0 === strlen($aResult['SipRealm']) || 0 === strlen($aResult['SipWebsocketProxyUrl']))) { $aResult['AllowVoice'] = false; $aResult['SipRealm'] = ''; $aResult['SipWebsocketProxyUrl'] = ''; $aResult['SipOutboundProxyUrl'] = ''; $aResult['SipCallerID'] = ''; $aResult['SipEnable'] = false; $aResult['SipImpi'] = ''; $aResult['SipPassword'] = ''; } } /* @var $oApiUsersManager CApiUsersManager */ $oApiUsersManager = CApi::Manager('users'); /* @var $oApiDavManager CApiDavManager */ $oApiDavManager = CApi::Manager('dav'); $aResult['AllowCalendar'] = $oApiCapabilityManager->isCalendarSupported($oAccount); $aResult['Calendar'] = null; if ($aResult['AllowCalendar'] && $oApiDavManager && $oAccount->IsDefaultAccount) { /* @var $oCalUser CCalUser */ $oCalUser = $oApiUsersManager->getOrCreateCalUser($oAccount->IdUser); if ($oCalUser) { $aResult['Calendar'] = array(); $aResult['Calendar']['ShowWeekEnds'] = (bool) $oCalUser->ShowWeekEnds; $aResult['Calendar']['ShowWorkDay'] = (bool) $oCalUser->ShowWorkDay; $aResult['Calendar']['WorkDayStarts'] = (int) $oCalUser->WorkDayStarts; $aResult['Calendar']['WorkDayEnds'] = (int) $oCalUser->WorkDayEnds; $aResult['Calendar']['WeekStartsOn'] = (int) $oCalUser->WeekStartsOn; $aResult['Calendar']['DefaultTab'] = (int) $oCalUser->DefaultTab; $aResult['Calendar']['SyncLogin'] = (string) $oApiDavManager->getLogin($oAccount); $aResult['Calendar']['DavServerUrl'] = (string) $oApiDavManager->getServerUrl($oAccount); $aResult['Calendar']['DavPrincipalUrl'] = (string) $oApiDavManager->getPrincipalUrl($oAccount); $aResult['Calendar']['AllowReminders'] = true; } } $aResult['CalendarSharing'] = false; $aResult['CalendarAppointments'] = false; $aResult['AllowCalendar'] = null === $aResult['Calendar'] ? false : $aResult['AllowCalendar']; if ($aResult['AllowCalendar']) { $aResult['CalendarSharing'] = $oApiCapabilityManager->isCalendarSharingSupported($oAccount); $aResult['CalendarAppointments'] = $oApiCapabilityManager->isCalendarAppointmentsSupported($oAccount); } $bIsDemo = false; CApi::Plugin()->RunHook('plugin-is-demo-account', array(&$oAccount, &$bIsDemo)); $aResult['IsDemo'] = $bIsDemo; CApi::Plugin()->RunHook('api-app-user-data', array(&$oAccount, &$aResult)); } return $aResult; }
public static function GetOembedFileInfo($sUrl) { $mResult = false; $sOembedUrl = ''; if (false !== strpos($sUrl, 'youtube.com') || false !== strpos($sUrl, 'youtu.be')) { $sOembedUrl = 'https://youtube.com/oembed?format=json&url=' . $sUrl; } else { if (false !== strpos($sUrl, 'vimeo.com')) { $sOembedUrl = 'https://vimeo.com/api/oembed.json?format=json&url=' . $sUrl; } else { if (false !== strpos($sUrl, 'soundcloud.com')) { $sOembedUrl = 'https://soundcloud.com/oembed?format=json&url=' . $sUrl; } } } if (strlen($sOembedUrl) > 0) { $oCurl = curl_init(); \curl_setopt_array($oCurl, array(CURLOPT_URL => $sOembedUrl, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => '', CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5, CURLOPT_MAXREDIRS => 5)); $sResult = curl_exec($oCurl); curl_close($oCurl); $oResult = json_decode($sResult); if ($oResult) { $sSearch = $oResult->html; $aPatterns = array('/ width="\\d+."/', '/ height="\\d+."/', '/(src="[^\\"]+)/'); $aResults = array(' width="896"', ' height="504"', '$1?&autoplay=1&auto_play=true'); $oResult->html = preg_replace($aPatterns, $aResults, $sSearch); $aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl); $oResult->fileSize = $aRemoteFileInfo['size']; $oResult->thumbnailLink = $oResult->thumbnail_url; $mResult = $oResult; } } return $mResult; }
/** * @param string $sEmail * @param string $sPassword * @param string $sChangeLang = '' * @param array $aExtValues = null * @param bool $bAllowInternalOnly = false * @return CAccount | false */ public function CreateAccountProcess($sEmail, $sPassword, $sChangeLang = '', $aExtValues = null, $bAllowInternalOnly = false) { $mResult = false; try { /* @var $oApiDomainsManager CApiDomainsManager */ $oApiDomainsManager = CApi::Manager('domains'); /* @var $oApiUsersManager CApiUsersManager */ $oApiUsersManager = CApi::Manager('users'); $sDomainName = api_Utils::GetDomainFromEmail($sEmail); $oDomain = $oApiDomainsManager->GetDomainByName($sDomainName); if (!$oDomain) { $oDomain = $oApiDomainsManager->GetDefaultDomain(); } $bApiIntegratorLoginToAccountResult = isset($aExtValues['ApiIntegratorLoginToAccountResult']) ? $aExtValues['ApiIntegratorLoginToAccountResult'] : false; if ($oDomain && ($bApiIntegratorLoginToAccountResult || $oDomain->AllowNewUsersRegister || $oDomain->IsInternal && $bAllowInternalOnly || 'nodb' === CApi::GetManager()->GetStorageByType('webmail'))) { /*if ($oDomain && !$oDomain->AllowWebMail) { throw new CApiManagerException(Errs::WebMailManager_AccountWebmailDisabled); } else */ if ($oDomain && $oDomain->IsInternal && !$bAllowInternalOnly) { throw new CApiManagerException(Errs::WebMailManager_NewUserRegistrationDisabled); } else { if ($oDomain && $bAllowInternalOnly && (!$oDomain->IsInternal || $oDomain->IsDefaultDomain)) { throw new CApiManagerException(Errs::WebMailManager_NewUserRegistrationDisabled); } else { if ($oDomain) { $oAccountToCreate = new CAccount($oDomain); $oAccountToCreate->Email = $sEmail; // $oAccountToCreate->IncomingMailLogin = (isset($aExtValues['Login'])) ? $aExtValues['Login'] : // (($this->oSettings->GetConf('WebMail/UseLoginWithoutDomain')) // ? api_Utils::GetAccountNameFromEmail($sEmail) : $sEmail); $oAccountToCreate->IncomingMailLogin = isset($aExtValues['Login']) ? $aExtValues['Login'] : $sEmail; if ($this->oSettings->GetConf('WebMail/UseLoginWithoutDomain')) { $oAccountToCreate->IncomingMailLogin = api_Utils::GetAccountNameFromEmail($oAccountToCreate->IncomingMailLogin); } $oAccountToCreate->IncomingMailPassword = $sPassword; if (0 < strlen($sChangeLang) && $sChangeLang !== $oAccountToCreate->User->DefaultLanguage) { $oAccountToCreate->User->DefaultLanguage = $sChangeLang; } if ($oDomain->IsDefaultDomain && isset($aExtValues['IncProtocol'], $aExtValues['IncHost'], $aExtValues['IncPort'], $aExtValues['OutHost'], $aExtValues['OutPort'], $aExtValues['OutAuth'])) { $oAccountToCreate->IncomingMailProtocol = (int) $aExtValues['IncProtocol']; $oAccountToCreate->IncomingMailServer = trim($aExtValues['IncHost']); $oAccountToCreate->IncomingMailPort = (int) trim($aExtValues['IncPort']); $oAccountToCreate->OutgoingMailServer = trim($aExtValues['OutHost']); $oAccountToCreate->OutgoingMailPort = (int) trim($aExtValues['OutPort']); $oAccountToCreate->OutgoingMailAuth = (bool) $aExtValues['OutAuth'] ? ESMTPAuthType::AuthCurrentUser : ESMTPAuthType::NoAuth; // TODO $oAccountToCreate->IncomingMailUseSSL = in_array($oAccountToCreate->IncomingMailPort, array(993, 995)); $oAccountToCreate->OutgoingMailUseSSL = in_array($oAccountToCreate->OutgoingMailPort, array(465)); } CApi::Plugin()->RunHook('api-pre-create-account-process-call', array(&$oAccountToCreate)); if (isset($aExtValues['FriendlyName'])) { $oAccountToCreate->FriendlyName = $aExtValues['FriendlyName']; } if (isset($aExtValues['Question1'])) { $oAccountToCreate->User->Question1 = $aExtValues['Question1']; } if (isset($aExtValues['Question2'])) { $oAccountToCreate->User->Question2 = $aExtValues['Question2']; } if (isset($aExtValues['Answer1'])) { $oAccountToCreate->User->Answer1 = $aExtValues['Answer1']; } if (isset($aExtValues['Answer2'])) { $oAccountToCreate->User->Answer2 = $aExtValues['Answer2']; } if ($oApiUsersManager->CreateAccount($oAccountToCreate, !($oAccountToCreate->IsInternal || !$oAccountToCreate->Domain->AllowWebMail || $bApiIntegratorLoginToAccountResult))) { CApi::Plugin()->RunHook('api-success-post-create-account-process-call', array(&$oAccountToCreate)); $mResult = $oAccountToCreate; } else { $oException = $oApiUsersManager->GetLastException(); CApi::Plugin()->RunHook('api-error-post-create-account-process-call', array(&$oAccountToCreate, &$oException)); throw is_object($oException) ? $oException : new CApiManagerException(Errs::WebMailManager_AccountCreateOnLogin); } } else { throw new CApiManagerException(Errs::WebMailManager_DomainDoesNotExist); } } } } else { throw new CApiManagerException(Errs::WebMailManager_NewUserRegistrationDisabled); } } catch (CApiBaseException $oException) { $mResult = false; $this->setLastException($oException); } return $mResult; }
public function Search($pattern, $path = null) { $this->initPath(); $aResult = array(); if ($path === null) { $path = $this->path; } $aItems = \api_Utils::SearchFiles($path, $pattern); if ($aItems) { foreach ($aItems as $sItem) { if (is_dir($sItem)) { $aResult[] = new Directory($sItem); } else { $aResult[] = new File($sItem); } } } return $aResult; }
/** * @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; }