ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilChatroomServerHandler Class Reference

Class ilChatroomServerHandler. More...

+ Collaboration diagram for ilChatroomServerHandler:

Public Member Functions

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

Private Member Functions

 handleCommand ($task)
 Calls command depending on given $task. More...
 
 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. More...
 
 serverStarted ()
 Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method. More...
 
 getUserInformation ($user_ids)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomServerHandler::__construct ( )

Constructor.

Calls $this->handleCommand method.

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

23 {
24 $this->handleCommand( $_REQUEST['task'] );
25 exit;
26 }
handleCommand($task)
Calls command depending on given $task.
exit
Definition: login.php:54
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, exit, and handleCommand().

+ Here is the call graph for this function:

Member Function Documentation

◆ cleanupPrivateRooms()

ilChatroomServerHandler::cleanupPrivateRooms ( )

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

70 {
71 $deletableRooms = ilChatroom::findDeletablePrivateRooms();
72
73 $connector = $this->getConnector();
74
75 foreach($deletableRooms as $deletableRoom) {
76
77 $room = ilChatroom::byObjectId($deletableRoom['object_id']);
78
79 $params['user'] = -1; //$chat_user->getUserId();
80 $room->closePrivateRoom($deletableRoom['proom_id']);
81 $query = http_build_query( $params );
82
83 $message = json_encode( array(
84 'type' => 'private_room_deleted',
85 'timestamp' => date( 'c' ),
86 'public' => 1,
87 'id' => $deletableRoom['proom_id'],
88 'proom_id' => $deletableRoom['proom_id'],
89 'message' => array(
90 'message'=> 'room deleted',
91 'public' => '1',
92 'user' => 'system'
93 )
94 ) );
95
96 $result = $connector->sendMessage( $room->getRoomId(), $message, array('public' => 1) );
97
98 }
99 }
$result
static findDeletablePrivateRooms()
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
$params
Definition: example_049.php:96

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

Referenced by handleCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ disconnectedUsers()

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.

109 {
110 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
111
112 foreach( $usersByScope as $scope => $users )
113 {
114 $users = explode( ',', $users );
115 $chatroom = ilChatroom::byRoomId( $scope );
116
117 if( $chatroom instanceof ilChatroom && is_array( $users ) )
118 {
119 $users = array_filter( $users );
120 $userDetails = $this->getUserInformation($users);
121 $message = json_encode( array(
122 'type' => 'disconnected',
123 'users' => $userDetails,
124 'timestamp' => date( 'c' )
125 ) );
126
127 $chatroom->disconnectUsers( $users );
128
129 if(!isset($_REQUEST['handledAction']) || $_REQUEST['handledAction'] != 'kick')
130 {
131 $this->getConnector()->sendMessage( $chatroom->getRoomId(), $message );
132 }
133
134 if( true || $chatroom->getSetting( 'enable_history' ) ) {
135 $messageObject = array(
136 'type' => 'disconnected',
137 'users' => $userDetails,
138 'timestamp' => date( 'c' )
139 );
140
141 $chatroom->addHistoryEntry( $messageObject );
142 }
143 }
144 }
145 }
Class ilChatroom.
static byRoomId($room_id, $initObject=false)
Returns ilChatroom by given $room_id.

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

Referenced by handleCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConnector()

ilChatroomServerHandler::getConnector ( )

Returns connector.

Instantiates ilChatroomServerConnector with server settings and returns it.

Returns
ilChatroomServerConnector

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

37 {
38 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
39 require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
40 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
41
42 //$settings = new ilChatroomServerSettings();
43 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
44 $connector = new ilChatroomServerConnector( $settings );
45
46 return $connector;
47 }
Class ilChatroomServerConnector.

Referenced by cleanupPrivateRooms(), and disconnectedUsers().

+ Here is the caller graph for this function:

◆ getUserInformation()

ilChatroomServerHandler::getUserInformation (   $user_ids)
private

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

158 {
159 global $ilDB;
160
161 $rset = $ilDB->query('SELECT userdata FROM chatroom_users WHERE ' . $ilDB->in('user_id', $user_ids, false, 'integer'));
162 $users = array();
163 while($row = $ilDB->fetchAssoc($rset)) {
164 $users[] = json_decode($row['userdata']);
165 }
166 return $users;
167 }
global $ilDB

References $ilDB, and $row.

Referenced by disconnectedUsers().

+ Here is the caller graph for this function:

◆ handleCommand()

ilChatroomServerHandler::handleCommand (   $task)
private

Calls command depending on given $task.

Parameters
string$task

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

55 {
56 switch($task)
57 {
58 case 'disconnectedUsers':
59 if (isset($_REQUEST['scope'])) {
60 $this->disconnectedUsers( $_REQUEST['scope'] );
61 }
62 $this->cleanupPrivateRooms();
63 break;
64 case 'serverStarted':
65 $this->serverStarted();
66 break;
67 }
68 }
disconnectedUsers($usersByScope)
Calls $chatroom->disconnectUsers for every given user in every given scope ($usersByScope),...
serverStarted()
Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method.
$task
GENERAL INFORMATION:

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverStarted()

ilChatroomServerHandler::serverStarted ( )
private

Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method.

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

152 {
153 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
154
156 }
disconnectAllUsersFromAllRooms()
Deletes all entrys from userTable.

References ilChatroom\disconnectAllUsersFromAllRooms().

Referenced by handleCommand().

+ 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: