ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomServerHandler Class Reference

Class ilChatroomServerHandler. More...

+ Collaboration diagram for ilChatroomServerHandler:

Public Member Functions

 __construct ()
 Constructor.
 getConnector ()
 Returns connector.
 cleanupPrivateRooms ()

Private Member Functions

 handleCommand ($task)
 Calls command depending on given $task.
 disconnectedUsers ($usersByScope)
 Calls $chatroom->disconnectUsers for every given user in every given scope ($usersByScope), sends corresponding status messages to chatroom and adds event in history.
 serverStarted ()
 Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method.
 getUserInformation ($user_ids)

Detailed Description

Constructor & Destructor Documentation

ilChatroomServerHandler::__construct ( )

Constructor.

Calls $this->handleCommand method.

Definition at line 22 of file class.ilChatroomServerHandler.php.

References $_REQUEST, exit, and handleCommand().

{
$this->handleCommand( $_REQUEST['task'] );
}

+ Here is the call graph for this function:

Member Function Documentation

ilChatroomServerHandler::cleanupPrivateRooms ( )

Definition at line 70 of file class.ilChatroomServerHandler.php.

References $query, $result, ilChatroom\byObjectId(), ilChatroom\findDeletablePrivateRooms(), and getConnector().

Referenced by handleCommand().

{
$connector = $this->getConnector();
foreach($deletableRooms as $deletableRoom) {
$room = ilChatroom::byObjectId($deletableRoom['object_id']);
$params['user'] = -1; //$chat_user->getUserId();
$room->closePrivateRoom($deletableRoom['proom_id']);
$query = http_build_query( $params );
$message = json_encode( array(
'type' => 'private_room_deleted',
'timestamp' => date( 'c' ),
'public' => 1,
'id' => $deletableRoom['proom_id'],
'proom_id' => $deletableRoom['proom_id'],
'message' => array(
'message'=> 'room deleted',
'public' => '1',
'user' => 'system'
)
) );
$result = $connector->sendMessage( $room->getRoomId(), $message, array('public' => 1) );
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerHandler::disconnectedUsers (   $usersByScope)
private

Calls $chatroom->disconnectUsers for every given user in every given scope ($usersByScope), sends corresponding status messages to chatroom and adds event in history.

Parameters
array$usersByScope

Definition at line 108 of file class.ilChatroomServerHandler.php.

References $_REQUEST, ilChatroom\byRoomId(), getConnector(), and getUserInformation().

Referenced by handleCommand().

{
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
foreach( $usersByScope as $scope => $users )
{
$users = explode( ',', $users );
$chatroom = ilChatroom::byRoomId( $scope );
if( $chatroom instanceof ilChatroom && is_array( $users ) )
{
$users = array_filter( $users );
$userDetails = $this->getUserInformation($users);
$message = json_encode( array(
'type' => 'disconnected',
'users' => $userDetails,
'timestamp' => date( 'c' )
) );
$chatroom->disconnectUsers( $users );
if(!isset($_REQUEST['handledAction']) || $_REQUEST['handledAction'] != 'kick')
{
$this->getConnector()->sendMessage( $chatroom->getRoomId(), $message );
}
if( true || $chatroom->getSetting( 'enable_history' ) ) {
$messageObject = array(
'type' => 'disconnected',
'users' => $userDetails,
'timestamp' => date( 'c' )
);
$chatroom->addHistoryEntry( $messageObject );
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerHandler::getConnector ( )

Returns connector.

Instantiates ilChatroomServerConnector with server settings and returns it.

Returns
ilChatroomServerConnector

Definition at line 36 of file class.ilChatroomServerHandler.php.

Referenced by cleanupPrivateRooms(), and disconnectedUsers().

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

+ Here is the caller graph for this function:

ilChatroomServerHandler::getUserInformation (   $user_ids)
private

Definition at line 158 of file class.ilChatroomServerHandler.php.

References $row.

Referenced by disconnectedUsers().

{
global $ilDB;
$rset = $ilDB->query('SELECT userdata FROM chatroom_users WHERE ' . $ilDB->in('user_id', $user_ids, false, 'integer'));
$users = array();
while($row = $ilDB->fetchAssoc($rset)) {
$users[] = json_decode($row['userdata']);
}
return $users;
}

+ Here is the caller graph for this function:

ilChatroomServerHandler::handleCommand (   $task)
private

Calls command depending on given $task.

Parameters
string$task

Definition at line 54 of file class.ilChatroomServerHandler.php.

References $_REQUEST, cleanupPrivateRooms(), disconnectedUsers(), and serverStarted().

Referenced by __construct().

{
switch($task)
{
case 'disconnectedUsers':
if (isset($_REQUEST['scope'])) {
$this->disconnectedUsers( $_REQUEST['scope'] );
}
break;
case 'serverStarted':
$this->serverStarted();
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerHandler::serverStarted ( )
private

Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method.

Definition at line 151 of file class.ilChatroomServerHandler.php.

References ilChatroom\disconnectAllUsersFromAllRooms().

Referenced by handleCommand().

{
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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