4 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
5 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
49 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
50 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
60 $user_id = $chat_user->getUserId();
64 $response = json_encode( array(
66 'reason' =>
'unkown room'
68 echo json_encode( $response );
71 else if( !$room->isSubscribed( $chat_user->getUserId() ) )
73 $response = json_encode( array(
75 'reason' =>
'not subscribed'
77 echo json_encode( $response );
82 $connector = $this->gui->getConnector();
83 $response = $connector->createPrivateRoom($room,
$title, $chat_user);
85 echo json_encode($response);
89 public function delete()
91 global
$tpl, $ilUser, $ilAccess;
93 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
94 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
99 $user_id = $chat_user->getUserId();
103 $response = json_encode( array(
105 'reason' =>
'unkown room'
107 echo json_encode( $response );
110 else if( !$room->isOwnerOfPrivateRoom( $user_id,
$_REQUEST[
'sub'] ) && !$ilAccess->checkAccess(
'moderate',
'', $this->gui->getRefId()) )
112 $response = json_encode( array(
114 'reason' =>
'not owner of private room'
116 echo json_encode( $response );
120 $scope = $room->getRoomId();
123 $params[
'user'] = $chat_user->getUserId();
124 $params[
'id'] = $room->closePrivateRoom(
$_REQUEST[
'sub'], $chat_user, $settings);
125 $query = http_build_query( $params );
126 $connector = $this->gui->getConnector();
128 if(
true || $responseObject->success ==
true )
130 $message = json_encode( array(
131 'type' =>
'private_room_deleted',
133 'timestamp' => date(
'c' ),
136 'id' => $responseObject->id,
139 'message' =>
'room deleted',
145 $connector->sendMessage( $room->getRoomId(), $message, array(
'public' => 1) );
148 $response = json_encode(array(
'success' =>
true));
164 global
$tpl, $ilUser;
169 $user_id = $chat_user->getUserId();
170 $connector = $this->gui->getConnector();
174 $response = json_encode( array(
176 'reason' =>
'unkown room'
178 echo json_encode( $response );
181 else if( !$room->isSubscribed( $chat_user->getUserId() ) )
183 $response = json_encode( array(
185 'reason' =>
'not subscribed'
187 echo json_encode( $response );
191 $scope = $room->getRoomId();
194 $params[
'user'] = $chat_user->getUserId();
197 $message = json_encode( array(
198 'type' =>
'private_room_left',
199 'user' => $params[
'user'],
200 'sub' => $params[
'sub']
203 $connector->sendMessage( $room->getRoomId(), $message, array(
'public' => 1,
'sub' => $params[
'sub']) );
205 if( $room->userIsInPrivateRoom( $params[
'sub'], $params[
'user'] ) )
208 $query = http_build_query( $params );
209 $connector = $this->gui->getConnector();
210 $response = $connector->leavePrivateRoom( $scope,
$query );
211 $responseObject = json_decode( $response );
218 $room->unsubscribeUserFromPrivateRoom( $params[
'sub'], $params[
'user'] );
222 $response = json_encode( array(
'success' =>
true,
'message' =>
'was not in room') );
231 global
$tpl, $ilUser;
238 $user_id = $chat_user->getUserId();
242 $response = json_encode( array(
244 'reason' =>
'unkown room'
246 echo json_encode( $response );
249 else if( !$room->isAllowedToEnterPrivateRoom( $chat_user->getUserId(),
$_REQUEST[
'sub'] ) )
251 $response = json_encode( array(
253 'reason' =>
'not allowed enter to private room'
256 echo json_encode( $response );
260 $scope = $room->getRoomId();
263 $params[
'user'] = $chat_user->getUserId();
265 $params[
'message'] = json_encode( array(
266 'type' =>
'private_room_entered',
271 $query = http_build_query( $params );
272 $connector = $this->gui->getConnector();
273 $response = $connector->enterPrivateRoom( $scope,
$query );
274 $responseObject = json_decode( $response );
276 $message = json_encode( array(
277 'type' =>
'private_room_entered',
278 'user' => $params[
'user'],
279 'sub' => $params[
'sub']
282 $connector->sendMessage( $room->getRoomId(), $message, array(
'public' => 1,
'sub' => $params[
'sub']) );
284 if( $responseObject->success ==
true )
286 $room->subscribeUserToPrivateRoom( $params[
'sub'], $params[
'user'] );
299 echo json_encode( $room->listUsersInPrivateRoom(
$_REQUEST[
'sub'] ) );
315 $data =
new stdClass();
318 $data->title = $params[
'title'];
319 $data->timestamp = date(
'c' );
320 $data->type =
'private_room_created';