1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
messageaccess.php
См. документацию.
1<?php
2
3namespace Bitrix\Mail\Helper;
4
5use Bitrix\Main;
6use Bitrix\Mail\MailboxTable;
7use Bitrix\Mail\MailMessageTable;
8
13{
14 public static function createToken($mailBoxId, $messageId, $entityType, $entityId, $ufId = '0'): string
15 {
16 return md5(sprintf(
17 '%u:%u:%u:%s:%s:%u', // '%u:%u:%u:%s:%s:%u'
18 time(),
19 $mailBoxId,
21 $entityType,
22 $ufId,
24 ));
25 }
26
27 public static function createSecret(): string
28 {
29 return bin2hex(\Bitrix\Main\Security\Random::getBytes(16));
30 }
31
32 public static function isMailboxOwner(int $mailboxId, int $userId): bool
33 {
34 return Message::isMailboxOwner($mailboxId, $userId);
35 }
36
37 public static function isMessageOwner(\Bitrix\Mail\Item\Message $message, $userId): bool
38 {
39 return \Bitrix\Mail\MessageAccess::createForMessage($message, $userId)->isOwner();
40 }
41
42 public static function checkAccessForChat(int $chatId, int $userId): bool
43 {
44 if (Main\Loader::includeModule('im'))
45 {
46 $data = \CIMChat::GetChatData(['ID' => $chatId]);
47 $userInChat = $data['userInChat'][$chatId] ?? [];
48 if (in_array($userId, $userInChat, true))
49 {
50 return true;
51 }
52 }
53
54 return false;
55 }
56
57 public static function checkAccessForCalendarEvent(int $calendarEventId, int $userId): bool
58 {
59 if (Main\Loader::includeModule('calendar'))
60 {
61 $attendeeIds = [];
62 $entry = \CCalendarEvent::getEventForViewInterface($calendarEventId);
63
64 if ($entry && isset($entry['ATTENDEE_LIST']))
65 {
66 foreach($entry['ATTENDEE_LIST'] as $attendee)
67 {
68 $attendeeId = (int)$attendee['id'];
69 if ($attendeeId > 0)
70 {
71 $attendeeIds[] = $attendeeId;
72 }
73 }
74 }
75
76 if (in_array($userId, $attendeeIds, true))
77 {
78 return true;
79 }
80 }
81
82 return false;
83 }
84}
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static isMessageOwner(\Bitrix\Mail\Item\Message $message, $userId)
Определения messageaccess.php:37
static isMailboxOwner(int $mailboxId, int $userId)
Определения messageaccess.php:32
static createSecret()
Определения messageaccess.php:27
static checkAccessForChat(int $chatId, int $userId)
Определения messageaccess.php:42
static createToken($mailBoxId, $messageId, $entityType, $entityId, $ufId='0')
Определения messageaccess.php:14
static checkAccessForCalendarEvent(int $calendarEventId, int $userId)
Определения messageaccess.php:57
$data['IS_AVAILABLE']
Определения .description.php:13
Определения base.php:3
Определения address.php:8
$entityId
Определения payment.php:4
$message
Определения payment.php:8