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';
54 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id", ROOT_FOLDER_ID);
55 $ilCtrl->redirectByClass(
"ilrepositorygui",
"");
61 $user_id = $chat_user->getUserId();
65 $response = json_encode( array(
67 'reason' =>
'unkown room'
69 echo json_encode( $response );
72 else if( !$room->isSubscribed( $chat_user->getUserId() ) )
74 $response = json_encode( array(
76 'reason' =>
'not subscribed'
78 echo json_encode( $response );
83 $connector = $this->gui->getConnector();
84 $response = $connector->createPrivateRoom($room,
$title, $chat_user);
86 echo json_encode($response);
90 public function delete()
94 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
95 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
100 $user_id = $chat_user->getUserId();
104 $response = json_encode( array(
106 'reason' =>
'unkown room'
108 echo json_encode( $response );
111 else if( !$room->isOwnerOfPrivateRoom( $user_id,
$_REQUEST[
'sub'] ) && !$rbacsystem->checkAccess(
'moderate', $this->gui->getRefId()) )
113 $response = json_encode( array(
115 'reason' =>
'not owner of private room'
117 echo json_encode( $response );
121 $scope = $room->getRoomId();
124 $params[
'user'] = $chat_user->getUserId();
125 $params[
'id'] = $room->closePrivateRoom(
$_REQUEST[
'sub'], $chat_user, $settings);
126 $query = http_build_query( $params );
127 $connector = $this->gui->getConnector();
129 if(
true || $responseObject->success ==
true )
131 $message = json_encode( array(
132 'type' =>
'private_room_deleted',
134 'timestamp' => date(
'c' ),
137 'id' => $responseObject->id,
140 'message' =>
'room deleted',
146 $connector->sendMessage( $room->getRoomId(), $message, array(
'public' => 1) );
149 $response = json_encode(array(
'success' =>
true));
170 $user_id = $chat_user->getUserId();
171 $connector = $this->gui->getConnector();
175 $response = json_encode( array(
177 'reason' =>
'unkown room'
179 echo json_encode( $response );
182 else if( !$room->isSubscribed( $chat_user->getUserId() ) )
184 $response = json_encode( array(
186 'reason' =>
'not subscribed'
188 echo json_encode( $response );
192 $scope = $room->getRoomId();
195 $params[
'user'] = $chat_user->getUserId();
198 $message = json_encode( array(
199 'type' =>
'private_room_left',
200 'user' => $params[
'user'],
201 'sub' => $params[
'sub']
204 $connector->sendMessage( $room->getRoomId(), $message, array(
'public' => 1,
'sub' => $params[
'sub']) );
206 if( $room->userIsInPrivateRoom( $params[
'sub'], $params[
'user'] ) )
209 $query = http_build_query( $params );
210 $connector = $this->gui->getConnector();
211 $response = $connector->leavePrivateRoom( $scope,
$query );
212 $responseObject = json_decode( $response );
219 $room->unsubscribeUserFromPrivateRoom( $params[
'sub'], $params[
'user'] );
223 $response = json_encode( array(
'success' =>
true,
'message' =>
'was not in room') );
239 $user_id = $chat_user->getUserId();
243 $response = json_encode( array(
245 'reason' =>
'unkown room'
247 echo json_encode( $response );
250 else if( !$room->isAllowedToEnterPrivateRoom( $chat_user->getUserId(),
$_REQUEST[
'sub'] ) )
252 $response = json_encode( array(
254 'reason' =>
'not allowed enter to private room'
257 echo json_encode( $response );
261 $scope = $room->getRoomId();
264 $params[
'user'] = $chat_user->getUserId();
266 $params[
'message'] = json_encode( array(
267 'type' =>
'private_room_entered',
272 $query = http_build_query( $params );
273 $connector = $this->gui->getConnector();
274 $response = $connector->enterPrivateRoom( $scope,
$query );
275 $responseObject = json_decode( $response );
277 $message = json_encode( array(
278 'type' =>
'private_room_entered',
279 'user' => $params[
'user'],
280 'sub' => $params[
'sub']
283 $connector->sendMessage( $room->getRoomId(), $message, array(
'public' => 1,
'sub' => $params[
'sub']) );
285 if( $responseObject->success ==
true )
287 $room->subscribeUserToPrivateRoom( $params[
'sub'], $params[
'user'] );
300 echo json_encode( $room->listUsersInPrivateRoom(
$_REQUEST[
'sub'] ) );
316 $data =
new stdClass();
319 $data->title = $params[
'title'];
320 $data->timestamp = date(
'c' );
321 $data->type =
'private_room_created';