ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
49 $connector = $this->gui->getConnector();
50 $response = $connector->sendInviteToPrivateRoom(
51 $room->getRoomId(),
52 $chat_user->getUserId(),
53 $invited_id
54 );
55
56 $room->sendInvitationNotification($this->gui, $chat_user, $invited_id);
57
58 if ('asynch' === $this->getRequestValue('cmdMode', $this->refinery->kindlyTo()->string())) {
59 $this->sendResponse($response, 'application/json');
60 }
61 $this->ilCtrl->redirect($this->gui, 'view');
62 }
63
64 public function byId(): void
65 {
66 $this->inviteById($this->getRequestValue('user', $this->refinery->kindlyTo()->int()));
67 }
68
69 public function getUserList(): void
70 {
71 $auto = new ilUserAutoComplete();
72 $auto->setUser($this->ilUser);
74 if ($this->ilUser->isAnonymous()) {
75 $auto->setSearchType(ilUserAutoComplete::SEARCH_TYPE_EQUALS);
76 }
77
78 $query = ilUtil::stripSlashes(
79 $this->getRequestValue('q', $this->refinery->kindlyTo()->string(), '')
80 );
81
82 if ($this->http->wrapper()->query()->has('fetchall')) {
83 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
84 }
85 $auto->setMoreLinkAvailable(true);
86 $auto->setSearchFields(['firstname', 'lastname']);
87 $auto->setResultField('login');
88 $auto->enableFieldSearchableCheck(true);
89
90 $this->sendResponse($auto->getList($query), 'application/json');
91 }
92}
Class ilChatroomGUIHandler.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
sendResponse(string $content, string $type)
Sends a response and exits the php process.
getRequestValue(string $key, Transformation $trafo, $default=null)
Class ilChatroomUser.
static byObjectId(int $object_id)
Class ilCtrl provides processing control methods.
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
static _lookupId(string|array $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.
$response
Definition: xapitoken.php:93