ILIAS  release_8 Revision v8.24
ilChatroomGUIHandler Class Reference

Class ilChatroomGUIHandler. More...

+ Inheritance diagram for ilChatroomGUIHandler:
+ Collaboration diagram for ilChatroomGUIHandler:

Public Member Functions

 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...
 
 sendResponse ($response, bool $isJson=false)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission (string $permission)
 

Protected Member Functions

 getRequestValue (string $key, Transformation $trafo, $default=null)
 
 hasRequestValue (string $key)
 
 getRoomByObjectId (int $objectId)
 
 exitIfNoRoomExists (?ilChatroom $room)
 Checks if a ilChatroom exists. More...
 
 exitIfNoRoomModeratePermission (ilChatroom $room, int $subRoom, ilChatroomUser $chatUser)
 Check if user can moderate a chatroom. More...
 
 canModerate (ilChatroom $room, int $subRoom, int $usrId)
 
 isMainRoom (int $subRoomId)
 

Protected Attributes

ilChatroomObjectGUI $gui
 
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
 

Detailed Description

Member Function Documentation

◆ canModerate()

ilChatroomGUIHandler::canModerate ( ilChatroom  $room,
int  $subRoom,
int  $usrId 
)
protected

Definition at line 205 of file class.ilChatroomGUIHandler.php.

205 : bool
206 {
207 return (
208 $this->isMainRoom($subRoom) ||
209 $room->isOwnerOfPrivateRoom($usrId, $subRoom) ||
210 $this->hasPermission('moderate')
211 );
212 }
isOwnerOfPrivateRoom(int $user_id, int $proom_id)

References isMainRoom(), and ilChatroom\isOwnerOfPrivateRoom().

Referenced by exitIfNoRoomModeratePermission().

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

◆ execute()

ilChatroomGUIHandler::execute ( string  $method)

Definition at line 112 of file class.ilChatroomGUIHandler.php.

112 : void
113 {
114 $this->ilLng->loadLanguageModule('chatroom');
115
116 if (method_exists($this, $method)) {
117 $this->$method();
118 return;
119 }
120
121 $this->executeDefault($method);
122 }
executeDefault(string $requestedMethod)

References executeDefault().

+ Here is the call graph for this function:

◆ executeDefault()

◆ exitIfNoRoomExists()

ilChatroomGUIHandler::exitIfNoRoomExists ( ?ilChatroom  $room)
protected

Checks if a ilChatroom exists.

If not, it will send a json encoded response with success = false

Parameters
?ilChatroom$room

Definition at line 163 of file class.ilChatroomGUIHandler.php.

163 : void
164 {
165 if (null === $room) {
166 $this->sendResponse([
167 'success' => false,
168 'reason' => 'unknown room',
169 ]);
170 }
171 }
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.

References sendResponse().

Referenced by ilChatroomBanGUI\active(), ilChatroomPrivateRoomGUI\create(), ilChatroomBanGUI\delete(), ilChatroomPrivateRoomGUI\delete(), ilChatroomPrivateRoomGUI\enter(), ilChatroomClearGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomPrivateRoomGUI\leave(), ilChatroomPrivateRoomGUI\listUsers(), ilChatroomKickGUI\main(), and ilChatroomBanGUI\show().

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

◆ exitIfNoRoomModeratePermission()

ilChatroomGUIHandler::exitIfNoRoomModeratePermission ( ilChatroom  $room,
int  $subRoom,
ilChatroomUser  $chatUser 
)
protected

Check if user can moderate a chatroom.

If false it send a json decoded response with success = false

Parameters
ilChatroom$room
int$subRoom
ilChatroomUser$chatUser

Definition at line 195 of file class.ilChatroomGUIHandler.php.

195 : void
196 {
197 if (!$this->canModerate($room, $subRoom, $chatUser->getUserId())) {
198 $this->sendResponse([
199 'success' => false,
200 'reason' => 'not owner of private room',
201 ]);
202 }
203 }
canModerate(ilChatroom $room, int $subRoom, int $usrId)
getUserId()
Returns Ilias User ID.

References canModerate(), ilChatroomUser\getUserId(), and sendResponse().

Referenced by ilChatroomInviteUsersToPrivateRoomGUI\inviteById().

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

◆ getRequestValue()

ilChatroomGUIHandler::getRequestValue ( string  $key,
Transformation  $trafo,
  $default = null 
)
protected
Parameters
string$key
Transformation$trafo
mixed$default
Returns
mixed|null

Definition at line 90 of file class.ilChatroomGUIHandler.php.

91 {
92 if ($this->http->wrapper()->query()->has($key)) {
93 return $this->http->wrapper()->query()->retrieve($key, $trafo);
94 }
95
96 if ($this->http->wrapper()->post()->has($key)) {
97 return $this->http->wrapper()->post()->retrieve($key, $trafo);
98 }
99
100 return $default;
101 }
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\FileDelivery\http().

Referenced by ilChatroomBanGUI\active(), ilChatroomInviteUsersToPrivateRoomGUI\byId(), ilChatroomInviteUsersToPrivateRoomGUI\byLogin(), ilChatroomAdminSmileyGUI\confirmedDeleteMultipleObject(), ilChatroomPrivateRoomGUI\create(), ilChatroomBanGUI\delete(), ilChatroomPrivateRoomGUI\delete(), ilChatroomAdminSmileyGUI\deleteMultipleObject(), ilChatroomAdminSmileyGUI\deleteSmileyObject(), ilChatroomPrivateRoomGUI\enter(), ilChatroomClearGUI\executeDefault(), ilChatroomInfoGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomInviteUsersToPrivateRoomGUI\getUserList(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomViewGUI\joinWithCustomName(), ilChatroomPrivateRoomGUI\leave(), ilChatroomPrivateRoomGUI\listUsers(), ilChatroomKickGUI\main(), ilChatroomAdminSmileyGUI\showDeleteSmileyFormObject(), ilChatroomAdminSmileyGUI\showEditSmileyEntryFormObject(), and ilChatroomKickGUI\sub().

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

◆ getRoomByObjectId()

ilChatroomGUIHandler::getRoomByObjectId ( int  $objectId)
protected

Definition at line 154 of file class.ilChatroomGUIHandler.php.

154 : ?ilChatroom
155 {
156 return ilChatroom::byObjectId($objectId);
157 }
Class ilChatroom.
static byObjectId(int $object_id)

References ilChatroom\byObjectId().

Referenced by ilChatroomClearGUI\executeDefault().

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

◆ hasPermission()

ilChatroomGUIHandler::hasPermission ( string  $permission)

Definition at line 219 of file class.ilChatroomGUIHandler.php.

219 : bool
220 {
221 return ilChatroom::checkUserPermissions($permission, $this->gui->getRefId());
222 }
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.

References ilChatroom\checkUserPermissions().

+ Here is the call graph for this function:

◆ hasRequestValue()

ilChatroomGUIHandler::hasRequestValue ( string  $key)
protected

Definition at line 103 of file class.ilChatroomGUIHandler.php.

103 : bool
104 {
105 if ($this->http->wrapper()->query()->has($key)) {
106 return true;
107 }
108
109 return $this->http->wrapper()->post()->has($key);
110 }

References ILIAS\FileDelivery\http().

Referenced by ilChatroomViewGUI\joinWithCustomName().

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

◆ isMainRoom()

ilChatroomGUIHandler::isMainRoom ( int  $subRoomId)
protected

Definition at line 214 of file class.ilChatroomGUIHandler.php.

214 : bool
215 {
216 return $subRoomId === 0;
217 }

Referenced by canModerate(), and ilChatroomInviteUsersToPrivateRoomGUI\inviteById().

+ Here is the caller graph for this function:

◆ isSuccessful()

ilChatroomGUIHandler::isSuccessful (   $response)

Checks for success param in an json decoded response.

Parameters
string | false$response
Returns
bool

Definition at line 143 of file class.ilChatroomGUIHandler.php.

143 : bool
144 {
145 if (!is_string($response)) {
146 return false;
147 }
148
149 $response = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
150
151 return $response !== null && array_key_exists('success', $response) && $response['success'];
152 }
$response

References $response.

Referenced by ilChatroomBanGUI\active(), ilChatroomPrivateRoomGUI\create(), ilChatroomPrivateRoomGUI\enter(), ilChatroomKickGUI\executeDefault(), and ilChatroomKickGUI\main().

+ Here is the caller graph for this function:

◆ redirectIfNoPermission()

ilChatroomGUIHandler::redirectIfNoPermission (   $permission)

Checks for requested permissions and redirects if the permission check failed.

Parameters
string[] | string$permission

Definition at line 130 of file class.ilChatroomGUIHandler.php.

130 : void
131 {
132 if (!ilChatroom::checkUserPermissions($permission, $this->gui->getRefId())) {
133 $this->ilCtrl->setParameterByClass(ilRepositoryGUI::class, 'ref_id', ROOT_FOLDER_ID);
134 $this->ilCtrl->redirectByClass(ilRepositoryGUI::class);
135 }
136 }
Class ilCtrl provides processing control methods.
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
const ROOT_FOLDER_ID
Definition: constants.php:32

References ilChatroom\checkUserPermissions(), ilCtrl\redirectByClass(), ROOT_FOLDER_ID, and ilCtrl\setParameterByClass().

Referenced by ilChatroomBanGUI\active(), ilChatroomPrivateRoomGUI\create(), ilChatroomPrivateRoomGUI\enter(), ilChatroomClearGUI\executeDefault(), ilChatroomInfoGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomViewGUI\joinWithCustomName(), ilChatroomPrivateRoomGUI\leave(), ilChatroomPrivateRoomGUI\listUsers(), ilChatroomAdminViewGUI\saveClientSettings(), and ilChatroomBanGUI\show().

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

◆ sendResponse()

ilChatroomGUIHandler::sendResponse (   $response,
bool  $isJson = false 
)

Sends a json encoded response and exits the php process.

Parameters
mixed$response
bool$isJson

Definition at line 178 of file class.ilChatroomGUIHandler.php.

178 : void
179 {
180 $this->http->saveResponse(
181 $this->http->response()
182 ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
183 ->withBody(Streams::ofString($isJson ? $response : json_encode($response, JSON_THROW_ON_ERROR)))
184 );
185 $this->http->sendResponse();
186 $this->http->close();
187 }

References $response, and ILIAS\FileDelivery\http().

Referenced by ilChatroomBanGUI\active(), ilChatroomPrivateRoomGUI\create(), ilChatroomPrivateRoomGUI\delete(), ilChatroomPrivateRoomGUI\enter(), ilChatroomClearGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomPollGUI\executeDefault(), ilChatroomPrivateRoomGUI\exitIfEnterRoomIsNotAllowed(), exitIfNoRoomExists(), exitIfNoRoomModeratePermission(), ilChatroomPrivateRoomGUI\exitIfNoRoomSubscription(), ilChatroomInviteUsersToPrivateRoomGUI\getUserList(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomPrivateRoomGUI\leave(), ilChatroomPrivateRoomGUI\listUsers(), ilChatroomKickGUI\main(), and ilChatroomKickGUI\sub().

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

Field Documentation

◆ $gui

ilChatroomObjectGUI ilChatroomGUIHandler::$gui
protected

◆ $http

GlobalHttpState ilChatroomGUIHandler::$http
protected

Definition at line 54 of file class.ilChatroomGUIHandler.php.

◆ $ilCtrl

ilCtrlInterface ilChatroomGUIHandler::$ilCtrl
protected

Definition at line 41 of file class.ilChatroomGUIHandler.php.

◆ $ilias

ILIAS ilChatroomGUIHandler::$ilias
protected

Definition at line 48 of file class.ilChatroomGUIHandler.php.

◆ $ilLng

ilLanguage ilChatroomGUIHandler::$ilLng
protected

Definition at line 42 of file class.ilChatroomGUIHandler.php.

◆ $ilUser

ilObjUser ilChatroomGUIHandler::$ilUser
protected

Definition at line 40 of file class.ilChatroomGUIHandler.php.

◆ $mainTpl

ilGlobalTemplateInterface ilChatroomGUIHandler::$mainTpl
protected

Definition at line 47 of file class.ilChatroomGUIHandler.php.

◆ $navigationHistory

ilNavigationHistory ilChatroomGUIHandler::$navigationHistory
protected

Definition at line 49 of file class.ilChatroomGUIHandler.php.

◆ $obj_service

ilObjectService ilChatroomGUIHandler::$obj_service
protected

Definition at line 44 of file class.ilChatroomGUIHandler.php.

◆ $rbacsystem

ilRbacSystem ilChatroomGUIHandler::$rbacsystem
protected

Definition at line 46 of file class.ilChatroomGUIHandler.php.

◆ $refinery

Refinery ilChatroomGUIHandler::$refinery
protected

Definition at line 55 of file class.ilChatroomGUIHandler.php.

◆ $tabs

ilTabsGUI ilChatroomGUIHandler::$tabs
protected

Definition at line 51 of file class.ilChatroomGUIHandler.php.

◆ $tree

ilTree ilChatroomGUIHandler::$tree
protected

Definition at line 50 of file class.ilChatroomGUIHandler.php.

◆ $uiFactory

UIFactory ilChatroomGUIHandler::$uiFactory
protected

Definition at line 52 of file class.ilChatroomGUIHandler.php.

◆ $uiRenderer

UIRenderer ilChatroomGUIHandler::$uiRenderer
protected

Definition at line 53 of file class.ilChatroomGUIHandler.php.

◆ $upload

FileUpload ilChatroomGUIHandler::$upload
protected

Definition at line 45 of file class.ilChatroomGUIHandler.php.

◆ $webDirectory

Filesystem ilChatroomGUIHandler::$webDirectory
protected

Definition at line 43 of file class.ilChatroomGUIHandler.php.


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