ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References exit, and handleCommand().

19  {
20  $this->handleCommand($_REQUEST['task']);
21  exit;
22  }
handleCommand($task)
Calls command depending on given $task.
+ Here is the call graph for this function:

Member Function Documentation

◆ cleanupPrivateRooms()

ilChatroomServerHandler::cleanupPrivateRooms ( )

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

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

Referenced by handleCommand().

115  {
116  $deletableRooms = ilChatroom::findDeletablePrivateRooms();
117 
118  $connector = $this->getConnector();
119 
120  foreach ($deletableRooms as $deletableRoom) {
121  $room = ilChatroom::byObjectId($deletableRoom['object_id']);
122 
123  $params['user'] = -1; //$chat_user->getUserId();
124  $room->closePrivateRoom($deletableRoom['proom_id']);
125  $query = http_build_query($params);
126 
127  $message = json_encode(array(
128  'type' => 'private_room_deleted',
129  'timestamp' => date('c'),
130  'public' => 1,
131  'id' => $deletableRoom['proom_id'],
132  'proom_id' => $deletableRoom['proom_id'],
133  'message' => array(
134  'message' => 'room deleted',
135  'public' => '1',
136  'user' => 'system'
137  )
138  ));
139 
140  $result = $connector->sendMessage($room->getRoomId(), $message, array('public' => 1));
141  }
142  }
$params
Definition: disable.php:11
$result
getConnector()
Returns connector Instantiates ilChatroomServerConnector with server settings and returns it...
catch(Exception $e) $message
static findDeletablePrivateRooms()
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$query
Create styles array
The data for the language used.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
+ 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 49 of file class.ilChatroomServerHandler.php.

References $message, $users, array, ilChatroom\byRoomId(), date, getConnector(), and getUserInformation().

Referenced by handleCommand().

50  {
51  require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
52 
53  foreach ($usersByScope as $scope => $users) {
54  $users = explode(',', $users);
55  $chatroom = ilChatroom::byRoomId($scope);
56 
57  if ($chatroom instanceof ilChatroom && is_array($users)) {
58  $users = array_filter($users);
59  $userDetails = $this->getUserInformation($users);
60  $message = json_encode(array(
61  'type' => 'disconnected',
62  'users' => $userDetails,
63  'timestamp' => date('c')
64  ));
65 
66  $chatroom->disconnectUsers($users);
67 
68  if (!isset($_REQUEST['handledAction']) || $_REQUEST['handledAction'] != 'kick') {
69  $this->getConnector()->sendMessage($chatroom->getRoomId(), $message);
70  }
71 
72  if (true || $chatroom->getSetting('enable_history')) {
73  $messageObject = array(
74  'type' => 'disconnected',
75  'users' => $userDetails,
76  'timestamp' => date('c')
77  );
78 
79  $chatroom->addHistoryEntry($messageObject);
80  }
81  }
82  }
83  }
getConnector()
Returns connector Instantiates ilChatroomServerConnector with server settings and returns it...
static byRoomId($room_id, $initObject=false)
Returns ilChatroom by given $room_id.
catch(Exception $e) $message
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
Class ilChatroom.
+ 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 103 of file class.ilChatroomServerHandler.php.

References ilChatroomAdmin\getDefaultConfiguration().

Referenced by cleanupPrivateRooms(), and disconnectedUsers().

104  {
105  require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
106  require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
107 
108  $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
109  $connector = new ilChatroomServerConnector($settings);
110 
111  return $connector;
112  }
static getDefaultConfiguration()
Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable...
Class ilChatroomServerConnector.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserInformation()

ilChatroomServerHandler::getUserInformation (   $user_ids)
private

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

References $DIC, $row, $users, and array.

Referenced by disconnectedUsers().

86  {
87  global $DIC;
88 
89  $rset = $DIC->database()->query('SELECT userdata FROM chatroom_users WHERE ' . $DIC->database()->in('user_id', $user_ids, false, 'integer'));
90  $users = array();
91  while ($row = $DIC->database()->fetchAssoc($rset)) {
92  $users[] = json_decode($row['userdata']);
93  }
94  return $users;
95  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
+ 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.

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

Referenced by __construct().

29  {
30  switch ($task) {
31  case 'disconnectedUsers':
32  if (isset($_REQUEST['scope'])) {
33  $this->disconnectedUsers($_REQUEST['scope']);
34  }
35  $this->cleanupPrivateRooms();
36  break;
37  case 'serverStarted':
38  $this->serverStarted();
39  break;
40  }
41  }
serverStarted()
Requires ilChatroom and calls its disconnectAllUsersFromAllRooms() method.
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.
+ 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 148 of file class.ilChatroomServerHandler.php.

References ilChatroom\disconnectAllUsersFromAllRooms().

Referenced by handleCommand().

149  {
150  require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
151 
153  }
static disconnectAllUsersFromAllRooms()
Deletes all entrys from userTable.
+ 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: