ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilChatroomPrivateRoomGUI Class Reference

Class ilChatroomPrivateRoomGUI. More...

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

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 ilChatroomPrivateRoomGUI constructor. More...
 
 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)
 

Protected Attributes

 $ilUser
 
- Protected Attributes inherited from ilChatroomGUIHandler
 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $webDirectory
 
 $upload
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomPrivateRoomGUI::__construct ( ilChatroomObjectGUI  $gui)

ilChatroomPrivateRoomGUI constructor.

Parameters
ilChatroomObjectGUI$gui

Reimplemented from ilChatroomGUIHandler.

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

26 {
27 global $ilUser;
28
29 $this->ilUser = $ilUser;
30
31 parent::__construct($gui);
32 }

References ilChatroomGUIHandler\$gui, and $ilUser.

Member Function Documentation

◆ create()

ilChatroomPrivateRoomGUI::create ( )

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

39 {
40 $this->redirectIfNoPermission('read');
41
42 $room = ilChatroom::byObjectId($this->gui->object->getId());
43 $chat_user = new ilChatroomUser($this->ilUser, $room);
44
45 $this->exitIfNoRoomExists($room);
46 $this->exitIfNoRoomSubscription($room, $chat_user);
47
48 $title = $room->getUniquePrivateRoomTitle(ilUtil::stripSlashes((string) $_REQUEST['title']));
49 $subRoomId = $room->addPrivateRoom($title, $chat_user, array('public' => false));
50
51 $connector = $this->gui->getConnector();
52 $response = $connector->sendCreatePrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $title);
53
54 if ($this->isSuccessful($response)) {
55 $response = array(
56 'success' => true,
57 'title' => $title,
58 'owner' => $chat_user->getUserId(),
59 'subRoomId' => $subRoomId
60 );
61 }
62
63 $this->sendResponse($response);
64 }
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.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$response

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

+ Here is the call graph for this function:

◆ delete()

ilChatroomPrivateRoomGUI::delete ( )

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

81 {
82 $room = ilChatroom::byObjectId($this->gui->object->getId());
83 $subRoom = $_REQUEST['sub'];
84 $chat_user = new ilChatroomUser($this->ilUser, $room);
85
86 $this->exitIfNoRoomExists($room);
87 $this->exitIfNoRoomSubscription($room, $chat_user);
88
89 $room->closePrivateRoom($subRoom);
90
91 $connector = $this->gui->getConnector();
92 $response = $connector->sendDeletePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
93
94 $this->sendResponse($response);
95 }

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

+ Here is the call graph for this function:

◆ enter()

ilChatroomPrivateRoomGUI::enter ( )

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

117 {
118 global $ilUser;
119
120 $this->redirectIfNoPermission('read');
121
122 $room = ilChatroom::byObjectId($this->gui->object->getId());
123 $subRoom = $_REQUEST['sub'];
124 $chat_user = new ilChatroomUser($ilUser, $room);
125
126 $this->exitIfNoRoomExists($room);
127 $this->exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user);
128
129 /*$params = array();
130
131 $params['user'] = $chat_user->getUserId();
132 $params['sub'] = $_REQUEST['sub'];
133 $params['message'] = json_encode( array(
134 'type' => 'private_room_entered',
135 'user' => $user_id
136 ));*/
137
138 //$query = http_build_query( $params );
139 $connector = $this->gui->getConnector();
140 $response = $connector->sendEnterPrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
141
142 if ($this->isSuccessful($response)) {
143 $room->subscribeUserToPrivateRoom($subRoom, $chat_user->getUserId());
144 }
145
146 /*$message = json_encode( array(
147 'type' => 'private_room_entered',
148 'user' => $params['user'],
149 'sub' => $params['sub']
150 ));
151
152 $connector->sendMessage( $room->getRoomId(), $message, array('public' => 1, 'sub' => $params['sub']) );*/
153
154 $this->sendResponse($response);
155 }
exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user)

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

+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomPrivateRoomGUI::executeDefault (   $requestedMethod)
Parameters
string$requestedMethod
Returns
mixed

Reimplemented from ilChatroomGUIHandler.

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

35 {
36 }

◆ exitIfEnterRoomIsNotAllowed()

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

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

163 {
164 if (!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $subRoom)) {
165 $this->sendResponse(array(
166 'success' => false,
167 'reason' => 'not allowed enter to private room'
168 ));
169 }
170 }

References ilChatroomGUIHandler\sendResponse().

Referenced by enter().

+ 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 70 of file class.ilChatroomPrivateRoomGUI.php.

71 {
72 if (!$room->isSubscribed($chat_user->getUserId())) {
73 $this->sendResponse(array(
74 'success' => false,
75 'reason' => 'not subscribed'
76 ));
77 }
78 }

References ilChatroomGUIHandler\sendResponse().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ leave()

ilChatroomPrivateRoomGUI::leave ( )

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

98 {
99 $room = ilChatroom::byObjectId($this->gui->object->getId());
100 $chat_user = new ilChatroomUser($this->ilUser, $room);
101 $subRoom = $_REQUEST['sub'];
102
103 $this->exitIfNoRoomExists($room);
104 $this->exitIfNoRoomSubscription($room, $chat_user);
105
106 $connector = $this->gui->getConnector();
107 $response = $connector->sendLeavePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
108
109 if ($room->userIsInPrivateRoom($subRoom, $chat_user->getUserId())) {
110 $room->unsubscribeUserFromPrivateRoom($subRoom, $chat_user->getUserId());
111 }
112
113 $this->sendResponse($response);
114 }

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

+ Here is the call graph for this function:

◆ listUsers()

ilChatroomPrivateRoomGUI::listUsers ( )

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

173 {
174 $room = ilChatroom::byObjectId($this->gui->object->getId());
175
176 $response = $room->listUsersInPrivateRoom($_REQUEST['sub']);
177 $this->sendResponse($response);
178 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $ilUser

ilChatroomPrivateRoomGUI::$ilUser
protected

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

Referenced by __construct(), and enter().


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