ILIAS  release_8 Revision v8.24
ChatMainBarProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28use ilSetting;
30
37{
38 public function getStaticTopItems(): array
39 {
40 return [];
41 }
42
43 public function getStaticSubItems(): array
44 {
46
47 $publicChatRefId = ilObjChatroom::_getPublicRefId();
48 $publicChatObjId = (int) $dic['ilObjDataCache']->lookupObjId($publicChatRefId);
49
50 $icon = $this->dic->ui()->factory()
51 ->symbol()
52 ->icon()
53 ->standard(Standard::CHTA, $this->dic->language()->txt('public_room'));
54
55 $this->dic->ctrl()->setParameterByClass(ilObjChatroomGUI::class, 'ref_id', $publicChatRefId);
56 $chatUrl = $this->dic->ctrl()->getLinkTargetByClass(
57 [
58 ilRepositoryGUI::class,
59 ilObjChatroomGUI::class
60 ],
61 'view'
62 );
63
64 return [
65 $this->mainmenu->link($this->if->identifier('mm_public_chat'))
66 ->withTitle($this->dic->language()->txt('public_room'))
67 ->withAction($chatUrl)
68 ->withParent(StandardTopItemsProvider::getInstance()->getCommunicationIdentification())
69 ->withPosition(30)
70 ->withSymbol($icon)
71 ->withNonAvailableReason(
72 $this->dic->ui()->factory()->legacy($this->dic->language()->txt('component_not_active'))
73 )
74 ->withAvailableCallable(
75 static function () use ($publicChatObjId): bool {
76 return $publicChatObjId > 0;
77 }
78 )
79 ->withVisibilityCallable(
80 static function () use ($dic, $publicChatRefId): bool {
81 if (0 === $dic->user()->getId() || $dic->user()->isAnonymous()) {
82 return false;
83 }
84
85 $hasPublicChatRoomAccess = $dic
86 ->rbac()
87 ->system()
88 ->checkAccessOfUser($dic->user()->getId(), 'read', $publicChatRefId);
89
90 return (
91 (new ilSetting('chatroom'))->get('chat_enabled', '0') &&
92 $hasPublicChatRoomAccess
93 );
94 }
95 ),
96 ];
97 }
98}
user()
Get the current user.
Definition: Container.php:62
ui()
Get the interface to get services from UI framework.
Definition: Container.php:118
rbac()
Get interface to get interfaces to all things rbac.
Definition: Container.php:46
Class ilObjChatroomGUI GUI class for chatroom objects.
Class ilObjChatroom.
Class ilRepositoryGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
This describes the specific behavior of an ILIAS standard icon.
Definition: Standard.php:27