ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomServerConnector Class Reference

Class ilChatroomServerConnector. More...

+ Collaboration diagram for ilChatroomServerConnector:

Public Member Functions

 __construct (ilChatroomServerSettings $settings)
 Constructor.
 connect ($scope, $userId)
 Returns connect URL.
 post ($scope, $query)
 Returns post URL.
 enterPrivateRoom ($scope, $query)
 leavePrivateRoom ($scope, $query)
 kick ($scope, $query)
 Returns kick URL.
 getSettings ()
 Returns $this->settings.
 sendMessage ($scope, $message, $options=array())
 Returns if given message is sucessfully sent.
 inviteToPrivateRoom (ilChatRoom $room, $scope, ilObjUser $inviter, $invited_id)
 createPrivateRoom (ilChatroom $room, $title, ilChatroomUser $owner)
 isServerAlive ()

Static Public Member Functions

static checkServerConnection ()

Private Member Functions

 file_get_contents ($url)
 sendCreatePrivateRoom ($scope, $query)

Private Attributes

 $settings

Detailed Description

Constructor & Destructor Documentation

ilChatroomServerConnector::__construct ( ilChatroomServerSettings  $settings)

Constructor.

Sets $this->settings using given $settings

Parameters
ilChatroomServerSettings$settings

Definition at line 33 of file class.ilChatroomServerConnector.php.

References $settings.

{
$this->settings = $settings;
}

Member Function Documentation

static ilChatroomServerConnector::checkServerConnection ( )
static

Definition at line 260 of file class.ilChatroomServerConnector.php.

References $settings, and ilChatroomAdmin\getDefaultConfiguration().

Referenced by ilChatroomViewTask\clientsettings(), ilChatroomBlockGUI\getHTML(), ilChatroomViewTask\getServerStatus(), and ilChatroomViewTask\serversettings().

{
require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
$connector = new ilChatroomServerConnector( $settings );
return $connector->isServerAlive();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerConnector::connect (   $scope,
  $userId 
)

Returns connect URL.

Creates connect URL using given $scope and $userId and returns it.

Parameters
string$scope
integer$userId
Returns
mixed

Definition at line 47 of file class.ilChatroomServerConnector.php.

References file_get_contents().

{
return $this->file_get_contents(
$this->settings->getURL( 'Connect', $scope ) . '?id=' . $userId
);
}

+ Here is the call graph for this function:

ilChatroomServerConnector::createPrivateRoom ( ilChatroom  $room,
  $title,
ilChatroomUser  $owner 
)

Definition at line 193 of file class.ilChatroomServerConnector.php.

References $query, $result, $settings, $title, ilChatroom\addPrivateRoom(), enterPrivateRoom(), ilChatroom\getRoomId(), ilChatroomUser\getUserId(), sendCreatePrivateRoom(), sendMessage(), and ilChatroom\subscribeUserToPrivateRoom().

{
$settings = array(
'public' => false,
);
$params['user'] = $owner->getUserId();
$params['id'] = $room->addPrivateRoom($title, $owner, $settings);
$query = http_build_query( $params );
$response = $this->sendCreatePrivateRoom( $room->getRoomId(), $query );
$responseObject = json_decode( $response );
$return = $responseObject;
if ($responseObject->success == true)
{
$message = json_encode( array(
'type' => 'private_room_created',
'timestamp' => date( 'c' ),
'public' => 0,
'title' => $title,
'id' => $responseObject->id,
'proom_id' => $responseObject->id,
'owner' => $owner->getUserId(),
) );
$result = $this->sendMessage( $room->getRoomId(), $message, array('public' => 0, 'recipients' => $owner->getUserId()) );
$params = array();
$params['user'] = $owner->getUserId();
$params['sub'] = $responseObject->id;
$query = http_build_query( $params );
$response = $this->enterPrivateRoom( $room->getRoomId(), $query );
$room->subscribeUserToPrivateRoom($params['sub'], $params['user']);
$message = json_encode( array(
'type' => 'private_room_entered',
'user' => $owner->getUserId(),
'timestamp' => date( 'c' ),
'sub' => $responseObject->id
) );
$this->sendMessage( $room->getRoomId(), $message );
}
return $responseObject;
}

+ Here is the call graph for this function:

ilChatroomServerConnector::enterPrivateRoom (   $scope,
  $query 
)
Parameters
string$scope
string$query
Returns
mixed

Definition at line 89 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

Referenced by createPrivateRoom().

{
return $this->file_get_contents(
$this->settings->getURL( 'EnterPrivateRoom', $scope ) . '?' . $query
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerConnector::file_get_contents (   $url)
private

Definition at line 18 of file class.ilChatroomServerConnector.php.

Referenced by connect(), enterPrivateRoom(), isServerAlive(), kick(), leavePrivateRoom(), post(), and sendCreatePrivateRoom().

{
return file_get_contents($url, null, stream_context_create(array(
'http' => array(
'header' => 'Connection: close'
)
)));
}

+ Here is the caller graph for this function:

ilChatroomServerConnector::getSettings ( )

Returns $this->settings.

Returns
ilChatroomServerSettings

Definition at line 130 of file class.ilChatroomServerConnector.php.

References $settings.

{
}
ilChatroomServerConnector::inviteToPrivateRoom ( ilChatRoom  $room,
  $scope,
ilObjUser  $inviter,
  $invited_id 
)

Definition at line 153 of file class.ilChatroomServerConnector.php.

References $tpl, ilObject\getId(), ilChatroom\lookupPrivateRoomTitle(), and sendMessage().

{
global $tpl, $ilUser;
$chat_user = new ilChatroomUser( $inviter, $room );
$user_id = $chat_user->getUserId();
if ($scope) {
$room->inviteUserToPrivateRoom($invited_id, $scope);
$message = json_encode( array(
'type' => 'private_room_created',
'users' => $invited_id,//$users,
'timestamp' => date( 'c' ),
'public' => 0,
'proom_id' => $scope,
'message' => array(
'public' => '0',
'user' => 'system',
'owner' => $user_id
)
) );
$this->sendMessage( $room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited_id) );
}
if ($room->isSubscribed( $user_id )) {
$message = json_encode( array(
'type' => 'user_invited',
'proom_id' => $scope,
'inviter' => $inviter->getId(),
'invited' => $invited_id
) );
$this->sendMessage( $room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited) );
}
return array('success' => true, 'message' => 'users invited');
}

+ Here is the call graph for this function:

ilChatroomServerConnector::isServerAlive ( )

Definition at line 239 of file class.ilChatroomServerConnector.php.

References file_get_contents().

{
$ctx = stream_context_create(
array(
'http' => array(
'timeout' => 2
)
)
);
$response = @$this->file_get_contents(
$this->settings->getURL( 'Status', 0),
0,
$ctx
);
$responseObject = json_decode($response);
return $responseObject->success == true;
}

+ Here is the call graph for this function:

ilChatroomServerConnector::kick (   $scope,
  $query 
)

Returns kick URL.

Creates kick URL using given $scope and $query and returns it.

Parameters
string$scope
string$query
Returns
mixed

Definition at line 118 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

{
return $this->file_get_contents(
$this->settings->getURL( 'Kick', $scope ) . '?' . $query
);
}

+ Here is the call graph for this function:

ilChatroomServerConnector::leavePrivateRoom (   $scope,
  $query 
)
Parameters
string$scope
string$query
Returns
mixed

Definition at line 102 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

{
return $this->file_get_contents(
$this->settings->getURL( 'LeavePrivateRoom', $scope ) . '?' . $query
);
}

+ Here is the call graph for this function:

ilChatroomServerConnector::post (   $scope,
  $query 
)

Returns post URL.

Creates post URL using given $scope and $query and returns it.

Parameters
string$scope
string$query
Returns
mixed

Definition at line 63 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

Referenced by sendMessage().

{
return $this->file_get_contents(
$this->settings->getURL( 'Post', $scope ) . '?' . $query
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerConnector::sendCreatePrivateRoom (   $scope,
  $query 
)
private
Parameters
string$scope
string$query
Returns
mixed

Definition at line 76 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

Referenced by createPrivateRoom().

{
return $this->file_get_contents(
$this->settings->getURL( 'CreatePrivateRoom', $scope ) . '?' . $query
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerConnector::sendMessage (   $scope,
  $message,
  $options = array() 
)

Returns if given message is sucessfully sent.

Calls $this->post using given $scope and $query built by http_build_query with given $message and returns if message was sent sucessfully.

Parameters
string$scope
string$message
Returns
stdClass

Definition at line 146 of file class.ilChatroomServerConnector.php.

References $query, and post().

Referenced by createPrivateRoom(), and inviteToPrivateRoom().

{
$query = http_build_query( array('message' => $message) + $options );
$response = $this->post( $scope, $query );
return @json_decode( $response );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilChatroomServerConnector::$settings
private

The documentation for this class was generated from the following file: