ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilChatroomServerHandler Class Reference

Class ilChatroomServerHandler. More...

+ Collaboration diagram for ilChatroomServerHandler:

Public Member Functions

 __construct ()
 Constructor Calls $this->handleCommand method. More...
 
 getConnector ()
 Returns connector Instantiates ilChatroomServerConnector with server settings and returns it. 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...
 
 getUserInformation ($user_ids)
 
 serverStarted ()
 Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomServerHandler::__construct ( )

Constructor Calls $this->handleCommand method.

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

19 {
20 $this->handleCommand($_REQUEST['task']);
21 exit;
22 }
handleCommand($task)
Calls command depending on given $task.

References exit, and handleCommand().

+ Here is the call graph for this function:

Member Function Documentation

◆ cleanupPrivateRooms()

ilChatroomServerHandler::cleanupPrivateRooms ( )

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

122 {
123 $deletableRooms = ilChatroom::findDeletablePrivateRooms();
124
125 $connector = $this->getConnector();
126
127 foreach($deletableRooms as $deletableRoom)
128 {
129
130 $room = ilChatroom::byObjectId($deletableRoom['object_id']);
131
132 $params['user'] = -1; //$chat_user->getUserId();
133 $room->closePrivateRoom($deletableRoom['proom_id']);
134 $query = http_build_query($params);
135
136 $message = json_encode(array(
137 'type' => 'private_room_deleted',
138 'timestamp' => date('c'),
139 'public' => 1,
140 'id' => $deletableRoom['proom_id'],
141 'proom_id' => $deletableRoom['proom_id'],
142 'message' => array(
143 'message' => 'room deleted',
144 'public' => '1',
145 'user' => 'system'
146 )
147 ));
148
149 $result = $connector->sendMessage($room->getRoomId(), $message, array('public' => 1));
150
151 }
152 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$result
getConnector()
Returns connector Instantiates ilChatroomServerConnector with server settings and returns it.
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(), date, 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 51 of file class.ilChatroomServerHandler.php.

52 {
53 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
54
55 foreach($usersByScope as $scope => $users)
56 {
57 $users = explode(',', $users);
58 $chatroom = ilChatroom::byRoomId($scope);
59
60 if($chatroom instanceof ilChatroom && is_array($users))
61 {
62 $users = array_filter($users);
63 $userDetails = $this->getUserInformation($users);
64 $message = json_encode(array(
65 'type' => 'disconnected',
66 'users' => $userDetails,
67 'timestamp' => date('c')
68 ));
69
70 $chatroom->disconnectUsers($users);
71
72 if(!isset($_REQUEST['handledAction']) || $_REQUEST['handledAction'] != 'kick')
73 {
74 $this->getConnector()->sendMessage($chatroom->getRoomId(), $message);
75 }
76
77 if(true || $chatroom->getSetting('enable_history'))
78 {
79 $messageObject = array(
80 'type' => 'disconnected',
81 'users' => $userDetails,
82 'timestamp' => date('c')
83 );
84
85 $chatroom->addHistoryEntry($messageObject);
86 }
87 }
88 }
89 }
Class ilChatroom.
static byRoomId($room_id, $initObject=false)
Returns ilChatroom by given $room_id @global ilDBInterface $ilDB.

References ilChatroom\byRoomId(), date, 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 110 of file class.ilChatroomServerHandler.php.

111 {
112 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
113 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
114
115 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
116 $connector = new ilChatroomServerConnector($settings);
117
118 return $connector;
119 }
Class ilChatroomServerConnector.

Referenced by cleanupPrivateRooms(), and disconnectedUsers().

+ Here is the caller graph for this function:

◆ getUserInformation()

ilChatroomServerHandler::getUserInformation (   $user_ids)
private

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

92 {
93 global $ilDB;
94
95 $rset = $ilDB->query('SELECT userdata FROM chatroom_users WHERE ' . $ilDB->in('user_id', $user_ids, false, 'integer'));
96 $users = array();
97 while($row = $ilDB->fetchAssoc($rset))
98 {
99 $users[] = json_decode($row['userdata']);
100 }
101 return $users;
102 }
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 28 of file class.ilChatroomServerHandler.php.

29 {
30 switch($task)
31 {
32 case 'disconnectedUsers':
33 if(isset($_REQUEST['scope']))
34 {
35 $this->disconnectedUsers($_REQUEST['scope']);
36 }
37 $this->cleanupPrivateRooms();
38 break;
39 case 'serverStarted':
40 $this->serverStarted();
41 break;
42 }
43 }
disconnectedUsers($usersByScope)
Calls $chatroom->disconnectUsers for every given user in every given scope ($usersByScope),...
serverStarted()
Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method.

References 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 158 of file class.ilChatroomServerHandler.php.

159 {
160 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
161
163 }
static 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: