ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilChatroomKickGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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 }
executeDefault(string $requestedMethod)
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getRequestValue(string $key, Transformation $trafo, $default=null)
$response
Definition: xapitoken.php:93
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
sendResponse(string $content, string $type)
Sends a response and exits the php process.
Class ilChatroomGUIHandler.
isSuccessful($response)
Checks for success param in an json decoded response.
Class ilChatroomUser.
static byObjectId(int $object_id)
Class ilChatroomKickGUI.
buildMessage(string $messageString, ilChatroomUser $chat_user)