ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 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 }
exit
Definition: backend.php:16
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 102 of file class.ilChatroomServerHandler.php.

103 {
104 $deletableRooms = ilChatroom::findDeletablePrivateRooms();
105
106 $connector = $this->getConnector();
107
108 foreach ($deletableRooms as $deletableRoom) {
109 $room = ilChatroom::byObjectId($deletableRoom['object_id']);
110
111 $params['user'] = -1; //$chat_user->getUserId();
112 $room->closePrivateRoom($deletableRoom['proom_id']);
113 $query = http_build_query($params);
114
115 $message = json_encode(array(
116 'type' => 'private_room_deleted',
117 'timestamp' => date('c'),
118 'public' => 1,
119 'id' => $deletableRoom['proom_id'],
120 'proom_id' => $deletableRoom['proom_id'],
121 'message' => array(
122 'message' => 'room deleted',
123 'public' => '1',
124 'user' => 'system'
125 )
126 ));
127
128 $result = $connector->sendMessage($room->getRoomId(), $message, array('public' => 1));
129 }
130 }
$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.
catch(Exception $e) $message
$query

References $message, PHPMailer\PHPMailer\$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 49 of file class.ilChatroomServerHandler.php.

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);
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 }
$users
Definition: authpage.php:44
static getUserInformation(array $usrIds, int $roomId=null)
Class ilChatroom.
static byRoomId($room_id, $initObject=false)
Returns ilChatroom by given $room_id.

References $message, $users, ilChatroom\byRoomId(), getConnector(), and ilChatroomUser\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 91 of file class.ilChatroomServerHandler.php.

92 {
93 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
94 require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
95
96 $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
97 $connector = new ilChatroomServerConnector($settings);
98
99 return $connector;
100 }
static getDefaultConfiguration()
Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable.
Class ilChatroomServerConnector.

References ilChatroomAdmin\getDefaultConfiguration().

Referenced by cleanupPrivateRooms(), and disconnectedUsers().

+ Here is the call graph for this function:
+ 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 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 }
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 136 of file class.ilChatroomServerHandler.php.

137 {
138 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
139
141 }
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: