ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilChatroomPrivateRoomGUI Class Reference

Class ilChatroomPrivateRoomGUI. More...

+ Inheritance diagram for ilChatroomPrivateRoomGUI:
+ Collaboration diagram for ilChatroomPrivateRoomGUI:

Public Member Functions

 executeDefault (string $requestedMethod)
 
 create ()
 
 delete ()
 
 leave ()
 
 enter ()
 
 listUsers ()
 
- Public Member Functions inherited from ilChatroomGUIHandler
 execute (string $method)
 
 executeDefault (string $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, bool $isJson=false)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission (string $permission)
 

Protected Member Functions

 exitIfEnterRoomIsNotAllowed (ilChatroom $room, int $subRoom, ilChatroomUser $chat_user)
 
 exitIfNoRoomSubscription (ilChatroom $room, ilChatroomUser $chat_user)
 
- Protected Member Functions inherited from ilChatroomGUIHandler
 getRequestValue (string $key, Transformation $trafo, $default=null)
 
 hasRequestValue (string $key)
 
 getRoomByObjectId (int $objectId)
 
 exitIfNoRoomExists (?ilChatroom $room)
 Checks if a ilChatroom exists. More...
 
 exitIfNoRoomModeratePermission (ilChatroom $room, int $subRoom, ilChatroomUser $chatUser)
 Check if user can moderate a chatroom. More...
 
 canModerate (ilChatroom $room, int $subRoom, int $usrId)
 
 isMainRoom (int $subRoomId)
 

Additional Inherited Members

- Protected Attributes inherited from ilChatroomGUIHandler
ilChatroomObjectGUI $gui
 
ilObjUser $ilUser
 
ilCtrlInterface $ilCtrl
 
ilLanguage $ilLng
 
Filesystem $webDirectory
 
ilObjectService $obj_service
 
FileUpload $upload
 
ilRbacSystem $rbacsystem
 
ilGlobalTemplateInterface $mainTpl
 
ILIAS $ilias
 
ilNavigationHistory $navigationHistory
 
ilTree $tree
 
ilTabsGUI $tabs
 
UIFactory $uiFactory
 
UIRenderer $uiRenderer
 
GlobalHttpState $http
 
Refinery $refinery
 

Detailed Description

Member Function Documentation

◆ create()

ilChatroomPrivateRoomGUI::create ( )

Definition at line 53 of file class.ilChatroomPrivateRoomGUI.php.

References $response, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), exitIfNoRoomSubscription(), ilChatroomGUIHandler\getRequestValue(), ilChatroomGUIHandler\isSuccessful(), ilChatroomGUIHandler\redirectIfNoPermission(), ILIAS\Repository\refinery(), ilChatroomGUIHandler\sendResponse(), and ilUtil\stripSlashes().

53  : void
54  {
55  $this->redirectIfNoPermission('read');
56 
57  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
58  $this->exitIfNoRoomExists($room);
59 
60  $chat_user = new ilChatroomUser($this->ilUser, $room);
61  $this->exitIfNoRoomSubscription($room, $chat_user);
62 
63  $title = $room->getUniquePrivateRoomTitle(ilUtil::stripSlashes(
64  $this->getRequestValue('title', $this->refinery->kindlyTo()->string())
65  ));
66  $subRoomId = $room->addPrivateRoom($title, $chat_user, ['public' => false]);
67 
68  $connector = $this->gui->getConnector();
69  $response = $connector->sendCreatePrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $title);
70 
71  if ($this->isSuccessful($response)) {
72  $response = [
73  'success' => true,
74  'title' => $title,
75  'owner' => $chat_user->getUserId(),
76  'subRoomId' => $subRoomId
77  ];
78  }
79 
80  $this->sendResponse($response);
81  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getRequestValue(string $key, Transformation $trafo, $default=null)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
exitIfNoRoomSubscription(ilChatroom $room, ilChatroomUser $chat_user)
isSuccessful($response)
Checks for success param in an json decoded response.
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.
Class ilChatroomUser.
static byObjectId(int $object_id)
$response
+ Here is the call graph for this function:

◆ delete()

ilChatroomPrivateRoomGUI::delete ( )

Definition at line 83 of file class.ilChatroomPrivateRoomGUI.php.

References $response, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), exitIfNoRoomSubscription(), ilChatroomGUIHandler\getRequestValue(), ILIAS\Repository\refinery(), and ilChatroomGUIHandler\sendResponse().

83  : void
84  {
85  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
86 
87  $this->exitIfNoRoomExists($room);
88 
89  $subRoom = $this->getRequestValue('sub', $this->refinery->kindlyTo()->int());
90  $chat_user = new ilChatroomUser($this->ilUser, $room);
91  $this->exitIfNoRoomSubscription($room, $chat_user);
92 
93  $room->closePrivateRoom($subRoom);
94 
95  $connector = $this->gui->getConnector();
96  $response = $connector->sendDeletePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
97 
98  $this->sendResponse($response);
99  }
getRequestValue(string $key, Transformation $trafo, $default=null)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
exitIfNoRoomSubscription(ilChatroom $room, ilChatroomUser $chat_user)
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.
Class ilChatroomUser.
static byObjectId(int $object_id)
$response
+ Here is the call graph for this function:

◆ enter()

ilChatroomPrivateRoomGUI::enter ( )

Definition at line 123 of file class.ilChatroomPrivateRoomGUI.php.

