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

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

References $DIC, and $gui.

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

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.

References hasPermission(), and isMainRoom().

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

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

References executeDefault().

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)
+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomGUIHandler::executeDefault (   $requestedMethod)
abstract
Parameters
string$requestedMethod
Returns
mixed

Referenced by ilChatroomInfoGUI\__construct(), execute(), and ilChatroomViewGUI\renderFileUploadForm().

+ Here is the caller graph for this function:

◆ 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.

References array, and sendResponse().

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

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.
Create styles array
The data for the language used.
+ 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.

References array, canModerate(), and sendResponse().

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

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  }
sendResponse($response)
Sends a json encoded response and exits the php process.
canModerate($room, $subRoom, $user_id)
Checks if the user has permission to moderate a ilChatroom.
Create styles array
The data for the language used.
+ 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.

References ilChatroom\byObjectId().

Referenced by ilChatroomClearGUI\executeDefault().

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

References ilChatroom\checkUserPermissions().

Referenced by canModerate().

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.
+ 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.

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

129  {
130  return $subRoomId == 0;
131  }
+ 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.

References $response.

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

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

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

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

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  }
This class provides processing control methods.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendResponse()

Field Documentation

◆ $gui

ilChatroomGUIHandler::$gui
protected

◆ $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: