1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
CategoryBanProvider.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\OpenEvents\Provider;
4
5use Bitrix\Calendar\OpenEvents\Internals\OpenEventCategoryBannedTable;
6use Bitrix\Main\Engine\CurrentUser;
7
9{
10 protected static array $cache = [];
11
12 protected int $userId;
13
14 public function __construct(?int $userId = null)
15 {
16 $this->userId = $userId ?? (int)CurrentUser::get()->getId();
17 }
18
22 public function listIds(): array
23 {
24 if (empty(self::$cache[$this->userId]))
25 {
27 ->setSelect(['CATEGORY_ID'])
28 ->where('USER_ID', $this->userId)
29 ->fetchCollection()
30 ->getCategoryIdList()
31 ;
32 }
33
34 return self::$cache[$this->userId];
35 }
36
40 public function getUsersWhoBannedTheCategory(array $userIds, int $categoryId): array
41 {
42 if (empty($userIds))
43 {
44 return [];
45 }
46
48 ->setSelect(['USER_ID', 'CATEGORY_ID'])
49 ->whereIn('USER_ID', $userIds)
50 ->where('CATEGORY_ID', $categoryId)
51 ;
52
53 $bannedQueryResult = $bannedQuery->exec();
54
55 $usersWhoBanned = [];
56 while($ban = $bannedQueryResult->fetchObject())
57 {
58 $usersWhoBanned[$ban->getUserId()] = true;
59 }
60
61 $bans = array_map(static fn(int $userId) => !empty($usersWhoBanned[$userId]), $userIds);
62
63 return array_combine($userIds, $bans);
64 }
65}
getUsersWhoBannedTheCategory(array $userIds, int $categoryId)
Определения CategoryBanProvider.php:40
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804