ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChatroomViewGUI Class Reference

Class ilChatroomViewGUI. More...

+ Inheritance diagram for ilChatroomViewGUI:
+ Collaboration diagram for ilChatroomViewGUI:

Public Member Functions

 joinWithCustomName ()
 
 readOnlyChatWindow (ilChatroom $room, array $messages)
 
 toggleAutoMessageDisplayState ()
 
 executeDefault (string $requestedMethod)
 Chatroom and Chatuser get prepared before $this->showRoom method is called. More...
 
 logout ()
 
 lostConnection ()
 
 userEntry ()
 
- Public Member Functions inherited from ilChatroomGUIHandler
 execute (string $method)
 
 executeDefault (string $requestedMethod)
 
 redirectIfNoPermission ($permission)
 Checks for requested permissions and redirects if the permission check failed. More...
 
 isSuccessful ($response)
 Checks for success param in an json decoded response. More...
 
 hasPermission (string $permission)
 

Protected Member Functions

 renderSendMessageBox (ilTemplate $roomTpl)
 
 renderRightUsersBlock (ilTemplate $roomTpl)
 
- Protected Member Functions inherited from ilChatroomGUIHandler
 getRequestValue (string $key, Transformation $trafo, $default=null)
 
 hasRequestValue (string $key)
 
 getRoomByObjectId (int $objectId)
 
 exitIfNoRoomExists (?ilChatroom $room)
 Checks if a ilChatroom exists. More...
 
 sendJSONResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 sendResponse (string $content, string $type)
 Sends a response and exits the php process. More...
 

Private Member Functions

 setupTemplate ()
 Adds CSS and JavaScript files that should be included in the header. More...
 
 showRoom (ilChatroom $room, ilChatroomUser $chat_user)
 Prepares and displays chatroom and connects user to it. More...
 
 sendMessageForm ()
 
 userList ()
 
 chatFunctions (bool $show_auto_messages, bool $is_moderator)
 
 checkbox (Component $component)
 
 legacy (string $html)
 
 panel (string $title, $body)
 
 cancelJoin (string $message)
 Calls ilUtil::sendFailure method using given $message as parameter. More...
 
 showNameSelection (ilChatroomUser $chat_user)
 
 buildUserActions (int $user_id, array $actions)
 
 buildChat (ilChatroom $room, ilChatroomServerSettings $settings)
 

Additional Inherited Members

- Protected Attributes inherited from ilChatroomGUIHandler
ilObjUser $ilUser
 
ilCtrlInterface $ilCtrl
 
ilLanguage $ilLng
 
Filesystem $webDirectory
 
ilObjectService $obj_service
 
FileUpload $upload
 
ilRbacSystem $rbacsystem
 
ilGlobalTemplateInterface $mainTpl
 
ILIAS $ilias
 
ilNavigationHistory $navigationHistory
 
ilTree $tree
 
ilTabsGUI $tabs
 
UIFactory $uiFactory
 
UIRenderer $uiRenderer
 
GlobalHttpState $http
 
Refinery $refinery
 
ILIAS FileDelivery Services $file_delivery
 

Detailed Description

Class ilChatroomViewGUI.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 33 of file class.ilChatroomViewGUI.php.

Member Function Documentation

◆ buildChat()

ilChatroomViewGUI::buildChat ( ilChatroom  $room,
ilChatroomServerSettings  $settings 
)
private

Definition at line 504 of file class.ilChatroomViewGUI.php.

504 : BuildChat
505 {
506 return new BuildChat($this->ilCtrl, $this->ilLng, $this->gui, $room, $settings, $this->ilUser, $this->uiFactory, $this->uiRenderer);
507 }
Class ilCtrl provides processing control methods.

◆ buildUserActions()

ilChatroomViewGUI::buildUserActions ( int  $user_id,
array  $actions 
)
private
Parameters
array<string|int,string>$actions
Returns
array<Button>

Definition at line 475 of file class.ilChatroomViewGUI.php.