References $response, ilChatroom\byObjectId(), exitIfEnterRoomIsNotAllowed(), ilChatroomGUIHandler\exitIfNoRoomExists(), ilChatroomGUIHandler\getRequestValue(), ilChatroomGUIHandler\isSuccessful(), ilChatroomGUIHandler\redirectIfNoPermission(), ILIAS\Repository\refinery(), and ilChatroomGUIHandler\sendResponse().

123  : void
124  {
125  $this->redirectIfNoPermission('read');
126 
127  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
128  $this->exitIfNoRoomExists($room);
129 
130  $subRoom = $this->getRequestValue('sub', $this->refinery->kindlyTo()->int());
131  $chat_user = new ilChatroomUser($this->ilUser, $room);
132  $this->exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user);
133 
134  $connector = $this->gui->getConnector();
135  $response = $connector->sendEnterPrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
136 
137  if ($this->isSuccessful($response)) {
138  $room->subscribeUserToPrivateRoom($subRoom, $chat_user->getUserId());
139  }
140 
141  $this->sendResponse($response);
142  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getRequestValue(string $key, Transformation $trafo, $default=null)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
exitIfEnterRoomIsNotAllowed(ilChatroom $room, int $subRoom, ilChatroomUser $chat_user)
isSuccessful($response)
Checks for success param in an json decoded response.
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.
Class ilChatroomUser.
static byObjectId(int $object_id)
$response
+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomPrivateRoomGUI::executeDefault ( string  $requestedMethod)

Definition at line 49 of file class.ilChatroomPrivateRoomGUI.php.

49  : void
50  {
51  }

◆ exitIfEnterRoomIsNotAllowed()

ilChatroomPrivateRoomGUI::exitIfEnterRoomIsNotAllowed ( ilChatroom  $room,
int  $subRoom,
ilChatroomUser  $chat_user 
)
protected

Definition at line 29 of file class.ilChatroomPrivateRoomGUI.php.

References ilChatroomUser\getUserId(), ilChatroom\isAllowedToEnterPrivateRoom(), and ilChatroomGUIHandler\sendResponse().

Referenced by enter().

29  : void
30  {
31  if (!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $subRoom)) {
32  $this->sendResponse([
33  'success' => false,
34  'reason' => 'not allowed enter to private room'
35  ]);
36  }
37  }
getUserId()
Returns Ilias User ID.
isAllowedToEnterPrivateRoom(int $chat_userid, int $proom_id)
sendResponse($response, bool $isJson=false)
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:

◆ exitIfNoRoomSubscription()

ilChatroomPrivateRoomGUI::exitIfNoRoomSubscription ( ilChatroom  $room,
ilChatroomUser  $chat_user 
)
protected

Definition at line 39 of file class.ilChatroomPrivateRoomGUI.php.

References ilChatroomUser\getUserId(), ilChatroom\isSubscribed(), and ilChatroomGUIHandler\sendResponse().

Referenced by create(), delete(), and leave().

39  : void
40  {
41  if (!$room->isSubscribed($chat_user->getUserId())) {
42  $this->sendResponse([
43  'success' => false,
44  'reason' => 'not subscribed'
45  ]);
46  }
47  }
getUserId()
Returns Ilias User ID.
isSubscribed(int $chat_userid)
sendResponse($response, bool $isJson=false)
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:

◆ leave()

ilChatroomPrivateRoomGUI::leave ( )

Definition at line 101 of file class.ilChatroomPrivateRoomGUI.php.

References $response, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), exitIfNoRoomSubscription(), ilChatroomGUIHandler\getRequestValue(), ilChatroomGUIHandler\redirectIfNoPermission(), ILIAS\Repository\refinery(), and ilChatroomGUIHandler\sendResponse().

101  : void
102  {
103  $this->redirectIfNoPermission('read');
104 
105  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
106 
107  $this->exitIfNoRoomExists($room);
108 
109  $subRoom = $this->getRequestValue('sub', $this->refinery->kindlyTo()->int());
110  $chat_user = new ilChatroomUser($this->ilUser, $room);
111  $this->exitIfNoRoomSubscription($room, $chat_user);
112 
113  $connector = $this->gui->getConnector();
114  $response = $connector->sendLeavePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
115 
116  if ($room->userIsInPrivateRoom($subRoom, $chat_user->getUserId())) {
117  $room->unsubscribeUserFromPrivateRoom($subRoom, $chat_user->getUserId());
118  }
119 
120  $this->sendResponse($response);
121  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getRequestValue(string $key, Transformation $trafo, $default=null)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
exitIfNoRoomSubscription(ilChatroom $room, ilChatroomUser $chat_user)
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.
Class ilChatroomUser.
static byObjectId(int $object_id)
$response
+ Here is the call graph for this function:

◆ listUsers()

ilChatroomPrivateRoomGUI::listUsers ( )

Definition at line 144 of file class.ilChatroomPrivateRoomGUI.php.

References $response, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), ilChatroomGUIHandler\getRequestValue(), ilChatroomGUIHandler\redirectIfNoPermission(), ILIAS\Repository\refinery(), and ilChatroomGUIHandler\sendResponse().

144  : void
145  {
146  $this->redirectIfNoPermission('read');
147 
148  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
149  $this->exitIfNoRoomExists($room);
150 
151  $response = $room->listUsersInPrivateRoom(
152  $this->getRequestValue('sub', $this->refinery->kindlyTo()->int())
153  );
154  $this->sendResponse($response);
155  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getRequestValue(string $key, Transformation $trafo, $default=null)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.
static byObjectId(int $object_id)
$response
+ Here is the call graph for this function:

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