ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilChatroomKickGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 private function buildMessage(string $messageString, ilChatroomUser $chat_user): stdClass
30 {
31 $data = new stdClass();
32
33 $data->user = $this->gui->getObject()->getPersonalInformation($chat_user);
34 $data->userToKick = $messageString;
35 $data->timestamp = date('c');
36 $data->type = 'kick';
37
38 return $data;
39 }
40
41 public function executeDefault(string $requestedMethod): void
42 {
43 $this->main();
44 }
45
46 public function main(): void
47 {
48 $this->redirectIfNoPermission(['read', 'moderate']);
49
50 $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
51 $this->exitIfNoRoomExists($room);
52
53 $userToKick = $this->getRequestValue('user', $this->refinery->kindlyTo()->int());
54
55 $connector = $this->gui->getConnector();
56 $response = $connector->sendKick($room->getRoomId(), $userToKick);
57
58 if ($this->isSuccessful($response)) {
59 // 2013-09-11: Should already been done by the chat server
60 $room->disconnectUser($userToKick);
61 }
62
63 $this->sendResponse($response, 'application/json');
64 }
65}
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.
isSuccessful($response)
Checks for success param in an json decoded response.
getRequestValue(string $key, Transformation $trafo, $default=null)
Class ilChatroomKickGUI.
buildMessage(string $messageString, ilChatroomUser $chat_user)
executeDefault(string $requestedMethod)
Class ilChatroomUser.
static byObjectId(int $object_id)
$response
Definition: xapitoken.php:93