ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
 
 $rbacsystem
 
 $mainTpl
 
 $ilias
 
 $navigationHistory
 
 $tree
 
 $tabs
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, and $gui.

71  {
72  global $DIC;
73 
74  $this->gui = $gui;
75  $this->ilUser = $DIC->user();
76  $this->ilCtrl = $DIC->ctrl();
77  $this->ilLng = $DIC->language();
78  $this->rbacsystem = $DIC->rbac()->system();
79  $this->mainTpl = $DIC->ui()->mainTemplate();
80  $this->upload = $DIC->upload();
81  $this->webDirectory = $DIC->filesystem()->web();
82  $this->ilias = $DIC['ilias'];
83  $this->tabs = $DIC->tabs();
84  $this->navigationHistory = $DIC['ilNavigationHistory'];
85  $this->tree = $DIC['tree'];
86  }
This class provides processing control methods.
global $DIC
Definition: saml.php:7
redirection script todo: (a better solution should control the processing via a xml file) ...

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

References hasPermission(), and isMainRoom().

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

149  {
150  return $this->isMainRoom($subRoom) || $room->isOwnerOfPrivateRoom($user_id, $subRoom) || $this->hasPermission('moderate');
151  }
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 178 of file class.ilChatroomGUIHandler.php.

References executeDefault().

179  {
180  $this->ilLng->loadLanguageModule('chatroom');
181 
182  if (method_exists($this, $method)) {
183  return $this->$method();
184  } else {
185  return $this->executeDefault($method);
186  }
187  }
executeDefault($requestedMethod)
+ Here is the call graph for this function:

◆ executeDefault()

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

Referenced by execute().

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

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().

102  {
103  if (!$room) {
104  $this->sendResponse(
105  array(
106  'success' => false,
107  'reason' => 'unkown room',
108  )
109  );
110  }
111  }
sendResponse($response)
Sends a json encoded response and exits the php process.
+ 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 129 of file class.ilChatroomGUIHandler.php.

References canModerate(), and sendResponse().

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

130  {
131  if (!$this->canModerate($room, $subRoom, $chat_user->getUserId())) {
132  $this->sendResponse(
133  array(
134  'success' => false,
135  'reason' => 'not owner of private room',
136  )
137  );
138  }
139  }
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.
+ 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 92 of file class.ilChatroomGUIHandler.php.

References ilChatroom\byObjectId().

Referenced by ilChatroomClearGUI\executeDefault().

93  {
94  return ilChatroom::byObjectId($objectId);
95  }
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 167 of file class.ilChatroomGUIHandler.php.

References ilChatroom\checkUserPermissions().

Referenced by canModerate().

168  {
169  return ilChatroom::checkUserPermissions($permission, $this->gui->ref_id);
170  }
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 157 of file class.ilChatroomGUIHandler.php.

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

158  {
159  return $subRoomId == 0;
160  }
+ 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 212 of file class.ilChatroomGUIHandler.php.

References $response.

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

213  {
214  $response = json_decode($response, true);
215 
216  return $response !== null && array_key_exists('success', $response) && $response['success'];
217  }
$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 199 of file class.ilChatroomGUIHandler.php.

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

Referenced by ilChatroomBanGUI\active(), ilChatroomAdminViewGUI\clientsettings(), ilChatroomPrivateRoomGUI\create(), ilChatroomPrivateRoomGUI\enter(), ilChatroomInfoGUI\executeDefault(), ilChatroomClearGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomViewGUI\executeDefault(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomAdminViewGUI\saveClientSettings(), ilChatroomAdminViewGUI\saveSettings(), ilChatroomAdminViewGUI\serversettings(), ilChatroomBanGUI\show(), ilChatroomHistoryGUI\showMessages(), and ilChatroomViewGUI\showRoom().

200  {
201  if (!ilChatroom::checkUserPermissions($permission, $this->gui->ref_id)) {
202  $this->ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
203  $this->ilCtrl->redirectByClass('ilrepositorygui', '');
204  }
205  }
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

ilChatroomGUIHandler::$ilCtrl
protected

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

◆ $ilias

ilChatroomGUIHandler::$ilias
protected

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

◆ $ilLng

ilChatroomGUIHandler::$ilLng
protected

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

◆ $ilUser

ilChatroomGUIHandler::$ilUser
protected

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

◆ $mainTpl

ilChatroomGUIHandler::$mainTpl
protected

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

◆ $navigationHistory

ilChatroomGUIHandler::$navigationHistory
protected

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

◆ $rbacsystem

ilChatroomGUIHandler::$rbacsystem
protected

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

◆ $tabs

ilChatroomGUIHandler::$tabs
protected

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

◆ $tree

ilChatroomGUIHandler::$tree
protected

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

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