%PDF- %PDF-
Direktori : /proc/self/root/home/bitrix/www/bitrix/modules/mail/tools/ |
Current File : //proc/self/root/home/bitrix/www/bitrix/modules/mail/tools/check_mail.php |
<?php define('NO_KEEP_STATISTIC', 'Y'); define('NO_AGENT_STATISTIC', 'Y'); define('NO_AGENT_CHECK', true); define('DisableEventsCheck', true); define('NOT_CHECK_PERMISSIONS', true); define('BX_SECURITY_SESSION_READONLY', true); require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'); $timeStart = time(); if (!is_object($USER) || !$USER->IsAuthorized()) { return; } $userId = $USER->GetID(); session_write_close(); $siteId = SITE_ID; if (isset($_REQUEST['SITE_ID'])) { $site = \CSite::getById($_REQUEST['SITE_ID'])->fetch(); if (empty($site)) { return; } $siteId = $site['LID']; } \Bitrix\Main\Loader::includeModule('mail'); $error = false; $mailboxesSyncManager = new \Bitrix\Mail\Helper\Mailbox\MailboxSyncManager($userId); $mailboxesReadyToSync = $mailboxesSyncManager->getNeedToBeSyncedMailboxes(); $isSuccessSync = false; $failedToSyncMailboxId = 0; if (!empty($mailboxesReadyToSync)) { $hasSuccessSync = false; foreach ($mailboxesReadyToSync as $mailboxId => $lastMailCheckData) { $mailboxHelper = \Bitrix\Mail\Helper\Mailbox::createInstance($mailboxId, false); if (!empty($mailboxHelper)) { $result = $mailboxHelper->sync(); if ($result === false) { $failedToSyncMailboxId = $mailboxId; } else { $hasSuccessSync = true; } if (time() - $timeStart > Bitrix\Mail\Helper\Mailbox::SYNC_TIME_QUOTA) { break; } } } } $unseen = \Bitrix\Mail\Helper\Message::getTotalUnseenCount($userId); if ($unseen >= 0) { CUserCounter::Set($userId, 'mail_unseen', $unseen, $siteId); } else { $unseen = 0; } header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); echo json_encode([ 'result' => $error === false ? 'ok' : 'error', 'unseen' => $unseen, 'hasSuccessSync' => $hasSuccessSync, 'failedToSyncMailboxId' => $failedToSyncMailboxId, ]); require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php';