475 : array
476 {
477 $chat_settings = new ilSetting('chatroom');
478 $osc_enabled = $chat_settings->get('chat_enabled') && $chat_settings->get('enable_osc');
479 $translations = [
480 'kick' => $this->ilLng->txt('chat_kick'),
481 'ban' => $this->ilLng->txt('chat_ban'),
482 ];
483
484 if ($osc_enabled && ilObjUser::_lookupPref($user_id, 'chat_osc_accept_msg') === 'y') {
485 $translations['chat'] = $this->ilLng->txt('start_private_chat');
486 }
487
488 $buttons = [];
489 foreach ($actions as $key => $bus_id) {
490 $label = $translations[$key] ?? false;
491 if ($label) {
492 $buttons[] = $this->uiFactory->button()->shy($label, '')->withAdditionalOnLoadCode(fn(string $id): string => (
493 'il.Chatroom.bus.send(' . json_encode(
494 $bus_id,
495 JSON_THROW_ON_ERROR
496 ) . ', document.getElementById(' . json_encode($id, JSON_THROW_ON_ERROR) . '));'
497 ));
498 }
499 }
500
501 return $buttons;
502 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupPref(int $a_usr_id, string $a_keyword)
ILIAS Setting Class.

References $id, $user_id, and ilObjUser\_lookupPref().

+ Here is the call graph for this function:

◆ cancelJoin()

ilChatroomViewGUI::cancelJoin ( string  $message)
private

Calls ilUtil::sendFailure method using given $message as parameter.

Definition at line 298 of file class.ilChatroomViewGUI.php.

298 : void
299 {
300 $this->mainTpl->setOnScreenMessage('failure', $message);
301 }
$message
Definition: xapiexit.php:31

References $message.

◆ chatFunctions()

ilChatroomViewGUI::chatFunctions ( bool  $show_auto_messages,
bool  $is_moderator 
)
private

Definition at line 190 of file class.ilChatroomViewGUI.php.

190 : string
191 {
192 $txt = $this->ilLng->txt(...);
193 $js_escape = json_encode(...);
194 $format = fn($format, ...$args) => sprintf($format, ...array_map($js_escape, $args));
195 $register = fn($name, $c) => $c->withOnLoadCode(fn($id) => $format(
196 'il.Chatroom.bus.send(%s, document.getElementById(%s));',
197 $name,
198 $id
199 ));
200
201 $b = $this->uiFactory->button();
202 $toggle = fn($label, $enabled) => $b->toggle($label, '#', '#', $enabled)->withAriaLabel($label);
203
204 $bind = fn($key, $m) => $m->withAdditionalOnLoadCode(fn(string $id) => $format(
205 '$(() => il.Chatroom.bus.send(%s, {
206 node: document.getElementById(%s),
207 showModal: () => $(document).trigger(%s, {}),
208 closeModal: () => $(document).trigger(%s, {})
209 }));',
210 $key,
211 $id,
212 $m->getShowSignal()->getId(),
213 $m->getCloseSignal()->getId()
214 ));
215
216 $interrupt = fn($key, $label, $text, $button = null) => $bind($key, $this->uiFactory->modal()->interruptive(
217 $label,
218 $text,
219 ''
220 ))->withActionButtonLabel($button ?? $label);
221
222 $auto_scroll = $register('auto-scroll-toggle', $toggle($txt('auto_scroll'), true));
223 $messages = $register('system-messages-toggle', $toggle($txt('chat_show_auto_messages'), $show_auto_messages));
224
225 $invite = $bind('invite-modal', $this->uiFactory->modal()->roundtrip($txt('chat_invite'), $this->legacy($txt('invite_to_private_room')), [
226 $this->uiFactory->input()->field()->text($txt('chat_invite')),
227 ])->withSubmitLabel($txt('chat_invite')));
228
229 $buttons = [];
230 $buttons[] = $register('invite-button', $b->shy($txt('invite_to_private_room'), ''));
231 if ($is_moderator) {
232 $buttons[] = $register('clear-history-button', $b->shy($txt('clear_room_history'), ''));
233 }
234
235 return $this->panel($txt('chat_functions'), [
236 $this->legacy('<div id="chat_function_list">'),
237 ...$buttons,
238 $invite,
239 $interrupt('kick-modal', $txt('chat_kick'), $txt('kick_question')),
240 $interrupt('ban-modal', $txt('chat_ban'), $txt('ban_question')),
241 $interrupt('clear-history-modal', $txt('clear_room_history'), $txt('clear_room_history_question')),
242 $this->legacy('</div>'),
243 $this->legacy(sprintf('<div>%s%s</div>', $this->checkbox($auto_scroll), $this->checkbox($messages))),
244 ]);
245 }
panel(string $title, $body)
checkbox(Component $component)
$c
Definition: deliver.php:25
$txt
Definition: error.php:31
$messages
Definition: xapiexit.php:21

References Vendor\Package\$b, $c, $id, $messages, $txt, and ILIAS\UI\examples\MainControls\Slate\Legacy\legacy().

+ Here is the call graph for this function:

◆ checkbox()

ilChatroomViewGUI::checkbox ( Component  $component)
private

Definition at line 247 of file class.ilChatroomViewGUI.php.

247 : string
248 {
249 return sprintf('<div class="chatroom-centered-checkboxes">%s</div>', $this->uiRenderer->render($component));
250 }

◆ executeDefault()

ilChatroomViewGUI::executeDefault ( string  $requestedMethod)

Chatroom and Chatuser get prepared before $this->showRoom method is called.

If custom usernames are allowed, $this->showNameSelection method is called if user isn't already registered in the Chatroom. @inheritDoc

Reimplemented from ilChatroomGUIHandler.

Definition at line 336 of file class.ilChatroomViewGUI.php.

336 : void
337 {
338 $this->redirectIfNoPermission('read');
339
340 $this->gui->switchToVisibleMode();
341 $this->setupTemplate();
342
343 $chatSettings = new ilSetting('chatroom');
344 if (!$chatSettings->get('chat_enabled', '0')) {
345 $this->ilCtrl->redirect($this->gui, 'settings-general');
346 }
347
348 $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
349
350 if (!$room->getSetting('allow_anonymous') && $this->ilUser->isAnonymous()) {
351 $this->cancelJoin($this->ilLng->txt('chat_anonymous_not_allowed'));
352 return;
353 }
354
355 $chat_user = new ilChatroomUser($this->ilUser, $room);
356
357 if ($room->getSetting('allow_custom_usernames')) {
358 if ($room->isSubscribed($chat_user->getUserId())) {
359 $chat_user->setUsername($chat_user->getUsername());
360 $this->showRoom($room, $chat_user);
361 } else {
362 $this->showNameSelection($chat_user);
363 }
364 } else {
365 $chat_user->setUsername($this->ilUser->getPublicName());
366 $chat_user->setProfilePictureVisible(true);
367 $this->showRoom($room, $chat_user);
368 }
369 }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
Class ilChatroomUser.
cancelJoin(string $message)
Calls ilUtil::sendFailure method using given $message as parameter.
setupTemplate()
Adds CSS and JavaScript files that should be included in the header.
showNameSelection(ilChatroomUser $chat_user)
showRoom(ilChatroom $room, ilChatroomUser $chat_user)
Prepares and displays chatroom and connects user to it.
static byObjectId(int $object_id)
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc

References ilChatroom\byObjectId(), and ilCtrl\redirect().

+ Here is the call graph for this function:

◆ joinWithCustomName()

ilChatroomViewGUI::joinWithCustomName ( )

Definition at line 35 of file class.ilChatroomViewGUI.php.

35 : void
36 {
37 $this->redirectIfNoPermission('read');
38
39 $this->gui->switchToVisibleMode();
40 $this->setupTemplate();
41 $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
42 $chat_user = new ilChatroomUser($this->ilUser, $room);
43 $failure = true;
44 $username = '';
45 $custom_username = false;
46
47 if ($this->hasRequestValue('custom_username_radio')) {
48 if (
49 $this->hasRequestValue('custom_username_text') &&
50 $this->getRequestValue('custom_username_radio', $this->refinery->kindlyTo()->string()) === 'custom_username'
51 ) {
52 $custom_username = true;
53 $username = $this->getRequestValue('custom_username_text', $this->refinery->kindlyTo()->string());
54 $failure = false;
55 } elseif (
56 method_exists(
57 $chat_user,
58 'build' . $this->getRequestValue('custom_username_radio', $this->refinery->kindlyTo()->string())
59 )
60 ) {
61 $username = $chat_user->{
62 'build' . $this->getRequestValue('custom_username_radio', $this->refinery->kindlyTo()->string())
63 }();
64 $failure = false;
65 }
66 }
67
68 if (!$failure && trim($username) !== '') {
69 if (!$room->isSubscribed($chat_user->getUserId())) {
70 $chat_user->setUsername($chat_user->buildUniqueUsername($username));
71 $chat_user->setProfilePictureVisible(!$custom_username);
72 }
73
74 $this->showRoom($room, $chat_user);
75 } else {
76 $this->mainTpl->setOnScreenMessage('failure', $this->ilLng->txt('no_username_given'));
77 $this->showNameSelection($chat_user);
78 }
79 }
getRequestValue(string $key, Transformation $trafo, $default=null)

References ilChatroom\byObjectId(), ilChatroomGUIHandler\getRequestValue(), ilChatroomGUIHandler\hasRequestValue(), ilChatroomGUIHandler\redirectIfNoPermission(), ILIAS\Repository\refinery(), and setupTemplate().

+ Here is the call graph for this function:

◆ legacy()

ilChatroomViewGUI::legacy ( string  $html)
private

Definition at line 252 of file class.ilChatroomViewGUI.php.

252 : Component
253 {
254 return $this->uiFactory->legacy()->content($html);
255 }

◆ logout()

ilChatroomViewGUI::logout ( )

Definition at line 371 of file class.ilChatroomViewGUI.php.

371 : void
372 {
373 $pid = $this->tree->getParentId($this->gui->getRefId());
374 $this->ilCtrl->setParameterByClass(ilRepositoryGUI::class, 'ref_id', $pid);
375 $this->ilCtrl->redirectByClass(ilRepositoryGUI::class);
376 }
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc

References ilCtrl\redirectByClass(), and ilCtrl\setParameterByClass().

+ Here is the call graph for this function:

◆ lostConnection()

ilChatroomViewGUI::lostConnection ( )

Definition at line 378 of file class.ilChatroomViewGUI.php.

378 : void
379 {
380 if ($this->http->wrapper()->query()->has('msg')) {
381 match ($this->http->wrapper()->query()->retrieve('msg', $this->refinery->kindlyTo()->string())) {
382 'kicked' => $this->mainTpl->setOnScreenMessage('failure', $this->ilLng->txt('kicked'), true),
383 'banned' => $this->mainTpl->setOnScreenMessage('failure', $this->ilLng->txt('banned'), true),
384 default => $this->mainTpl->setOnScreenMessage('failure', $this->ilLng->txt('lost_connection'), true),
385 };
386 } else {
387 $this->mainTpl->setOnScreenMessage('failure', $this->ilLng->txt('lost_connection'), true);
388 }
389
390 $this->ilCtrl->redirectByClass(ilInfoScreenGUI::class, 'showSummary');
391 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http(), and ilCtrl\redirectByClass().

+ Here is the call graph for this function:

◆ panel()

ilChatroomViewGUI::panel ( string  $title,
  $body 
)
private
Parameters
Component|array<Component>$body

Definition at line 260 of file class.ilChatroomViewGUI.php.

260 : string
261 {
262 if (is_array($body)) {
263 $body = $this->uiFactory->legacy()->content(join('', array_map($this->uiRenderer->render(...), $body)));
264 }
265 $panel = $this->uiFactory->panel()->secondary()->legacy($title, $body);
266
267 return $this->uiRenderer->render($panel);
268 }

◆ readOnlyChatWindow()

ilChatroomViewGUI::readOnlyChatWindow ( ilChatroom  $room,
array  $messages 
)

Definition at line 162 of file class.ilChatroomViewGUI.php.

162 : ilTemplate
163 {
164 $build = $this->buildChat($room, $this->gui->getConnector()->getSettings());
165
166 return $build->template(true, $build->initialData([], true, null, [
167 'moderator' => false,
168 'id' => -1,
169 'login' => null,
170 'broadcast_typing' => false,
171 ], $messages), $this->panel($this->ilLng->txt('messages'), $this->legacy('<div id="chat_messages"></div>')), '');
172 }
buildChat(ilChatroom $room, ilChatroomServerSettings $settings)
special template class to simplify handling of ITX/PEAR

References $messages, and ilChatroom\getSettings().

+ Here is the call graph for this function:

◆ renderRightUsersBlock()

ilChatroomViewGUI::renderRightUsersBlock ( ilTemplate  $roomTpl)
protected

Definition at line 309 of file class.ilChatroomViewGUI.php.

309 : void
310 {
311 $roomTpl->setVariable('LBL_NO_FURTHER_USERS', $this->ilLng->txt('no_further_users'));
312 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544

References HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderSendMessageBox()

ilChatroomViewGUI::renderSendMessageBox ( ilTemplate  $roomTpl)
protected

Definition at line 303 of file class.ilChatroomViewGUI.php.

303 : void
304 {
305 $roomTpl->setVariable('PLACEHOLDER', $this->ilLng->txt('chat_osc_write_a_msg'));
306 $roomTpl->setVariable('LBL_SEND', $this->ilLng->txt('send'));
307 }

References HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ sendMessageForm()

ilChatroomViewGUI::sendMessageForm ( )
private

Definition at line 174 of file class.ilChatroomViewGUI.php.

174 : Component
175 {
176 $template = new ilTemplate('tpl.chatroom_send_message_form.html', true, true, 'components/ILIAS/Chatroom');
177 $this->renderSendMessageBox($template);
178
179 return $this->legacy($template->get());
180 }
renderSendMessageBox(ilTemplate $roomTpl)

References ILIAS\UI\examples\MainControls\Slate\Legacy\legacy().

+ Here is the call graph for this function:

◆ setupTemplate()

ilChatroomViewGUI::setupTemplate ( )
private

Adds CSS and JavaScript files that should be included in the header.

Definition at line 84 of file class.ilChatroomViewGUI.php.

84 : void
85 {
86 ilLinkifyUtil::initLinkify($this->mainTpl);
87 $this->mainTpl->addJavaScript('assets/js/socket.io.min.js');
88 $this->mainTpl->addJavaScript('assets/js/Chatroom.min.js');
89 $this->mainTpl->addJavaScript('assets/js/AdvancedSelectionList.js');
90
91 $this->mainTpl->setPermanentLink($this->gui->getObject()->getType(), $this->gui->getObject()->getRefId());
92 }
static initLinkify(?ilGlobalTemplateInterface $a_tpl=null)

References ilLinkifyUtil\initLinkify().

Referenced by joinWithCustomName().

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

◆ showNameSelection()

ilChatroomViewGUI::showNameSelection ( ilChatroomUser  $chat_user)
private

Definition at line 314 of file class.ilChatroomViewGUI.php.

314 : void
315 {
316 $name_options = $chat_user->getChatNameSuggestions();
317 $formFactory = new ilChatroomFormFactory();
318 $selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
319
320 $this->ilCtrl->saveParameter($this->gui, 'sub');
321
322 $selectionForm->addCommandButton('view-joinWithCustomName', $this->ilLng->txt('enter'));
323 $selectionForm->setFormAction(
324 $this->ilCtrl->getFormAction($this->gui, 'view-joinWithCustomName')
325 );
326
327 $this->mainTpl->setVariable('ADM_CONTENT', $selectionForm->getHTML());
328 }
getChatNameSuggestions()
Returns an array of chat-name suggestions.
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
saveParameter(object $a_gui_obj, $a_parameter)
@inheritDoc

References ilChatroomUser\getChatNameSuggestions(), ilCtrl\getFormAction(), and ilCtrl\saveParameter().

+ Here is the call graph for this function:

◆ showRoom()

ilChatroomViewGUI::showRoom ( ilChatroom  $room,
ilChatroomUser  $chat_user 
)
private

Prepares and displays chatroom and connects user to it.

Definition at line 97 of file class.ilChatroomViewGUI.php.

97 : void
98 {
99 $this->redirectIfNoPermission('read');
100
101 $user_id = $chat_user->getUserId();
102
103 $ref_id = $this->getRequestValue('ref_id', $this->refinery->kindlyTo()->int());
104 $this->navigationHistory->addItem(
105 $ref_id,
106 $this->ilCtrl->getLinkTargetByClass(ilRepositoryGUI::class, 'view'),
107 'chtr'
108 );
109
110 if ($room->isUserBanned($user_id)) {
111 $this->cancelJoin($this->ilLng->txt('banned'));
112 return;
113 }
114
115 $scope = $room->getRoomId();
116 $connector = $this->gui->getConnector();
117 $response = $connector->connect($scope, $user_id);
118
119 if (!$response) {
120 $this->mainTpl->setOnScreenMessage('failure', $this->ilLng->txt('unable_to_connect'), true);
121 $this->ilCtrl->redirectByClass(ilInfoScreenGUI::class, 'showSummary');
122 }
123
124 if (!$room->isSubscribed($chat_user->getUserId())) {
125 $room->connectUser($chat_user);
126 }
127
128 $response = $connector->sendEnterPrivateRoom($scope, $user_id);
129 if (!$response) {
130 $this->mainTpl->setOnScreenMessage('failure', $this->ilLng->txt('unable_to_connect'), true);
131 $this->ilCtrl->redirectByClass(ilInfoScreenGUI::class, 'showSummary');
132 }
133
134 $messages = $room->getSetting('display_past_msgs') ? array_reverse(array_filter(
135 $room->getLastMessages($room->getSetting('display_past_msgs'), $chat_user),
136 fn($entry) => $entry->type !== 'notice'
137 )) : [];
138
139 $is_moderator = ilChatroom::checkUserPermissions('moderate', $ref_id, false);
140 $show_auto_messages = !$this->ilUser->getPref('chat_hide_automsg_' . $room->getRoomId());
141
142 $build = $this->buildChat($room, $connector->getSettings());
143
144 $room_tpl = $build->template(false, $build->initialData(
145 $room->getConnectedUsers(),
146 $show_auto_messages,
147 $this->ilCtrl->getLinkTarget($this->gui, 'view-lostConnection', '', false),
148 [
149 'moderator' => $is_moderator,
150 'id' => $chat_user->getUserId(),
151 'login' => $chat_user->getUsername(),
152 'broadcast_typing' => $chat_user->enabledBroadcastTyping(),
153 'profile_picture_visible' => $chat_user->isProfilePictureVisible(),
154 ],
156 ), $this->panel($this->ilLng->txt('write_message'), $this->sendMessageForm()), $this->panel($this->ilLng->txt('messages'), $this->legacy('<div id="chat_messages"></div>')));
157
158 $this->mainTpl->setContent($room_tpl->get());
159 $this->mainTpl->setRightContent($this->userList() . $this->chatFunctions($show_auto_messages, $is_moderator));
160 }
getUserId()
Returns Ilias User ID.
getUsername()
Returns username from Object or SESSION.
chatFunctions(bool $show_auto_messages, bool $is_moderator)
getConnectedUsers(bool $only_data=true)
connectUser(ilChatroomUser $user)
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
getSetting(string $name)
isUserBanned(int $user_id)
isSubscribed(int $chat_userid)
getLastMessages(int $number, ilChatroomUser $chatuser)
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
$ref_id
Definition: ltiauth.php:66
$scope
Definition: ltiregstart.php:51
$response
Definition: xapitoken.php:93

References $messages, $ref_id, $response, $scope, $user_id, ilChatroom\checkUserPermissions(), ilChatroom\connectUser(), ilChatroomUser\enabledBroadcastTyping(), ilChatroom\getConnectedUsers(), ilChatroom\getLastMessages(), ilCtrl\getLinkTargetByClass(), ilChatroom\getRoomId(), ilChatroom\getSetting(), ilChatroom\getSettings(), ilChatroomUser\getUserId(), ilChatroomUser\getUsername(), ilChatroomUser\isProfilePictureVisible(), ilChatroom\isSubscribed(), ilChatroom\isUserBanned(), ILIAS\Repository\navigationHistory(), ilCtrl\redirectByClass(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ toggleAutoMessageDisplayState()

ilChatroomViewGUI::toggleAutoMessageDisplayState ( )

Definition at line 270 of file class.ilChatroomViewGUI.php.

270 : void
271 {
272 $this->redirectIfNoPermission('read');
273
274 $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
275
276 $state = 0;
277 if ($this->http->wrapper()->post()->has('state')) {
278 $state = $this->http->wrapper()->post()->retrieve('state', $this->refinery->kindlyTo()->int());
279 }
280
281 $this->ilUser->writePref(
282 'chat_hide_automsg_' . $room->getRoomId(),
283 (string) ((int) (!(bool) $state))
284 );
285
286 $this->http->saveResponse(
287 $this->http->response()
288 ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
289 ->withBody(Streams::ofString(json_encode(['success' => true], JSON_THROW_ON_ERROR)))
290 );
291 $this->http->sendResponse();
292 $this->http->close();
293 }

References ilChatroom\byObjectId(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ userEntry()

ilChatroomViewGUI::userEntry ( )

Definition at line 436 of file class.ilChatroomViewGUI.php.

436 : void
437 {
438 global $DIC;
439
440 $kindly = $this->refinery->kindlyTo();
441 $s = $kindly->string();
442 $int = $kindly->int();
443 $get = $this->http->wrapper()->query()->retrieve(...);
444 $get_or = fn($k, $t, $d = null) => $get($k, $this->refinery->byTrying([$t, $this->refinery->always($d)]));
445
446 $ref_id = $get('ref_id', $int);
447 $user_id = $get('user_id', $int);
448 $username = $get('username', $s);
449 $actions = $get_or('actions', $kindly->dictOf($s), []);
450
451 $avatar = $DIC["user.avatar.factory"]->avatar('xsmall');
452 $avatar->setUsrId(ANONYMOUS_USER_ID);
453 $avatar->setName(ilStr::subStr($username, 0, 2));
454 $public_image = $avatar->getUrl();
455 $item = $this->uiFactory->item()->standard($username)->withLeadImage($this->uiFactory->image()->standard(
456 $public_image,
457 'Profile image of ' . $username
458 ));
459
461 $item = $item->withProperties([
462 $this->ilLng->txt('role') => $this->ilLng->txt('il_chat_moderator'),
463 ]);
464 }
465 $item = $item->withActions($this->uiFactory->dropdown()->standard($this->buildUserActions($user_id, $actions)));
466
467
468 $this->sendResponse($this->uiRenderer->renderAsync($item), 'text/html');
469 }
sendResponse(string $content, string $type)
Sends a response and exits the php process.
static checkPermissionsOfUser(int $usr_id, $permissions, int $ref_id)
Checks user permissions in question for a given user id in relation to a given ref_id.
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:21
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: shib_login.php:26

References Vendor\Package\$d, $DIC, $ref_id, $user_id, ANONYMOUS_USER_ID, ilChatroom\checkPermissionsOfUser(), ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and ilStr\subStr().

+ Here is the call graph for this function:

◆ userList()

ilChatroomViewGUI::userList ( )
private

Definition at line 182 of file class.ilChatroomViewGUI.php.

182 : string
183 {
184 $roomRightTpl = new ilTemplate('tpl.chatroom_right.html', true, true, 'components/ILIAS/Chatroom');
185 $this->renderRightUsersBlock($roomRightTpl);
186
187 return $this->panel($this->ilLng->txt('users'), $this->legacy($roomRightTpl->get()));
188 }
renderRightUsersBlock(ilTemplate $roomTpl)

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