ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilChatroomGUIHandler Class Reference

Class ilChatroomGUIHandler. More...

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

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 
 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...
 
 sendResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission ($permission)
 Checks for access with ilRbacSystem. 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
 
 $obj_service
 
 $upload
 
 $rbacsystem
 
 $mainTpl
 
 $ilias
 
 $navigationHistory
 
 $tree
 
 $tabs
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, and $gui.

83  {
84  global $DIC;
85 
86  $this->gui = $gui;
87  $this->ilUser = $DIC->user();
88  $this->ilCtrl = $DIC->ctrl();
89  $this->ilLng = $DIC->language();
90  $this->rbacsystem = $DIC->rbac()->system();
91  $this->mainTpl = $DIC->ui()->mainTemplate();
92  $this->upload = $DIC->upload();
93  $this->webDirectory = $DIC->filesystem()->web();
94  $this->obj_service = $DIC->object();
95  $this->ilias = $DIC['ilias'];
96  $this->tabs = $DIC->tabs();
97  $this->navigationHistory = $DIC['ilNavigationHistory'];
98  $this->tree = $DIC['tree'];
99  }
This class provides processing control methods.
global $DIC
Definition: goto.php:24
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 208 of file class.ilChatroomGUIHandler.php.

References hasPermission(), and isMainRoom().

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

209  {
210  return $this->isMainRoom($subRoom) || $room->isOwnerOfPrivateRoom(
211  $user_id,
212  $subRoom
213  ) || $this->hasPermission('moderate');
214  }
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 107 of file class.ilChatroomGUIHandler.php.

References executeDefault().

108  {
109  $this->ilLng->loadLanguageModule('chatroom');
110 
111  if (method_exists($this, $method)) {
112  return $this->$method();
113  } else {
114  return $this->executeDefault($method);
115  }
116  }
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 161 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().

162  {
163  if (!$room) {
164  $this->sendResponse(
165  array(
166  'success' => false,
167  'reason' => 'unkown room',
168  )
169  );
170  }
171  }
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 189 of file class.ilChatroomGUIHandler.php.

References canModerate(), and sendResponse().

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

190  {
191  if (!$this->canModerate($room, $subRoom, $chat_user->getUserId())) {
192  $this->sendResponse(
193  array(
194  'success' => false,
195  'reason' => 'not owner of private room',
196  )
197  );
198  }
199  }
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 152 of file class.ilChatroomGUIHandler.php.

References ilChatroom\byObjectId().

Referenced by ilChatroomClearGUI\executeDefault().

153  {
154  return ilChatroom::byObjectId($objectId);
155  }
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 230 of file class.ilChatroomGUIHandler.php.

References ilChatroom\checkUserPermissions().

Referenced by canModerate().

231  {
232  return ilChatroom::checkUserPermissions($permission, $this->gui->ref_id);
233  }
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 220 of file class.ilChatroomGUIHandler.php.

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

221  {
222  return $subRoomId == 0;
223  }
+ 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 141 of file class.ilChatroomGUIHandler.php.

References $response.

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

142  {
143  $response = json_decode($response, true);
144 
145  return $response !== null && array_key_exists('success', $response) && $response['success'];
146  }
$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 128 of file class.ilChatroomGUIHandler.php.

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

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

129  {
130  if (!ilChatroom::checkUserPermissions($permission, $this->gui->ref_id)) {
131  $this->ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
132  $this->ilCtrl->redirectByClass('ilrepositorygui', '');
133  }
134  }
This class provides processing control methods.
const ROOT_FOLDER_ID
Definition: constants.php:30
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 62 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 57 of file class.ilChatroomGUIHandler.php.

◆ $navigationHistory

ilChatroomGUIHandler::$navigationHistory
protected

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

◆ $obj_service

ilChatroomGUIHandler::$obj_service
protected

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

◆ $rbacsystem

ilChatroomGUIHandler::$rbacsystem
protected

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

◆ $tabs

ilChatroomGUIHandler::$tabs
protected

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

◆ $tree

ilChatroomGUIHandler::$tree
protected

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

◆ $upload

ilChatroomGUIHandler::$upload
protected

Definition at line 47 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: