ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 
 $rbacsystem
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomPrivateRoomGUI::__construct ( ilChatroomObjectGUI  $gui)

ilChatroomPrivateRoomGUI constructor.

Parameters
ilChatroomObjectGUI$gui

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

References $ilUser.

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

Member Function Documentation

◆ create()

ilChatroomPrivateRoomGUI::create ( )

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

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

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($_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  {
56  $response = array(
57  'success' => true,
58  'title' => $title,
59  'owner' => $chat_user->getUserId(),
60  'subRoomId' => $subRoomId
61  );
62  }
63 
64  $this->sendResponse($response);
65  }
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.
Create styles array
The data for the language used.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
+ Here is the call graph for this function:

◆ delete()

ilChatroomPrivateRoomGUI::delete ( )

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

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

83  {
84  $room = ilChatroom::byObjectId($this->gui->object->getId());
85  $subRoom = $_REQUEST['sub'];
86  $chat_user = new ilChatroomUser($this->ilUser, $room);
87 
88  $this->exitIfNoRoomExists($room);
89  $this->exitIfNoRoomSubscription($room, $chat_user);
90 
91  $room->closePrivateRoom($subRoom);
92 
93  $connector = $this->gui->getConnector();
94  $response = $connector->sendDeletePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
95 
96  $this->sendResponse($response);
97  }
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.
+ Here is the call graph for this function:

◆ enter()

ilChatroomPrivateRoomGUI::enter ( )

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

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

120  {
121  global $ilUser;
122 
123  ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
124 
125  $room = ilChatroom::byObjectId($this->gui->object->getId());
126  $subRoom = $_REQUEST['sub'];
127  $chat_user = new ilChatroomUser($ilUser, $room);
128 
129  $this->exitIfNoRoomExists($room);
130  $this->exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user);
131 
132  /*$params = array();
133 
134  $params['user'] = $chat_user->getUserId();
135  $params['sub'] = $_REQUEST['sub'];
136  $params['message'] = json_encode( array(
137  'type' => 'private_room_entered',
138  'user' => $user_id
139  ));*/
140 
141  //$query = http_build_query( $params );
142  $connector = $this->gui->getConnector();
143  $response = $connector->sendEnterPrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
144 
145  if($this->isSuccessful($response))
146  {
147  $room->subscribeUserToPrivateRoom($subRoom, $chat_user->getUserId());
148  }
149 
150  /*$message = json_encode( array(
151  'type' => 'private_room_entered',
152  'user' => $params['user'],
153  'sub' => $params['sub']
154  ));
155 
156  $connector->sendMessage( $room->getRoomId(), $message, array('public' => 1, 'sub' => $params['sub']) );*/
157 
158  $this->sendResponse($response);
159  }
sendResponse($response)
Sends a json encoded response and exits the php process.
exitIfNoRoomExists($room)
Checks if a ilChatroom exists.
exitIfEnterRoomIsNotAllowed($room, $subRoom, $chat_user)
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
isSuccessful($response)
Checks for success param in an json decoded response.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomPrivateRoomGUI::executeDefault (   $method)

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

References array, and ilChatroomGUIHandler\sendResponse().

Referenced by enter().

167  {
168  if(!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $subRoom))
169  {
170  $this->sendResponse(array(
171  'success' => false,
172  'reason' => 'not allowed enter to private room'
173  ));
174  }
175  }
sendResponse($response)
Sends a json encoded response and exits the php process.
Create styles array
The data for the language used.
+ 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 71 of file class.ilChatroomPrivateRoomGUI.php.

References array, and ilChatroomGUIHandler\sendResponse().

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

72  {
73  if(!$room->isSubscribed($chat_user->getUserId()))
74  {
75  $this->sendResponse(array(
76  'success' => false,
77  'reason' => 'not subscribed'
78  ));
79  }
80  }
sendResponse($response)
Sends a json encoded response and exits the php process.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ leave()

ilChatroomPrivateRoomGUI::leave ( )

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

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

100  {
101  $room = ilChatroom::byObjectId($this->gui->object->getId());
102  $chat_user = new ilChatroomUser($this->ilUser, $room);
103  $subRoom = $_REQUEST['sub'];
104 
105  $this->exitIfNoRoomExists($room);
106  $this->exitIfNoRoomSubscription($room, $chat_user);
107 
108  $connector = $this->gui->getConnector();
109  $response = $connector->sendLeavePrivateRoom($room->getRoomId(), $subRoom, $chat_user->getUserId());
110 
111  if($room->userIsInPrivateRoom($subRoom, $chat_user->getUserId()))
112  {
113  $room->unsubscribeUserFromPrivateRoom($subRoom, $chat_user->getUserId());
114  }
115 
116  $this->sendResponse($response);
117  }
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.
+ Here is the call graph for this function:

◆ listUsers()

ilChatroomPrivateRoomGUI::listUsers ( )

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

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

178  {
179  $room = ilChatroom::byObjectId($this->gui->object->getId());
180 
181  $response = $room->listUsersInPrivateRoom($_REQUEST['sub']);
182  $this->sendResponse($response);
183  }
sendResponse($response)
Sends a json encoded response and exits the php process.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
+ 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: