Server IP : 85.193.89.191 / Your IP : 3.143.214.145 Web Server : Apache System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : bitrix ( 600) PHP Version : 8.1.27 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bitrix/www/bitrix/modules/mail/lib/helper/ |
Upload File : |
<?php namespace Bitrix\Mail\Helper; use Bitrix\Main; use Bitrix\Mail\MailboxTable; use Bitrix\Mail\MailMessageTable; /** * @see \Bitrix\Mail\MessageAccess */ class MessageAccess { public static function createToken($mailBoxId, $messageId, $entityType, $entityId, $ufId = '0'): string { return md5(sprintf( '%u:%u:%u:%s:%s:%u', // '%u:%u:%u:%s:%s:%u' time(), $mailBoxId, $messageId, $entityType, $ufId, $entityId )); } public static function createSecret(): string { return bin2hex(\Bitrix\Main\Security\Random::getBytes(16)); } public static function isMailboxOwner(int $mailboxId, int $userId): bool { return Message::isMailboxOwner($mailboxId, $userId); } public static function isMessageOwner(\Bitrix\Mail\Item\Message $message, $userId): bool { return \Bitrix\Mail\MessageAccess::createForMessage($message, $userId)->isOwner(); } public static function checkAccessForChat(int $chatId, int $userId): bool { if (Main\Loader::includeModule('im')) { $data = \CIMChat::GetChatData(['ID' => $chatId]); $userInChat = $data['userInChat'][$chatId] ?? []; if (in_array($userId, $userInChat, true)) { return true; } } return false; } public static function checkAccessForCalendarEvent(int $calendarEventId, int $userId): bool { if (Main\Loader::includeModule('calendar')) { $attendeeIds = []; $entry = \CCalendarEvent::getEventForViewInterface($calendarEventId); if ($entry && isset($entry['ATTENDEE_LIST'])) { foreach($entry['ATTENDEE_LIST'] as $attendee) { $attendeeId = (int)$attendee['id']; if ($attendeeId > 0) { $attendeeIds[] = $attendeeId; } } } if (in_array($userId, $attendeeIds, true)) { return true; } } return false; } }