19 declare(strict_types=1);
56 $dic->
language()->loadLanguageModule(
'chatroom');
57 $this->conversationRepo = $conversationRepo ??
new Conversation($this->dic->database(), $this->dic->user());
58 $this->subscriberRepo = $subscriberRepo ??
new Subscriber($this->dic->database(), $this->dic->user());
71 $acceptsMessages =
ilUtil::yn2tf((
string) $this->dic->user()->getPref(
'chat_osc_accept_msg'));
72 if ($acceptsMessages) {
73 return $this->dic->ui()->factory()
75 ->info($this->dic->language()->txt(
'chat_osc_accept_no_conv_info_slate'));
78 return $this->dic->ui()->factory()
80 ->info($this->dic->language()->txt(
'chat_osc_accept_msg_info_slate'))
82 $this->dic->ui()->factory()
85 $this->dic->language()->txt(
'chat_osc_accept_msg_info_slate_link_txt'),
86 $this->dic->ctrl()->getLinkTargetByClass(
88 ilDashboardGUI::class,
89 ilPersonalProfileGUI::class,
90 ilUserPrivacySettingsGUI::class
103 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(
105 $this->dic->language()->txt(
'public_room')
109 $this->mainmenu->complex($this->
if->identifier(
'mm_chat'))
110 ->withAvailableCallable(
function ():
bool {
111 $isUser = 0 !== $this->dic->user()->getId() && !$this->dic->user()->isAnonymous();
112 $chatSettings =
new ilSetting(
'chatroom');
113 $isEnabled = $chatSettings->get(
'chat_enabled') && $chatSettings->get(
'enable_osc');
115 return $isUser && $isEnabled;
117 ->withTitle($this->dic->language()->txt(
'mm_private_chats'))
122 $this->dic->ui()->factory()->item()->shy(
'')->withAdditionalOnLoadCode(
123 static function (
$id):
string {
124 return "il.OnScreenChat.menuCollector = $id.parentNode;$id.remove();";
129 return $this->dic->ui()->factory()->legacy($this->dic->ui()->renderer()->render($components));
142 public function getAsyncItem(
string $conversationIds,
bool $withAggregates): array
144 $conversationIds = array_filter(explode(
',', $conversationIds));
146 if (!$withAggregates || !$this->dic->user()->getId() || $this->dic->user()->isAnonymous()) {
150 $conversations = $this->conversationRepo->findByIds($conversationIds);
153 foreach ($conversations as $conversation) {
154 foreach ($conversation->getSubscriberUsrIds() as
$id) {
155 if (
$id !== $this->dic->user()->getId()) {
156 $allUsrIds[
$id] =
true;
160 $allUsrIds = array_keys($allUsrIds);
161 $user_data = $this->subscriberRepo->getDataByUserIds($allUsrIds);
164 foreach ($conversations as $conversation) {
165 if ($conversation->isGroup()) {
166 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(
Standard::GCON,
'group-conversation');
168 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(
Standard::CON,
'conversation');
172 foreach ($conversation->getSubscriberUsrIds() as
$id) {
173 if (
$id !== $this->dic->user()->getId()) {
174 $users[] = $user_data[
$id][
'public_name'];
178 $cid = $conversation->getId();
180 $items[] = $this->dic->ui()->factory()->item()->shy(implode(
', ', $users))
181 ->withDescription($conversation->getLastMessage()->getMessage())
183 [$this->dic->language()->txt(
'time') .
':' =>
186 (
int) ($conversation->getLastMessage()->getCreatedTimestamp() / 1000),
192 ->withLeadIcon($icon)
193 ->withClose($this->dic->ui()->factory()->button()->close())
195 function (
$id) use ($cid) {
196 return "il.OnScreenChat.menuCollector.querySelector('#$id').dataset.id = '$cid';";
Subscriber $subscriberRepo
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Conversation $conversationRepo
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
withAdditionalOnLoadCode(Closure $binder)
Interface StaticMainMenuProvider.
Customizing of pimple-DIC for ILIAS.
getAsyncItem(string $conversationIds, bool $withAggregates)
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...
withSymbol(Symbol $symbol)
language()
Get interface to the i18n service.
__construct(Container $dic, ilPlugin $plugin)
Class OnScreenChatProvider.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ?Conversation $conversationRepo=null, ?Subscriber $subscriberRepo=null)
static yn2tf(string $a_yn)