42 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
43 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
53 $user_id = $chat_user->getUserId();
59 else if( !$room->isSubscribed( $chat_user->getUserId() ) )
63 else if ( isset(
$_REQUEST[
'sub']) && !$room->userIsInPrivateRoom(
$_REQUEST[
'sub'], $chat_user->getUserId() ))
65 $response = json_encode( array(
67 'reason' =>
'not subscribed to private room'
69 echo json_encode( $response );
73 $scope = $room->getRoomId();
76 if( ($recipient =
$_REQUEST[
'recipient'] ) )
78 $params[
'recipients'] = join(
',', array_unique( array($user_id, $recipient) ) );
79 $params[
'recipient_names'] = implode(
',', array($chat_user->getUsername(),
$_REQUEST[
'recipient_name']) );
84 $params[
'public'] = 1;
96 $message = json_encode( $messageObject );
98 $params = array_merge( $params, array(
'message' => $message) );
100 $query = http_build_query( $params );
101 $connector = $this->gui->getConnector();
102 $response = $connector->post( $scope,
$query );
104 $responseObject = json_decode( $response );
106 if( $responseObject->success ==
true )
108 $room->addHistoryEntry( $messageObject, $recipient, $publicMessage );
127 $data =
new stdClass();
129 $data->user = $this->gui->object->getPersonalInformation( $chat_user );
130 $data->message = $messageString;
131 $data->timestamp = time() * 1000;
132 $data->type =
'message';
133 isset($params[
'sub']) ? (
$data->sub = $params[
'sub']) :
false;
134 $data->public = (int)$params[
'public'];
135 $data->recipients = $params[
'recipients'];
136 $data->recipient_names = $params[
'recipient_names'];