ILIAS  release_7 Revision v7.30-3-g800a261c036
ilChatroomPrivateRoomGUI Class Reference

Class ilChatroomPrivateRoomGUI. More...

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

Public Member Functions

 executeDefault ($requestedMethod)
 
 create ()
 
 delete ()
 
 leave ()
 
 enter ()
 
 listUsers ()
 
- Public Member Functions inherited from ilChatroomGUIHandler
 __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

 exitIfNoRoomSubscription ($room, $chat_user)
 
 exitIfEnterRoomIsNotAllowed ($room, $subRoom, $chat_user)
 
- Protected Member Functions inherited from ilChatroomGUIHandler
 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)
 

Additional Inherited Members

- Protected Attributes inherited from ilChatroomGUIHandler
 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $webDirectory
 
 $obj_service
 
 $upload
 
 $rbacsystem
 
 $mainTpl
 
 $ilias
 
 $navigationHistory
 
 $tree
 
 $tabs
 

Detailed Description

Member Function Documentation

◆ create()

ilChatroomPrivateRoomGUI::create ( )

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

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

23  {
24  $this->redirectIfNoPermission('read');
25 
26  $room = ilChatroom::byObjectId($this->gui->object->getId());
27  $chat_user = new ilChatroomUser($this->ilUser, $room);
28 
29  $this->exitIfNoRoomExists($room);
30  $this->exitIfNoRoomSubscription($room, $chat_user);
31 
32  $title = $room->getUniquePrivateRoomTitle(ilUtil::stripSlashes((string) $_REQUEST['title']));
33  $subRoomId = $room->addPrivateRoom($title, $chat_user, array('public' => false));
34 
35  $connector = $this->gui->getConnector();
36  $response = $connector->sendCreatePrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $title);
37 
38  if ($this->isSuccessful($response)) {
39  $response = array(
40  'success' => true,
41  'title' => $title,
42  'owner' => $chat_user->getUserId(),
43  'subRoomId' => $subRoomId
44  );
45  }
46 
47  $this->sendResponse($response);
48  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
sendResponse($response)
Sends a json encoded response and exits the php process.
exitIfNoRoomExists($room)
Checks if a ilChatroom exists.
isSuccessful($response)
Checks for success param in an json decoded response.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
$response
+ Here is the call graph for this function:

◆ delete()

ilChatroomPrivateRoomGUI::delete ( )

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

References $response, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), exitIfNoRoomSubscription(), and ilChatroomGUIHandler\sendResponse().

65  {
66  $room = ilChatroom::byObjectId($this->gui->object->getId());
67  $subRoom = $_REQUEST['sub'];
68  $chat_user = new ilChatroomUser($this->ilUser, $room);
69 
70  $this->exitIfNoRoomExists($room);
71  $this->exitIfNoRoomSubscription($room, $chat_user);
72 
73  $room->closePrivateRoom($subRoom);
74 
75  $connector = $this->gui->getConnector();
76  $response = $connector->sendDeletePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
77 
78  $this->sendResponse($response);
79  }
sendResponse($response)
Sends a json encoded response and exits the php process.
exitIfNoRoomExists($room)
Checks if a ilChatroom exists.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
$response
+ Here is the call graph for this function:

◆ enter()

ilChatroomPrivateRoomGUI::enter ( )

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

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

101  {
102  $this->redirectIfNoPermission('read');
103 
104  $room = ilChatroom::byObjectId($this->gui->object->getId());
105  $subRoom = $_REQUEST['sub'];
106  $chat_user = new ilChatroomUser($this->ilUser, $room);
107 
108  $this->exitIfNoRoomExists($room);
109  $this->exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user);
110 
111  $connector = $this->gui->getConnector();
112  $response = $connector->sendEnterPrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
113 
114  if ($this->isSuccessful($response)) {
115  $room->subscribeUserToPrivateRoom($subRoom, $chat_user->getUserId());
116  }
117 
118  $this->sendResponse($response);
119  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
sendResponse($response)
Sends a json encoded response and exits the php process.
exitIfNoRoomExists($room)
Checks if a ilChatroom exists.
exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user)
isSuccessful($response)
Checks for success param in an json decoded response.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
$response
+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomPrivateRoomGUI::executeDefault (   $requestedMethod)

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

19  {
20  }

◆ exitIfEnterRoomIsNotAllowed()

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

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

References ilChatroomGUIHandler\sendResponse().

Referenced by enter().

127  {
128  if (!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $subRoom)) {
129  $this->sendResponse(array(
130  'success' => false,
131  'reason' => 'not allowed enter to private room'
132  ));
133  }
134  }
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:

◆ exitIfNoRoomSubscription()

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

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

References ilChatroomGUIHandler\sendResponse().

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

55  {
56  if (!$room->isSubscribed($chat_user->getUserId())) {
57  $this->sendResponse(array(
58  'success' => false,
59  'reason' => 'not subscribed'
60  ));
61  }
62  }
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:

◆ leave()

ilChatroomPrivateRoomGUI::leave ( )

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

References $response, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), exitIfNoRoomSubscription(), and ilChatroomGUIHandler\sendResponse().

82  {
83  $room = ilChatroom::byObjectId($this->gui->object->getId());
84  $chat_user = new ilChatroomUser($this->ilUser, $room);
85  $subRoom = $_REQUEST['sub'];
86 
87  $this->exitIfNoRoomExists($room);
88  $this->exitIfNoRoomSubscription($room, $chat_user);
89 
90  $connector = $this->gui->getConnector();
91  $response = $connector->sendLeavePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
92 
93  if ($room->userIsInPrivateRoom($subRoom, $chat_user->getUserId())) {
94  $room->unsubscribeUserFromPrivateRoom($subRoom, $chat_user->getUserId());
95  }
96 
97  $this->sendResponse($response);
98  }
sendResponse($response)
Sends a json encoded response and exits the php process.
exitIfNoRoomExists($room)
Checks if a ilChatroom exists.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
$response
+ Here is the call graph for this function:

◆ listUsers()

ilChatroomPrivateRoomGUI::listUsers ( )

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

References $response, ilChatroom\byObjectId(), and ilChatroomGUIHandler\sendResponse().

137  {
138  $room = ilChatroom::byObjectId($this->gui->object->getId());
139 
140  $response = $room->listUsersInPrivateRoom($_REQUEST['sub']);
141  $this->sendResponse($response);
142  }
sendResponse($response)
Sends a json encoded response and exits the php process.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
$response
+ Here is the call graph for this function:

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