ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilChatroomGUIHandler Class Reference

Class ilChatroomGUIHandler. More...

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

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 
 sendResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission ($permission)
 Checks for access with ilRbacSystem. More...
 
 execute ($method)
 Executes given $method if existing, otherwise executes executeDefault() method. More...
 
 executeDefault ($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...
 

Protected Member Functions

 getRoomByObjectId ($objectId)
 
 exitIfNoRoomExists ($room)
 Checks if a ilChatroom exists. More...
 
 exitIfNoRoomPermission ($room, $subRoom, $chat_user)
 Check if user can moderate a chatroom. More...
 
 canModerate ($room, $subRoom, $user_id)
 Checks if the user has permission to moderate a ilChatroom. More...
 
 isMainRoom ($subRoomId)
 

Protected Attributes

 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $webDirectory
 
 $upload
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomGUIHandler::__construct ( ilChatroomObjectGUI  $gui)
Parameters
ilChatroomObjectGUI$gui

Reimplemented in ilChatroomAdminViewGUI, ilChatroomHistoryGUI, ilChatroomInfoGUI, ilChatroomInitialGUI, ilChatroomInviteUsersToPrivateRoomGUI, ilChatroomPrivateRoomGUI, and ilChatroomSettingsGUI.

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

48 {
49 global $DIC;
50
51 $this->gui = $gui;
52 $this->ilUser = $DIC->user();
53 $this->ilCtrl = $DIC->ctrl();
54 $this->ilLng = $DIC->language();
55 $this->upload = $DIC->upload();
56 $this->webDirectory = $DIC->filesystem()->web();
57 }
This class provides processing control methods.
global $DIC
Definition: saml.php:7

References $DIC, and $gui.

Member Function Documentation

◆ canModerate()

ilChatroomGUIHandler::canModerate (   $room,
  $subRoom,
  $user_id 
)
protected

Checks if the user has permission to moderate a ilChatroom.

Parameters
ilChatroom$room
int$subRoom
int$user_id
Returns
bool

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

120 {
121 return $this->isMainRoom($subRoom) || $room->isOwnerOfPrivateRoom($user_id, $subRoom) || $this->hasPermission('moderate');
122 }
hasPermission($permission)
Checks for access with ilRbacSystem.

References hasPermission(), and isMainRoom().

Referenced by exitIfNoRoomPermission(), and ilChatroomTaskHandlerMock\mockedCanModerate().

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

◆ execute()

ilChatroomGUIHandler::execute (   $method)

Executes given $method if existing, otherwise executes executeDefault() method.

Parameters
string$method
Returns
mixed

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

150 {
151 $this->ilLng->loadLanguageModule('chatroom');
152
153 if (method_exists($this, $method)) {
154 return $this->$method();
155 } else {
156 return $this->executeDefault($method);
157 }
158 }
executeDefault($requestedMethod)

References executeDefault().

+ Here is the call graph for this function:

◆ executeDefault()

◆ exitIfNoRoomExists()

ilChatroomGUIHandler::exitIfNoRoomExists (   $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 72 of file class.ilChatroomGUIHandler.php.

73 {
74 if (!$room) {
75 $this->sendResponse(
76 array(
77 'success' => false,
78 'reason' => 'unkown room',
79 )
80 );
81 }
82 }
sendResponse($response)
Sends a json encoded response and exits the php process.

References sendResponse().

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

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

◆ exitIfNoRoomPermission()

ilChatroomGUIHandler::exitIfNoRoomPermission (   $room,
  $subRoom,
  $chat_user 
)
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$chat_user

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

101 {
102 if (!$this->canModerate($room, $subRoom, $chat_user->getUserId())) {
103 $this->sendResponse(
104 array(
105 'success' => false,
106 'reason' => 'not owner of private room',
107 )
108 );
109 }
110 }
canModerate($room, $subRoom, $user_id)
Checks if the user has permission to moderate a ilChatroom.

References canModerate(), and sendResponse().

Referenced by ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), and ilChatroomTaskHandlerMock\mockedExitIfNoRoomPermission().

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

◆ getRoomByObjectId()

ilChatroomGUIHandler::getRoomByObjectId (   $objectId)
protected
Parameters
$objectId
Returns
ilChatroom

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

64 {
65 return ilChatroom::byObjectId($objectId);
66 }
static byObjectId($object_id)
Returns ilChatroom object by given $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 (   $permission)

Checks for access with ilRbacSystem.

Parameters
string$permission
Returns
bool

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

139 {
140 return ilChatroom::checkUserPermissions($permission, $this->gui->ref_id);
141 }
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.

References ilChatroom\checkUserPermissions().

Referenced by canModerate().

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

◆ isMainRoom()

ilChatroomGUIHandler::isMainRoom (   $subRoomId)
protected
Parameters
int$subRoomId
Returns
bool

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

129 {
130 return $subRoomId == 0;
131 }

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$response
Returns
boolean

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

184 {
185 $response = json_decode($response, true);
186
187 return $response !== null && array_key_exists('success', $response) && $response['success'];
188 }
$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
array | string$permission

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

171 {
172 if (!ilChatroom::checkUserPermissions($permission, $this->gui->ref_id)) {
173 $this->ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
174 $this->ilCtrl->redirectByClass('ilrepositorygui', '');
175 }
176 }
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.

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

Referenced by ilChatroomBanGUI\active(), ilChatroomAdminViewGUI\clientsettings(), ilChatroomPrivateRoomGUI\create(), ilChatroomPrivateRoomGUI\enter(), ilChatroomClearGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomPostMessageGUI\executeDefault(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomAdminViewGUI\saveClientSettings(), ilChatroomAdminViewGUI\saveSettings(), ilChatroomAdminViewGUI\serversettings(), ilChatroomBanGUI\show(), and ilChatroomUploadFileGUI\uploadFile().

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

◆ sendResponse()

Field Documentation

◆ $gui

◆ $ilCtrl

◆ $ilLng

ilChatroomGUIHandler::$ilLng
protected

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

◆ $ilUser

◆ $upload

ilChatroomGUIHandler::$upload
protected

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

◆ $webDirectory

ilChatroomGUIHandler::$webDirectory
protected

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


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