ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
All Data Structures Namespaces Files Functions Variables Typedefs Modules Pages
ilChatroomPrivateRoomGUI Class Reference

Class ilChatroomPrivateRoomGUI. More...

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

Public Member Functions

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

 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
 
 $upload
 
 $rbacsystem
 
 $mainTpl
 
 $ilias
 
 $navigationHistory
 
 $tree
 
 $tabs
 

Detailed Description

Member Function Documentation

◆ create()

ilChatroomPrivateRoomGUI::create ( )

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

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

20  {
21  $this->redirectIfNoPermission('read');
22 
23  $room = ilChatroom::byObjectId($this->gui->object->getId());
24  $chat_user = new ilChatroomUser($this->ilUser, $room);
25 
26  $this->exitIfNoRoomExists($room);
27  $this->exitIfNoRoomSubscription($room, $chat_user);
28 
29  $title = $room->getUniquePrivateRoomTitle(ilUtil::stripSlashes((string) $_REQUEST['title']));
30  $subRoomId = $room->addPrivateRoom($title, $chat_user, array('public' => false));
31 
32  $connector = $this->gui->getConnector();
33  $response = $connector->sendCreatePrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $title);
34 
35  if ($this->isSuccessful($response)) {
36  $response = array(
37  'success' => true,
38  'title' => $title,
39  'owner' => $chat_user->getUserId(),
40  'subRoomId' => $subRoomId
41  );
42  }
43 
44  $this->sendResponse($response);
45  }
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 61 of file class.ilChatroomPrivateRoomGUI.php.

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

62  {
63  $room = ilChatroom::byObjectId($this->gui->object->getId());
64  $subRoom = $_REQUEST['sub'];
65  $chat_user = new ilChatroomUser($this->ilUser, $room);
66 
67  $this->exitIfNoRoomExists($room);
68  $this->exitIfNoRoomSubscription($room, $chat_user);
69 
70  $room->closePrivateRoom($subRoom);
71 
72  $connector = $this->gui->getConnector();
73  $response = $connector->sendDeletePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
74 
75  $this->sendResponse($response);
76  }
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 97 of file class.ilChatroomPrivateRoomGUI.php.

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

98  {
99  $this->redirectIfNoPermission('read');
100 
101  $room = ilChatroom::byObjectId($this->gui->object->getId());
102  $subRoom = $_REQUEST['sub'];
103  $chat_user = new ilChatroomUser($this->ilUser, $room);
104 
105  $this->exitIfNoRoomExists($room);
106  $this->exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user);
107 
108  $connector = $this->gui->getConnector();
109  $response = $connector->sendEnterPrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
110 
111  if ($this->isSuccessful($response)) {
112  $room->subscribeUserToPrivateRoom($subRoom, $chat_user->getUserId());
113  }
114 
115  $this->sendResponse($response);
116  }
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 (   $method)

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

16  {
17  }

◆ exitIfEnterRoomIsNotAllowed()

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

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

References ilChatroomGUIHandler\sendResponse().

Referenced by enter().

124  {
125  if (!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $subRoom)) {
126  $this->sendResponse(array(
127  'success' => false,
128  'reason' => 'not allowed enter to private room'
129  ));
130  }
131  }
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 51 of file class.ilChatroomPrivateRoomGUI.php.

References ilChatroomGUIHandler\sendResponse().

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

52  {
53  if (!$room->isSubscribed($chat_user->getUserId())) {
54  $this->sendResponse(array(
55  'success' => false,
56  'reason' => 'not subscribed'
57  ));
58  }
59  }
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 78 of file class.ilChatroomPrivateRoomGUI.php.

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

79  {
80  $room = ilChatroom::byObjectId($this->gui->object->getId());
81  $chat_user = new ilChatroomUser($this->ilUser, $room);
82  $subRoom = $_REQUEST['sub'];
83 
84  $this->exitIfNoRoomExists($room);
85  $this->exitIfNoRoomSubscription($room, $chat_user);
86 
87  $connector = $this->gui->getConnector();
88  $response = $connector->sendLeavePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
89 
90  if ($room->userIsInPrivateRoom($subRoom, $chat_user->getUserId())) {
91  $room->unsubscribeUserFromPrivateRoom($subRoom, $chat_user->getUserId());
92  }
93 
94  $this->sendResponse($response);
95  }
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 133 of file class.ilChatroomPrivateRoomGUI.php.

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

134  {
135  $room = ilChatroom::byObjectId($this->gui->object->getId());
136 
137  $response = $room->listUsersInPrivateRoom($_REQUEST['sub']);
138  $this->sendResponse($response);
139  }
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: