ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 
 $rbacsystem
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $gui, $ilCtrl, $ilUser, $lng, and $rbacsystem.

43  {
44  global $ilUser, $ilCtrl, $lng, $rbacsystem;
45 
46  $this->gui = $gui;
47  $this->ilUser = $ilUser;
48  $this->ilCtrl = $ilCtrl;
49  $this->ilLng = $lng;
50  $this->rbacsystem = $rbacsystem;
51  }
This class provides processing control methods.
global $lng
Definition: privfeed.php:17

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 115 of file class.ilChatroomGUIHandler.php.

References hasPermission(), and isMainRoom().

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

116  {
117  return $this->isMainRoom($subRoom) || $room->isOwnerOfPrivateRoom($user_id, $subRoom) || $this->hasPermission('moderate');
118  }
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 145 of file class.ilChatroomGUIHandler.php.

References executeDefault().

146  {
147  $this->ilLng->loadLanguageModule('chatroom');
148 
149  if(method_exists($this, $method))
150  {
151  return $this->$method();
152  }
153  else
154  {
155  return $this->executeDefault($method);
156  }
157  }
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 66 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().

67  {
68  if(!$room)
69  {
70  $this->sendResponse(
71  array(
72  'success' => false,
73  'reason' => 'unkown room',
74  )
75  );
76  }
77  }
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 95 of file class.ilChatroomGUIHandler.php.

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

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

96  {
97  if(!$this->canModerate($room, $subRoom, $chat_user->getUserId()))
98  {
99  $this->sendResponse(
100  array(
101  'success' => false,
102  'reason' => 'not owner of private room',
103  )
104  );
105  }
106  }
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 57 of file class.ilChatroomGUIHandler.php.

References ilChatroom\byObjectId().

Referenced by ilChatroomClearGUI\executeDefault().

58  {
59  return ilChatroom::byObjectId($objectId);
60  }
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 134 of file class.ilChatroomGUIHandler.php.

Referenced by canModerate().

135  {
136  return $this->rbacsystem->checkAccess($permission, $this->gui->ref_id);
137  }
+ Here is the caller graph for this function:

◆ isMainRoom()

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

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

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

125  {
126  return $subRoomId == 0;
127  }
+ 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.

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  }
+ 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 169 of file class.ilChatroomGUIHandler.php.

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

Referenced by ilChatroomInfoGUI\__construct(), ilChatroomBanGUI\active(), ilChatroomPrivateRoomGUI\create(), ilChatroomClearGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), and ilChatroomInviteUsersToPrivateRoomGUI\inviteById().

170  {
171  if(!ilChatroom::checkUserPermissions($permission, $this->gui->ref_id))
172  {
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

◆ $rbacsystem


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