ILIAS  release_8 Revision v8.24
class.ilChatroomInviteUsersToPrivateRoomGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 public function executeDefault(string $requestedMethod): void
30 {
31 $this->byLogin();
32 }
33
34 public function byLogin(): void
35 {
36 $user = $this->getRequestValue('user', $this->refinery->kindlyTo()->string());
37 $this->inviteById((int) ilObjUser::_lookupId($user));
38 }
39
40 private function inviteById(int $invited_id): void
41 {
42 $this->redirectIfNoPermission('read');
43
44 $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
45 $this->exitIfNoRoomExists($room);
46
47 $chat_user = new ilChatroomUser($this->ilUser, $room);
48 $subRoomId = $this->getRequestValue('sub', $this->refinery->kindlyTo()->int());
49 $this->exitIfNoRoomModeratePermission($room, $subRoomId, $chat_user);
50
51 if (!$this->isMainRoom($subRoomId)) {
52 $room->inviteUserToPrivateRoom($invited_id, $subRoomId);
53 }
54
55 $connector = $this->gui->getConnector();
56 $response = $connector->sendInviteToPrivateRoom(
57 $room->getRoomId(),
58 $subRoomId,
59 $chat_user->getUserId(),
60 $invited_id
61 );
62
63 $room->sendInvitationNotification($this->gui, $chat_user, $invited_id, $subRoomId);
64
65 $this->sendResponse($response);
66 }
67
68 public function byId(): void
69 {
70 $this->inviteById($this->getRequestValue('user', $this->refinery->kindlyTo()->int()));
71 }
72
73 public function getUserList(): void
74 {
75 $auto = new ilUserAutoComplete();
76 $auto->setUser($this->ilUser);
78 if ($this->ilUser->isAnonymous()) {
79 $auto->setSearchType(ilUserAutoComplete::SEARCH_TYPE_EQUALS);
80 }
81
83 $this->getRequestValue('q', $this->refinery->kindlyTo()->string(), '')
84 );
85
86 if ($this->http->wrapper()->query()->has('fetchall')) {
87 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
88 }
89 $auto->setMoreLinkAvailable(true);
90 $auto->setSearchFields(['firstname', 'lastname']);
91 $auto->setResultField('login');
92 $auto->enableFieldSearchableCheck(true);
93
94 $this->sendResponse($auto->getList($query), true);
95 }
96}
Class ilChatroomGUIHandler.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
exitIfNoRoomModeratePermission(ilChatroom $room, int $subRoom, ilChatroomUser $chatUser)
Check if user can moderate a chatroom.
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.
getRequestValue(string $key, Transformation $trafo, $default=null)
Class ilChatroomUser.
static byObjectId(int $object_id)
static _lookupId($a_user_str)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static http()
Fetches the global http state from ILIAS.
$query
$response