ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\OnScreenChat\Provider\OnScreenChatProvider Class Reference

Class OnScreenChatProvider. More...

+ Inheritance diagram for ILIAS\OnScreenChat\Provider\OnScreenChatProvider:
+ Collaboration diagram for ILIAS\OnScreenChat\Provider\OnScreenChatProvider:

Public Member Functions

 __construct (Container $dic, ?Conversation $conversationRepo=null, ?Subscriber $subscriberRepo=null)
 
 getStaticTopItems ()
 @inheritDoc More...
 
 getStaticSubItems ()
 @inheritDoc More...
 
 getAsyncItem (string $conversationIds, bool $withAggregates)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\MainMenu\Provider\AbstractStaticMainMenuProvider
 __construct (Container $dic)
 @inheritDoc More...
 
 getAllIdentifications ()
 @inheritDoc More...
 
 provideTypeInformation ()
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (protected Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getStaticTopItems ()
 
 getStaticSubItems ()
 
 provideTypeInformation ()
 
 getAllIdentifications ()
 

Private Member Functions

 getSlateMessageBox ()
 

Private Attributes

readonly Conversation $conversationRepo
 
readonly Subscriber $subscriberRepo
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\MainMenu\Provider\AbstractStaticMainMenuProvider
Container $dic
 
IdentificationProviderInterface $if
 
MainMenuItemFactory $mainmenu
 

Detailed Description

Class OnScreenChatProvider.

Author
Ingmar Szmais iszma.nosp@m.is@d.nosp@m.ataba.nosp@m.y.de

Definition at line 45 of file OnScreenChatProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::__construct ( Container  $dic,
?Conversation  $conversationRepo = null,
?Subscriber  $subscriberRepo = null 
)

Definition at line 50 of file OnScreenChatProvider.php.

54 {
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());
59 }
language()
Get interface to the i18n service.
Definition: Container.php:95
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\OnScreenChat\Provider\OnScreenChatProvider\$conversationRepo, ILIAS\GlobalScreen\Scope\MainMenu\Provider\AbstractStaticMainMenuProvider\$dic, ILIAS\OnScreenChat\Provider\OnScreenChatProvider\$subscriberRepo, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\DI\Container\language().

+ Here is the call graph for this function:

Member Function Documentation

◆ getAsyncItem()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getAsyncItem ( string  $conversationIds,
bool  $withAggregates 
)
Returns
Shy[]|MessageBox[]
Exceptions
JsonException
ilDateTimeException

Definition at line 142 of file OnScreenChatProvider.php.

142 : array
143 {
144 $conversationIds = array_filter(explode(',', $conversationIds));
145
146 if (!$withAggregates || !$this->dic->user()->getId() || $this->dic->user()->isAnonymous()) {
147 return [$this->getSlateMessageBox()];
148 }
149
150 $conversations = $this->conversationRepo->findByIds($conversationIds);
151
152 $allUsrIds = [];
153 foreach ($conversations as $conversation) {
154 foreach ($conversation->getSubscriberUsrIds() as $id) {
155 if ($id !== $this->dic->user()->getId()) {
156 $allUsrIds[$id] = true;
157 }
158 }
159 }
160 $allUsrIds = array_keys($allUsrIds);
161 $user_data = $this->subscriberRepo->getDataByUserIds($allUsrIds);
162
163 $items = [];
164 foreach ($conversations as $conversation) {
165 if ($conversation->isGroup()) {
166 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(Standard::GCON, 'group-conversation');
167 } else {
168 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(Standard::CON, 'conversation');
169 }
170
171 $users = [];
172 foreach ($conversation->getSubscriberUsrIds() as $id) {
173 if ($id !== $this->dic->user()->getId()) {
174 $users[] = $user_data[$id]['public_name'];
175 }
176 }
177
178 $cid = $conversation->getId();
179
180 $items[] = $this->dic->ui()->factory()->item()->shy(implode(', ', $users))
181 ->withDescription($conversation->getLastMessage()->getMessage())
182 ->withProperties(
183 [$this->dic->language()->txt('time') . ':' =>
185 new ilDateTime(
186 (int) ($conversation->getLastMessage()->getCreatedTimestamp() / 1000),
188 )
189 )
190 ]
191 )
192 ->withLeadIcon($icon)
193 ->withClose($this->dic->ui()->factory()->button()->close())
194 ->withAdditionalOnLoadCode(
195 function ($id) use ($cid) {
196 return "il.OnScreenChat.menuCollector.querySelector('#$id').dataset.id = '$cid';";
197 }
198 );
199 }
200
201 if ($items === []) {
202 $items[] = $this->getSlateMessageBox();
203 }
204
205 return $items;
206 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling

References $id, ILIAS\UI\Component\Symbol\Icon\Standard\CON, ilDatePresentation\formatDate(), ILIAS\UI\Component\Symbol\Icon\Standard\GCON, ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getSlateMessageBox(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ getSlateMessageBox()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getSlateMessageBox ( )
private

Definition at line 69 of file OnScreenChatProvider.php.

69 : MessageBox
70 {
71 $acceptsMessages = ilUtil::yn2tf((string) $this->dic->user()->getPref('chat_osc_accept_msg'));
72 if ($acceptsMessages) {
73 return $this->dic->ui()->factory()
74 ->messageBox()
75 ->info($this->dic->language()->txt('chat_osc_accept_no_conv_info_slate'));
76 }
77
78 return $this->dic->ui()->factory()
79 ->messageBox()
80 ->info($this->dic->language()->txt('chat_osc_accept_msg_info_slate'))
81 ->withLinks([
82 $this->dic->ui()->factory()
83 ->link()
84 ->standard(
85 $this->dic->language()->txt('chat_osc_accept_msg_info_slate_link_txt'),
86 $this->dic->ctrl()->getLinkTargetByClass(
87 [
88 ilDashboardGUI::class,
89 PersonalProfileGUI::class,
90 PrivacySettingsGUI::class
91 ],
92 'showPrivacySettings'
93 )
94 )
95 ]);
96 }
static yn2tf(string $a_yn)

References ilUtil\yn2tf().

Referenced by ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getAsyncItem(), and ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getStaticSubItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStaticSubItems()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getStaticSubItems ( )

@inheritDoc

Implements ILIAS\GlobalScreen\Scope\MainMenu\Provider\StaticMainMenuProvider.

Definition at line 101 of file OnScreenChatProvider.php.

101 : array
102 {
103 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(
105 $this->dic->language()->txt('public_room')
106 );
107
108 return [
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');
114
115 return $isUser && $isEnabled;
116 })
117 ->withTitle($this->dic->language()->txt('mm_private_chats'))
118 ->withSymbol($icon)
119 ->withContentWrapper(function (): \ILIAS\UI\Component\Component {
120 $components = [
121 $this->getSlateMessageBox(),
122 $this->dic->ui()->factory()->item()->shy('')->withAdditionalOnLoadCode(
123 static function ($id): string {
124 return "il.OnScreenChat.menuCollector = $id.parentNode;$id.remove();";
125 }
126 )
127 ];
128
129 return $this->dic->ui()->factory()->legacy()->content($this->dic->ui()->renderer()->render($components));
130 })
131 ->withParent(StandardTopItemsProvider::getInstance()->getCommunicationIdentification())
132 ->withPosition(40)
133 ,
134 ];
135 }
$components
ILIAS Setting Class.
get(string $a_keyword, ?string $a_default_value=null)
get setting
withParent(IdentificationInterface $identification)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))

References $components, $id, ILIAS\UI\Component\Symbol\Icon\Standard\CHTA, ilSetting\get(), ILIAS\Survey\Mode\getId(), ILIAS\MainMenu\Provider\StandardTopItemsProvider\getInstance(), ILIAS\OnScreenChat\Provider\OnScreenChatProvider\getSlateMessageBox(), if, ILIAS\GlobalScreen\Scope\Footer\Factory\withParent(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withTitle().

+ Here is the call graph for this function:

◆ getStaticTopItems()

ILIAS\OnScreenChat\Provider\OnScreenChatProvider::getStaticTopItems ( )

@inheritDoc

Implements ILIAS\GlobalScreen\Scope\MainMenu\Provider\StaticMainMenuProvider.

Definition at line 64 of file OnScreenChatProvider.php.

64 : array
65 {
66 return [];
67 }

Field Documentation

◆ $conversationRepo

readonly Conversation ILIAS\OnScreenChat\Provider\OnScreenChatProvider::$conversationRepo
private

◆ $subscriberRepo

readonly Subscriber ILIAS\OnScreenChat\Provider\OnScreenChatProvider::$subscriberRepo
private

The documentation for this class was generated from the following file: