1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
SystemGroupItemFactory.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Notification\Group\SystemGroup;
4
5use Bitrix\Im\V2\Notification\Group\Condition\ConditionFactory;
6use Bitrix\Im\V2\Notification\Group\GroupItem;
7use Bitrix\Im\V2\Notification\Group\GroupItemCollection;
8use Bitrix\Main\Localization\Loc;
9
11{
12 private readonly ConditionFactory $conditionFactory;
13
14 public function __construct()
15 {
16 $this->conditionFactory = new ConditionFactory();
17 }
18
19 private function makeConfirm(int $userId): GroupItem
20 {
21 return $this->make(SystemGroup::Confirm, $userId);
22 }
23
24 private function makeMention(int $userId): GroupItem
25 {
26 return $this->make(SystemGroup::Mention, $userId);
27 }
28
29 private function makeAdmin(int $userId): GroupItem
30 {
31 return $this->make(SystemGroup::Admin, $userId);
32 }
33
34 private function make(SystemGroup $systemGroup, int $userId): GroupItem
35 {
36 $tag = $systemGroup->value;
37
38 return new GroupItem(
39 tag: $tag,
40 title: $this->getTitle($systemGroup),
41 conditions: $this->conditionFactory->makeByTag($tag, $userId),
42 isEditable: false,
43 );
44 }
45
46 private function getTitle(SystemGroup $systemGroup): string
47 {
48 return match ($systemGroup)
49 {
50 SystemGroup::Confirm => Loc::getMessage('IM_V2_NOTIFICATION_GROUP_SYSTEM_GROUP_FACTORY_CONFIRM') ?? '',
51 SystemGroup::Mention => Loc::getMessage('IM_V2_NOTIFICATION_GROUP_SYSTEM_GROUP_FACTORY_MENTION') ?? '',
52 SystemGroup::Admin => Loc::getMessage('IM_V2_NOTIFICATION_GROUP_SYSTEM_GROUP_FACTORY_ADMIN') ?? '',
53 };
54 }
55
56 public function makeAllSystemItemsForUser(bool $isAdmin, int $userId): GroupItemCollection
57 {
58 $groups = [
59 $this->makeConfirm($userId),
60 $this->makeMention($userId),
61 ];
62
63 if ($isAdmin)
64 {
65 $groups[] = $this->makeAdmin($userId);
66 }
67
68 return new GroupItemCollection(...$groups);
69 }
70}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
$groups
Определения options.php:30
<? endif;?> window document title
Определения prolog_main_admin.php:76