42 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
43 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
47 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id", ROOT_FOLDER_ID);
48 $ilCtrl->redirectByClass(
"ilrepositorygui",
"");
54 $user_id = $chat_user->getUserId();
60 else if( !$room->isSubscribed( $chat_user->getUserId() ) )
64 else if ( isset(
$_REQUEST[
'sub']) && !$room->userIsInPrivateRoom(
$_REQUEST[
'sub'], $chat_user->getUserId() ))
66 $response = json_encode( array(
68 'reason' =>
'not subscribed to private room'
70 echo json_encode( $response );
74 $scope = $room->getRoomId();
77 if( ($recipient =
$_REQUEST[
'recipient'] ) )
79 $params[
'recipients'] = join(
',', array_unique( array($user_id, $recipient) ) );
80 $params[
'recipient_names'] = implode(
',', array($chat_user->getUsername(),
$_REQUEST[
'recipient_name']) );
85 $params[
'public'] = 1;
97 $message = json_encode( $messageObject );
99 $params = array_merge( $params, array(
'message' => $message) );
101 $query = http_build_query( $params );
102 $connector = $this->gui->getConnector();
103 $response = $connector->post( $scope,
$query );
105 $responseObject = json_decode( $response );
107 if( $responseObject->success ==
true )
109 $room->addHistoryEntry( $messageObject, $recipient, $publicMessage );
128 $data =
new stdClass();
130 $data->user = $this->gui->object->getPersonalInformation( $chat_user );
131 $data->message = $messageString;
132 $data->timestamp = time() * 1000;
133 $data->type =
'message';
134 isset($params[
'sub']) ? ($data->sub = $params[
'sub']) :
false;
135 $data->public = (int)$params[
'public'];
136 $data->recipients = $params[
'recipients'];
137 $data->recipient_names = $params[
'recipient_names'];