1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
MenuItemProvider.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Im\V2\Application\Navigation;
6
7use Bitrix\Im\V2\Application\Features;
8use Bitrix\Im\V2\Common\ContextCustomer;
9use Bitrix\Im\V2\Marketplace\Application;
10use Bitrix\Im\V2\Marketplace\Placement;
11use Bitrix\Im\V2\Permission;
12use Bitrix\Im\V2\Permission\GlobalAction;
13use Bitrix\Main\Localization\Loc;
14
22{
23 use ContextCustomer;
24
26
28
29 public function __construct()
30 {
31 $this->applicationFeatures = Features::get();
32 $this->phoneSettings = \CIMMessenger::getPhoneSettings();
33 }
34
40 public function getMenuItems(): array
41 {
42 return [
43 new MenuItem(
44 id: 'chat',
45 text: Loc::getMessage('IM_NAVIGATION_MENU_CHATS'),
46 ),
47 new MenuItem(
48 id: 'aiAssistant',
49 text:
50 $this->applicationFeatures->aiAssistantChatCreationAvailable
51 ? Loc::getMessage('IM_NAVIGATION_MENU_AI_ASSISTANT')
52 : Loc::getMessage('IM_NAVIGATION_MENU_COPILOT')
53 ,
54 isVisible: (
55 $this->applicationFeatures->copilotAvailable
56 || $this->applicationFeatures->aiAssistantChatCreationAvailable
57 )
58 ),
59 new MenuItem(
60 id: 'collab',
61 text: Loc::getMessage('IM_NAVIGATION_MENU_COLLAB'),
62 isVisible: $this->applicationFeatures->collabAvailable,
63 ),
64 new MenuItem(
65 id: 'channel',
66 text: Loc::getMessage('IM_NAVIGATION_MENU_CHANNELS'),
67 isVisible: $this->isGlobalActionPermitted(GlobalAction::GetChannels),
68 ),
69 new MenuItem(
70 id: 'openlines',
71 text: Loc::getMessage('IM_NAVIGATION_MENU_OPENLINES'),
72 isVisible: (
73 !$this->applicationFeatures->openLinesV2
74 && $this->isGlobalActionPermitted(GlobalAction::GetOpenlines)
75 ),
76 ),
77 new MenuItem(
78 id: 'openlinesV2',
79 text: Loc::getMessage('IM_NAVIGATION_MENU_OPENLINES'),
80 isVisible: (
81 $this->applicationFeatures->openLinesV2
82 && $this->isGlobalActionPermitted(GlobalAction::GetOpenlines)
83 ),
84 ),
85 new MenuItem(
86 id: 'notification',
87 text: Loc::getMessage('IM_NAVIGATION_MENU_NOTIFICATIONS'),
88 isVisible: !$this->applicationFeatures->isNotificationsStandalone,
89 ),
90 new MenuItem(
91 id: 'call',
92 text: Loc::getMessage('IM_NAVIGATION_MENU_CALLS_V2'),
93 isVisible: (
94 $this->phoneSettings['phoneEnabled']
95 && $this->phoneSettings['canPerformCallsByUser']
96 ),
97 ),
98 new MenuItem(
99 id: 'market',
100 text: Loc::getMessage('IM_NAVIGATION_MENU_MARKET_TITLE'),
101 isVisible: $this->isGlobalActionPermitted(GlobalAction::GetMarket),
102 ),
103 ...$this->getMarketAppMenuItems(),
104 new MenuItem(
105 id: 'settings',
106 text: Loc::getMessage('IM_NAVIGATION_MENU_SETTINGS'),
107 ),
108 ];
109 }
110
117 public function getMarketAppMenuItems(): array
118 {
119 $applications = (new Application())->getApplications([Placement::IM_NAVIGATION]);
120 usort($applications, function($a, $b) {
121 return $a->getOrder() - $b->getOrder();
122 });
123
124 $menuItems = [];
125 foreach ($applications as $application)
126 {
127 $menuItems[] = new MenuItem(
128 id: 'market',
129 text: $application->getTitle(),
130 entityId: $application->getId(),
131 );
132 }
133
134 return $menuItems;
135 }
136
137 protected function isGlobalActionPermitted(GlobalAction $action): bool
138 {
139 return Permission::canDoGlobalAction(
140 $this->getContext()->getUserId(),
141 $action,
142 null,
143 );
144 }
145}
static get()
Определения Features.php:54
isGlobalActionPermitted(GlobalAction $action)
Определения MenuItemProvider.php:137
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$application
Определения bitrix.php:23
else $a
Определения template.php:137
$action
Определения file_dialog.php:21