ILIAS  release_8 Revision v8.24
ilChatroom Class Reference

Class ilChatroom. More...

+ Collaboration diagram for ilChatroom:

Public Member Functions

 initialize (array $rowdata)
 Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $this->availableSettings. More...
 
 setSetting (string $name, $value)
 Sets given name and value as setting into $this->settings array. More...
 
 getDescription ()
 
 getSetting (string $name)
 
 save ()
 
 saveSettings (array $settings)
 
 addHistoryEntry ($message)
 
 connectUser (ilChatroomUser $user)
 
 getConnectedUsers (bool $only_data=true)
 
 disconnectUser (int $user_id)
 
 disconnectUsers (array $userIds)
 
 getSettings ()
 
 isSubscribed (int $chat_userid)
 
 isAllowedToEnterPrivateRoom (int $chat_userid, int $proom_id)
 
 getHistory (ilDateTime $from=null, ilDateTime $to=null, int $restricted_session_userid=null, ?int $proom_id=0, bool $respect_target=true)
 
 getRoomId ()
 
 getPrivateRoomSessions (ilDateTime $from, ilDateTime $to, int $user_id, int $room_id)
 
 saveFileUploadToDb (int $user_id, string $filename, string $type)
 
 banUser (int $user_id, int $actor_id, string $comment='')
 
 unbanUser ($user_id)
 Deletes entry from banTable matching roomId and given $user_id and returns the number of affected rows. More...
 
 isUserBanned (int $user_id)
 
 getBannedUsers ()
 
 getLastSession (ilChatroomUser $user)
 
 getSessions (ilChatroomUser $user)
 
 addPrivateRoom (string $title, ilChatroomUser $owner, array $settings)
 
 closePrivateRoom (int $id)
 
 isOwnerOfPrivateRoom (int $user_id, int $proom_id)
 
 getChatURL (ilChatroomObjectGUI $gui, int $scope_id=0)
 
 getTitle ()
 
 inviteUserToPrivateRoomByLogin (string $login, int $proom_id)
 
 inviteUserToPrivateRoom (int $user_id, int $proom_id)
 
 getActivePrivateRooms (int $userid)
 
 listUsersInPrivateRoom (int $private_room_id)
 
 subscribeUserToPrivateRoom (int $room_id, int $user_id)
 
 userIsInPrivateRoom (int $room_id, int $user_id)
 
 unsubscribeUserFromPrivateRoom (int $room_id, int $user_id)
 
 countActiveUsers ()
 
 getPrivateRooms ()
 
 getPrivilegedUsersForPrivateRoom (int $subRoomId)
 
 getUniquePrivateRoomTitle (string $title)
 
 getAccessibleRoomIdByTitleMap (int $user_id)
 Fetches and returns a Array<Integer, String> of all accessible repository object chats in the main tree. More...
 
 getPrivateSubRooms (int $parent_room, int $user_id)
 
 getRefIdByRoomId (int $room_id)
 
 getLastMessages (int $number, ilChatroomUser $chatuser)
 
 clearMessages (int $sub_room)
 

Static Public Member Functions

static checkUserPermissions ($permissions, int $ref_id, bool $send_info=true)
 Checks user permissions by given array and ref_id. More...
 
static checkPermissionsOfUser (int $usr_id, $permissions, int $ref_id)
 Checks user permissions in question for a given user id in relation to a given ref_id. More...
 
static byObjectId (int $object_id)
 
static byRoomId (int $room_id, bool $initObject=false)
 
static findDeletablePrivateRooms ()
 
static lookupPrivateRoomTitle (int $proom_id)
 

Data Fields

const ROOM_INVITATION = 'invitation_to_room'
 

Static Protected Member Functions

static checkPermissions (int $usrId, int $refId, array $permissions)
 

Private Member Functions

 phpTypeToMDBType (string $type)
 

Private Attributes

array $settings = []
 
array $availableSettings
 
int $roomId = 0
 
ilObjChatroom $object = null
 

Static Private Attributes

static string $settingsTable = 'chatroom_settings'
 
static string $historyTable = 'chatroom_history'
 
static string $userTable = 'chatroom_users'
 
static string $sessionTable = 'chatroom_sessions'
 
static string $banTable = 'chatroom_bans'
 
static string $privateRoomsTable = 'chatroom_prooms'
 
static string $privateSessionsTable = 'chatroom_psessions'
 
static string $uploadTable = 'chatroom_uploads'
 
static string $privateRoomsAccessTable = 'chatroom_proomaccess'
 

Detailed Description

Class ilChatroom.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 33 of file class.ilChatroom.php.

Member Function Documentation

◆ addHistoryEntry()

ilChatroom::addHistoryEntry (   $message)
Parameters
string | array | stdClass$message

Definition at line 360 of file class.ilChatroom.php.

360 : void
361 {
362 global $DIC;
363
364 $subRoom = 0;
365 $timestamp = 0;
366 if (is_array($message)) {
367 $subRoom = (int) ($message['sub'] ?? 0);
368 $timestamp = (int) $message['timestamp'];
369 } elseif (is_object($message)) {
370 $subRoom = (int) $message->sub;
371 $timestamp = (int) $message->timestamp;
372 }
373
374 $id = $DIC->database()->nextId(self::$historyTable);
375 $DIC->database()->insert(
376 self::$historyTable,
377 [
378 'hist_id' => ['integer', $id],
379 'room_id' => ['integer', $this->roomId],
380 'sub_room' => ['integer', $subRoom],
381 'message' => ['text', json_encode($message, JSON_THROW_ON_ERROR)],
382 'timestamp' => ['integer', ($timestamp > 0 ? $timestamp : time())],
383 ]
384 );
385 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
global $DIC
Definition: feed.php:28
$message
Definition: xapiexit.php:32

References $DIC, $id, $message, $timestamp, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ addPrivateRoom()

ilChatroom::addPrivateRoom ( string  $title,
ilChatroomUser  $owner,
array  $settings 
)

Definition at line 785 of file class.ilChatroom.php.

785 : int
786 {
787 global $DIC;
788
789 $nextId = $DIC->database()->nextId(self::$privateRoomsTable);
790 $DIC->database()->insert(
791 self::$privateRoomsTable,
792 [
793 'proom_id' => ['integer', $nextId],
794 'parent_id' => ['integer', $this->roomId],
795 'title' => ['text', $title],
796 'owner' => ['integer', $owner->getUserId()],
797 'closed' => ['integer', ($settings['closed'] ?? 0)],
798 'created' => ['integer', ($settings['created'] ?? time())],
799 'is_public' => ['integer', $settings['public']],
800 ]
801 );
802
803 return $nextId;
804 }
getUserId()
Returns Ilias User ID.

References $DIC, ILIAS\LTI\ToolProvider\$settings, and ilChatroomUser\getUserId().

+ Here is the call graph for this function:

◆ banUser()

ilChatroom::banUser ( int  $user_id,
int  $actor_id,
string  $comment = '' 
)

Definition at line 667 of file class.ilChatroom.php.

667 : void
668 {
669 global $DIC;
670
671 $DIC->database()->replace(
672 self::$banTable,
673 [
674 'room_id' => ['integer', $this->roomId],
675 'user_id' => ['integer', $user_id]
676 ],
677 [
678 'actor_id' => ['integer', $actor_id],
679 'timestamp' => ['integer', time()],
680 'remark' => ['text', $comment]
681 ]
682 );
683 }
$comment
Definition: buildRTE.php:72

References $comment, and $DIC.

◆ byObjectId()

static ilChatroom::byObjectId ( int  $object_id)
static

Definition at line 173 of file class.ilChatroom.php.

173 : ?ilChatroom
174 {
175 global $DIC;
176
177 $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE object_id = %s';
178 $types = ['integer'];
179 $values = [$object_id];
180 $rset = $DIC->database()->queryF($query, $types, $values);
181
182 if ($row = $DIC->database()->fetchAssoc($rset)) {
183 $room = new self();
184 $room->initialize($row);
185 return $room;
186 }
187
188 return null;
189 }
Class ilChatroom.
$query

References $DIC, and $query.

Referenced by ilChatroomXMLWriter\__construct(), ilChatroomXMLParser\__construct(), ilChatroomBanGUI\active(), ilChatroomHistoryGUI\byDay(), ilChatroomHistoryGUI\bySession(), ilObjChatroom\cloneObject(), ilChatroomPrivateRoomGUI\create(), ilChatroomBanGUI\delete(), ilChatroomPrivateRoomGUI\delete(), ilChatroomPrivateRoomGUI\enter(), ilChatroomKickGUI\executeDefault(), ilChatroomViewGUI\executeDefault(), ilChatroomSettingsGUI\general(), ilObjChatroomListGUI\getProperties(), ilChatroomGUIHandler\getRoomByObjectId(), ilChatroomTabGUIFactory\getTabsForCommand(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomViewGUI\invitePD(), ilChatroomViewGUI\joinWithCustomName(), ilChatroomPrivateRoomGUI\leave(), ilChatroomPrivateRoomGUI\listUsers(), ilChatroomKickGUI\main(), ilChatroomCreateGUI\save(), ilChatroomBanGUI\show(), ilChatroomKickGUI\sub(), and ilChatroomViewGUI\toggleAutoMessageDisplayState().

+ Here is the caller graph for this function:

◆ byRoomId()

static ilChatroom::byRoomId ( int  $room_id,
bool  $initObject = false 
)
static

Definition at line 218 of file class.ilChatroom.php.

218 : ?ilChatroom
219 {
220 global $DIC;
221
222 $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE room_id = %s';
223
224 $types = ['integer'];
225 $values = [$room_id];
226
227 $rset = $DIC->database()->queryF($query, $types, $values);
228
229 if ($row = $DIC->database()->fetchAssoc($rset)) {
230 $room = new self();
231 $room->initialize($row);
232
233 if ($initObject) {
234 $room->object = ilObjectFactory::getInstanceByObjId((int) $row['object_id']);
235 }
236
237 return $room;
238 }
239
240 return null;
241 }
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

References $DIC, $query, and ilObjectFactory\getInstanceByObjId().

Referenced by ilContactGUI\submitInvitation().

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

◆ checkPermissions()

static ilChatroom::checkPermissions ( int  $usrId,
int  $refId,
array  $permissions 
)
staticprotected
Parameters
int$usrId
int$refId
string[]$permissions
Returns
bool

Definition at line 117 of file class.ilChatroom.php.

117 : bool
118 {
119 global $DIC;
120
121 $pub_ref_id = ilObjChatroom::_getPublicRefId();
122
123 foreach ($permissions as $permission) {
124 if ($pub_ref_id === $refId) {
125 $hasAccess = $DIC->rbac()->system()->checkAccessOfUser($usrId, $permission, $refId);
126 if ($hasAccess) {
127 $hasWritePermission = $DIC->rbac()->system()->checkAccessOfUser($usrId, 'write', $refId);
128 if ($hasWritePermission) {
129 continue;
130 }
131
132 $visible = null;
133 $a_obj_id = ilObject::_lookupObjId($refId);
134 $active = ilObjChatroomAccess::isActivated($refId, $a_obj_id, $visible);
135
136 switch ($permission) {
137 case 'visible':
138 if (!$active) {
139 $DIC->access()->addInfoItem(
141 $DIC->language()->txt('offline')
142 );
143 }
144
145 if (!$active && !$visible) {
146 return false;
147 }
148 break;
149
150 case 'read':
151 if (!$active) {
152 $DIC->access()->addInfoItem(
154 $DIC->language()->txt('offline')
155 );
156 return false;
157 }
158 break;
159 }
160 }
161 } else {
162 $hasAccess = $DIC->access()->checkAccessOfUser($usrId, $permission, '', $refId);
163 }
164
165 if (!$hasAccess) {
166 return false;
167 }
168 }
169
170 return true;
171 }
static isActivated(int $refId, int $objId, bool &$a_visible_flag=null)
static _lookupObjId(int $ref_id)
$refId
Definition: xapitoken.php:58

References $DIC, $refId, ilObjChatroom\_getPublicRefId(), ilObject\_lookupObjId(), ilAccessInfo\IL_NO_OBJECT_ACCESS, and ilObjChatroomAccess\isActivated().

Referenced by checkPermissionsOfUser(), and checkUserPermissions().

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

◆ checkPermissionsOfUser()

static ilChatroom::checkPermissionsOfUser ( int  $usr_id,
  $permissions,
int  $ref_id 
)
static

Checks user permissions in question for a given user id in relation to a given ref_id.

Parameters
int$usr_id
string | string[]$permissions
int$ref_id
Returns
bool

Definition at line 102 of file class.ilChatroom.php.

102 : bool
103 {
104 if (!is_array($permissions)) {
105 $permissions = [$permissions];
106 }
107
108 return self::checkPermissions($usr_id, $ref_id, $permissions);
109 }
static checkPermissions(int $usrId, int $refId, array $permissions)
$ref_id
Definition: ltiauth.php:67

References $ref_id, and checkPermissions().

Referenced by ilObjChatroomGUI\executeCommand(), and ilContactGUI\submitInvitation().

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

◆ checkUserPermissions()

static ilChatroom::checkUserPermissions (   $permissions,
int  $ref_id,
bool  $send_info = true 
)
static

Checks user permissions by given array and ref_id.

Parameters
string | string[]$permissions
int$ref_id
bool$send_info
Returns
bool

Definition at line 75 of file class.ilChatroom.php.

75 : bool
76 {
77 global $DIC;
78 $main_tpl = $DIC->ui()->mainTemplate();
79
80 if (!is_array($permissions)) {
81 $permissions = [$permissions];
82 }
83
84 $hasPermissions = self::checkPermissions($DIC->user()->getId(), $ref_id, $permissions);
85 if (!$hasPermissions && $send_info) {
86 $main_tpl->setOnScreenMessage('failure', $DIC->language()->txt('permission_denied'), true);
87
88 return false;
89 }
90
91 return $hasPermissions;
92 }

References $DIC, $ref_id, and checkPermissions().

Referenced by ilObjChatroomAccess\_checkGoto(), ilObjChatroomGUI\_goto(), ilChatroomTabGUIFactory\buildTabs(), ilChatroomInfoGUI\executeDefault(), ilChatroomSettingsGUI\general(), ilChatroomGUIHandler\hasPermission(), ilChatroomGUIHandler\redirectIfNoPermission(), ilChatroomViewGUI\showRoom(), ilChatroomKickGUI\sub(), and ilChatroomAdminSmileyGUI\view().

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

◆ clearMessages()

ilChatroom::clearMessages ( int  $sub_room)

Definition at line 1308 of file class.ilChatroom.php.

1308 : void
1309 {
1310 global $DIC;
1311
1312 $DIC->database()->queryF(
1313 'DELETE FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = %s',
1314 ['integer', 'integer'],
1315 [$this->roomId, $sub_room]
1316 );
1317
1318 if ($sub_room) {
1319 $DIC->database()->queryF(
1320 'DELETE FROM ' . self::$privateSessionsTable . ' WHERE proom_id = %s AND disconnected < %s',
1321 ['integer', 'integer'],
1322 [$sub_room, time()]
1323 );
1324 } else {
1325 $DIC->database()->queryF(
1326 'DELETE FROM ' . self::$sessionTable . ' WHERE room_id = %s AND disconnected < %s',
1327 ['integer', 'integer'],
1328 [$this->roomId, time()]
1329 );
1330 }
1331 }

References $DIC.

◆ closePrivateRoom()

ilChatroom::closePrivateRoom ( int  $id)

Definition at line 806 of file class.ilChatroom.php.

806 : void
807 {
808 global $DIC;
809
810 $DIC->database()->manipulateF(
811 'UPDATE ' . self::$privateRoomsTable . ' SET closed = %s WHERE proom_id = %s',
812 ['integer', 'integer'],
813 [time(), $id]
814 );
815 }

References $DIC, and $id.

◆ connectUser()

ilChatroom::connectUser ( ilChatroomUser  $user)

Definition at line 387 of file class.ilChatroom.php.

387 : bool
388 {
389 global $DIC;
390
391 $userdata = [
392 'login' => $user->getUsername(),
393 'id' => $user->getUserId()
394 ];
395
396 $query = 'SELECT user_id FROM ' . self::$userTable . ' WHERE room_id = %s AND user_id = %s';
397 $types = ['integer', 'integer'];
398 $values = [$this->roomId, $user->getUserId()];
399
400 if (!$DIC->database()->fetchAssoc($DIC->database()->queryF($query, $types, $values))) {
401 // Notice: Using replace instead of insert looks strange, because we actually know whether the selected data exists or not
402 // But we occasionally found some duplicate key errors although the data set should not exist when the following code is reached
403 $DIC->database()->replace(
404 self::$userTable,
405 [
406 'room_id' => ['integer', $this->roomId],
407 'user_id' => ['integer', $user->getUserId()]
408 ],
409 [
410 'userdata' => ['text', json_encode($userdata, JSON_THROW_ON_ERROR)],
411 'connected' => ['integer', time()],
412 ]
413 );
414
415 return true;
416 }
417
418 return false;
419 }
getUsername()
Returns username from Object or SESSION.

References $DIC, $query, $roomId, ilChatroomUser\getUserId(), and ilChatroomUser\getUsername().

Referenced by ilChatroomViewGUI\showRoom().

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

◆ countActiveUsers()

ilChatroom::countActiveUsers ( )

Definition at line 1071 of file class.ilChatroom.php.

1071 : int
1072 {
1073 global $DIC;
1074
1075 $query = 'SELECT COUNT(user_id) cnt FROM ' . self::$userTable . ' WHERE room_id = %s';
1076 $types = ['integer'];
1077 $values = [$this->roomId];
1078 $res = $DIC->database()->queryF($query, $types, $values);
1079
1080 if ($row = $DIC->database()->fetchAssoc($res)) {
1081 return (int) $row['cnt'];
1082 }
1083
1084 return 0;
1085 }
$res
Definition: ltiservices.php:69

References $DIC, $query, and $res.

◆ disconnectUser()

ilChatroom::disconnectUser ( int  $user_id)

Definition at line 438 of file class.ilChatroom.php.

438 : void
439 {
440 $this->disconnectUsers([$user_id]);
441 }
disconnectUsers(array $userIds)

References disconnectUsers().

+ Here is the call graph for this function:

◆ disconnectUsers()

ilChatroom::disconnectUsers ( array  $userIds)
Parameters
int[]$userIds

Definition at line 446 of file class.ilChatroom.php.

446 : void
447 {
448 global $DIC;
449
450 $query = 'SELECT * FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
451 $DIC->database()->in('user_id', $userIds, false, 'integer');
452
453 $types = ['integer'];
454 $values = [$this->roomId];
455 $res = $DIC->database()->queryF($query, $types, $values);
456
457 if ($row = $DIC->database()->fetchAssoc($res)) {
458 $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s';
459 $rset_prooms = $DIC->database()->queryF($query, ['integer'], [$this->roomId]);
460
461 $prooms = [];
462
463 while ($row_prooms = $DIC->database()->fetchAssoc($rset_prooms)) {
464 $prooms[] = $row_prooms['proom_id'];
465 }
466
467 $query = 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = %s WHERE ' .
468 $DIC->database()->in('user_id', $userIds, false, 'integer') .
469 ' AND ' . $DIC->database()->in('proom_id', $prooms, false, 'integer');
470 $DIC->database()->manipulateF($query, ['integer'], [time()]);
471
472 $query = 'DELETE FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
473 $DIC->database()->in('user_id', $userIds, false, 'integer');
474
475 $types = ['integer'];
476 $values = [$this->roomId];
477 $DIC->database()->manipulateF($query, $types, $values);
478
479 do {
480 if ($this->getSetting('enable_history')) {
481 $id = $DIC->database()->nextId(self::$sessionTable);
482 $DIC->database()->insert(
483 self::$sessionTable,
484 [
485 'sess_id' => ['integer', $id],
486 'room_id' => ['integer', $this->roomId],
487 'user_id' => ['integer', $row['user_id']],
488 'userdata' => ['text', $row['userdata']],
489 'connected' => ['integer', $row['connected']],
490 'disconnected' => ['integer', time()]
491 ]
492 );
493 }
494 } while ($row = $DIC->database()->fetchAssoc($res));
495 }
496 }
getSetting(string $name)

References $DIC, $id, $query, $res, $roomId, and getSetting().

Referenced by disconnectUser().

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

◆ findDeletablePrivateRooms()

static ilChatroom::findDeletablePrivateRooms ( )
static
Returns
array{proom_id: int, room_id: int, object_id: int}[]

Definition at line 246 of file class.ilChatroom.php.

246 : array
247 {
248 global $DIC;
249
250 $query = '
251 SELECT private_rooms.proom_id id, MIN(disconnected) min_disconnected, MAX(disconnected) max_disconnected
252 FROM ' . self::$privateSessionsTable . ' private_sessions
253 INNER JOIN ' . self::$privateRoomsTable . ' private_rooms
254 ON private_sessions.proom_id = private_rooms.proom_id
255 WHERE closed = 0
256 GROUP BY private_rooms.proom_id
257 HAVING MIN(disconnected) > 0 AND MAX(disconnected) < %s';
258 $rset = $DIC->database()->queryF(
259 $query,
260 ['integer'],
261 [time() + 60 * 5]
262 );
263
264 $rooms = [];
265
266 while ($row = $DIC->database()->fetchAssoc($rset)) {
267 $rooms[$row['id']] = $row['id'];
268 }
269
270 $query = 'SELECT DISTINCT proom_id, room_id, object_id FROM ' . self::$privateRoomsTable
271 . ' INNER JOIN ' . self::$settingsTable . ' ON parent_id = room_id '
272 . ' WHERE ' . $DIC->database()->in('proom_id', $rooms, false, 'integer');
273
274 $rset = $DIC->database()->query($query);
275 $rooms = [];
276 while ($row = $DIC->database()->fetchAssoc($rset)) {
277 $rooms[] = [
278 'proom_id' => (int) $row['proom_id'],
279 'room_id' => (int) $row['room_id'],
280 'object_id' => (int) $row['object_id']
281 ];
282 }
283
284 return $rooms;
285 }

References $DIC, $query, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getAccessibleRoomIdByTitleMap()

ilChatroom::getAccessibleRoomIdByTitleMap ( int  $user_id)

Fetches and returns a Array<Integer, String> of all accessible repository object chats in the main tree.

Parameters
int$user_id
Returns
array<int, string>

Definition at line 1154 of file class.ilChatroom.php.

1154 : array
1155 {
1156 global $DIC;
1157
1158 $query = "
1159 SELECT room_id, od.title, objr.ref_id
1160 FROM object_data od
1161 INNER JOIN " . self::$settingsTable . "
1162 ON object_id = od.obj_id
1163 INNER JOIN object_reference objr
1164 ON objr.obj_id = od.obj_id
1165 AND objr.deleted IS NULL
1166 INNER JOIN tree
1167 ON tree.child = objr.ref_id
1168 AND tree.tree = %s
1169 WHERE od.type = %s
1170 ";
1171
1172 $types = ['integer', 'text'];
1173 $values = [1, 'chtr'];
1174 $res = $DIC->database()->queryF($query, $types, $values);
1175
1176 $rooms = [];
1177 while ($row = $DIC->database()->fetchAssoc($res)) {
1178 if (self::checkPermissionsOfUser($user_id, 'read', (int) $row['ref_id'])) {
1179 $rooms[(int) $row['room_id']] = $row['title'];
1180 }
1181 }
1182
1183 return $rooms;
1184 }

References $DIC, $query, $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getActivePrivateRooms()

ilChatroom::getActivePrivateRooms ( int  $userid)

Definition at line 969 of file class.ilChatroom.php.

969 : array
970 {
971 global $DIC;
972
973 $query = '
974 SELECT roomtable.title, roomtable.proom_id, accesstable.user_id id, roomtable.owner rowner
975 FROM ' . self::$privateRoomsTable . ' roomtable
976 LEFT JOIN ' . self::$privateRoomsAccessTable . ' accesstable
977 ON roomtable.proom_id = accesstable.proom_id
978 AND accesstable.user_id = %s
979 WHERE parent_id = %s
980 AND (closed = 0 OR closed IS NULL)
981 AND (accesstable.user_id IS NOT NULL OR roomtable.owner = %s)';
982 $types = ['integer', 'integer', 'integer'];
983 $values = [$userid, $this->roomId, $userid];
984 $rset = $DIC->database()->queryF($query, $types, $values);
985 $rooms = [];
986 while ($row = $DIC->database()->fetchAssoc($rset)) {
987 $row['active_users'] = $this->listUsersInPrivateRoom((int) $row['id']);
988 $row['owner'] = $row['rowner'];
989 $rooms[$row['proom_id']] = $row;
990 }
991
992 return $rooms;
993 }
listUsersInPrivateRoom(int $private_room_id)

References $DIC, and $query.

Referenced by ilChatroomViewGUI\showRoom().

+ Here is the caller graph for this function:

◆ getBannedUsers()

ilChatroom::getBannedUsers ( )

Definition at line 718 of file class.ilChatroom.php.

718 : array
719 {
720 global $DIC;
721
722 $query = 'SELECT chb.* FROM ' . self::$banTable . ' chb INNER JOIN usr_data ud ON chb.user_id = ud.usr_id WHERE chb.room_id = %s ';
723 $types = ['integer'];
724 $values = [$this->getRoomId()];
725 $res = $DIC->database()->queryF($query, $types, $values);
726 $result = [];
727
728 while ($row = $DIC->database()->fetchAssoc($res)) {
729 if ($row['user_id'] > 0) {
730 $user = new ilObjUser((int) $row['user_id']);
731 $userdata = [
732 'user_id' => $user->getId(),
733 'firstname' => $user->getFirstname(),
734 'lastname' => $user->getLastname(),
735 'login' => $user->getLogin(),
736 'timestamp' => (int) $row['timestamp'],
737 'actor_id' => (int) $row['actor_id'],
738 'remark' => $row['remark']
739 ];
740
741 $result[] = $userdata;
742 }
743 }
744
745 return $result;
746 }
User class.

References $DIC, $query, $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getChatURL()

ilChatroom::getChatURL ( ilChatroomObjectGUI  $gui,
int  $scope_id = 0 
)

Definition at line 910 of file class.ilChatroom.php.

910 : string
911 {
912 $url = '';
913 if ($scope_id) {
914 $url = ilLink::_getStaticLink($gui->getObject()->getRefId(), $gui->getObject()->getType(), true, '_' . $scope_id);
915 } else {
916 $url = ilLink::_getStaticLink($gui->getObject()->getRefId(), $gui->getObject()->getType());
917 }
918
919 return $url;
920 }
$url

References $url, ilLink\_getStaticLink(), and ilObjectGUI\getObject().

+ Here is the call graph for this function:

◆ getConnectedUsers()

ilChatroom::getConnectedUsers ( bool  $only_data = true)

Definition at line 421 of file class.ilChatroom.php.

421 : array
422 {
423 global $DIC;
424
425 $query = 'SELECT ' . ($only_data ? 'userdata' : '*') . ' FROM ' . self::$userTable . ' WHERE room_id = %s';
426 $types = ['integer'];
427 $values = [$this->roomId];
428 $rset = $DIC->database()->queryF($query, $types, $values);
429 $users = [];
430
431 while ($row = $DIC->database()->fetchAssoc($rset)) {
432 $users[] = $only_data ? json_decode($row['userdata'], false, 512, JSON_THROW_ON_ERROR) : $row;
433 }
434
435 return $users;
436 }

References $DIC, $query, and $roomId.

Referenced by ilChatroomViewGUI\showRoom().

+ Here is the caller graph for this function:

◆ getDescription()

ilChatroom::getDescription ( )

Definition at line 287 of file class.ilChatroom.php.

287 : string
288 {
289 if (!$this->object) {
290 $this->object = ilObjectFactory::getInstanceByObjId((int) $this->getSetting('object_id'));
291 }
292
293 return $this->object->getDescription();
294 }

References ilObjectFactory\getInstanceByObjId(), and getSetting().

+ Here is the call graph for this function:

◆ getHistory()

ilChatroom::getHistory ( ilDateTime  $from = null,
ilDateTime  $to = null,
int  $restricted_session_userid = null,
?int  $proom_id = 0,
bool  $respect_target = true 
)

Definition at line 542 of file class.ilChatroom.php.

548 : array {
549 global $DIC;
550
551 $join = '';
552
553 if ($proom_id) {
554 $join .=
555 'INNER JOIN ' . self::$privateSessionsTable . ' pSessionTable ' .
556 'ON pSessionTable.user_id = ' . $DIC->database()->quote($restricted_session_userid, 'integer') . ' ' .
557 'AND pSessionTable.proom_id = historyTable.sub_room ' .
558 'AND timestamp >= pSessionTable.connected ' .
559 'AND timestamp <= pSessionTable.disconnected ';
560 }
561
562 $query =
563 'SELECT historyTable.* ' .
564 'FROM ' . self::$historyTable . ' historyTable ' . $join . ' ' .
565 'WHERE historyTable.room_id = ' . $this->getRoomId();
566
567 if ($proom_id !== null) {
568 $query .= ' AND historyTable.sub_room = ' . $DIC->database()->quote($proom_id, 'integer');
569 }
570
571 $filter = [];
572
573 if ($from !== null) {
574 $filter[] = 'timestamp >= ' . $DIC->database()->quote($from->getUnixTime(), 'integer');
575 }
576
577 if ($to !== null) {
578 $filter[] = 'timestamp <= ' . $DIC->database()->quote($to->getUnixTime(), 'integer');
579 }
580
581 if ($filter) {
582 $query .= ' AND ' . implode(' AND ', $filter);
583 }
584 $query .= ' ORDER BY timestamp ASC';
585
586 $rset = $DIC->database()->query($query);
587 $result = [];
588
589 while ($row = $DIC->database()->fetchAssoc($rset)) {
590 try {
591 $message = json_decode($row['message'], false, 512, JSON_THROW_ON_ERROR);
592 } catch (JsonException $e) {
593 $message = null;
594 } finally {
595 if ($message === null) {
596 $message = json_decode('{}', false, 512, JSON_THROW_ON_ERROR);
597 }
598 }
599
600 $row['message'] = $message;
601 $row['message']->timestamp = $row['timestamp'];
602 if (
603 $respect_target &&
604 property_exists($row['message'], 'target') &&
605 $row['message']->target !== null &&
606 !$row['message']->target->public && (
607 !isset($row['recipients']) ||
608 !in_array($DIC->user()->getId(), explode(',', $row['recipients']), false)
609 )
610 ) {
611 continue;
612 }
613
614 $result[] = $row;
615 }
616 return $result;
617 }

References $DIC.

◆ getLastMessages()

ilChatroom::getLastMessages ( int  $number,
ilChatroomUser  $chatuser 
)

Definition at line 1243 of file class.ilChatroom.php.

1243 : array
1244 {
1245 global $DIC;
1246
1247 // There is currently no way to check if a message is private or not
1248 // by sql. So we fetch twice as much as we need and hope that there
1249 // are not more than $number private messages.
1250 $DIC->database()->setLimit($number);
1251 $rset = $DIC->database()->query(
1252 'SELECT *
1253 FROM ' . self::$historyTable . '
1254 WHERE room_id = ' . $DIC->database()->quote($this->roomId, 'integer') . '
1255 AND sub_room = 0
1256 AND (
1257 (' . $DIC->database()->like('message', 'text', '%"type":"message"%') . ' AND NOT ' . $DIC->database()->like('message', 'text', '%"public":0%') . ')
1258 OR ' . $DIC->database()->like('message', 'text', '%"target":{%"id":"' . $chatuser->getUserId() . '"%') . '
1259 OR ' . $DIC->database()->like('message', 'text', '%"from":{"id":' . $chatuser->getUserId() . '%') . '
1260 )
1261 ORDER BY timestamp DESC'
1262 );
1263
1264 $result_count = 0;
1265 $results = [];
1266 while (($row = $DIC->database()->fetchAssoc($rset)) && $result_count < $number) {
1267 $tmp = json_decode($row['message'], false, 512, JSON_THROW_ON_ERROR);
1268 if (property_exists($tmp, 'target') && $tmp->target instanceof stdClass && (int) $tmp->target->public === 0) {
1269 if (in_array($chatuser->getUserId(), [(int) $tmp->target->id, (int) $tmp->from->id], true)) {
1270 $results[] = $tmp;
1271 ++$result_count;
1272 }
1273 } else {
1274 $results[] = $tmp;
1275 ++$result_count;
1276 }
1277 }
1278
1279 if ($results !== []) {
1280 $rset = $DIC->database()->queryF(
1281 'SELECT *
1282 FROM ' . self::$historyTable . '
1283 WHERE room_id = %s
1284 AND sub_room = 0
1285 AND ' . $DIC->database()->like('message', 'text', '%%"type":"notice"%%') . '
1286 AND timestamp <= %s AND timestamp >= %s
1287 ORDER BY timestamp DESC',
1288 ['integer', 'integer', 'integer'],
1289 [$this->roomId, $results[0]->timestamp, $results[$result_count - 1]->timestamp]
1290 );
1291
1292 while (($row = $DIC->database()->fetchAssoc($rset))) {
1293 $tmp = json_decode($row['message'], false, 512, JSON_THROW_ON_ERROR);
1294 $results[] = $tmp;
1295 }
1296 }
1297
1298 usort($results, static function (stdClass $a, stdClass $b): int {
1299 $a_timestamp = strlen((string) $a->timestamp) === 13 ? ((int) substr((string) $a->timestamp, 0, -3)) : $a->timestamp;
1300 $b_timestamp = strlen((string) $b->timestamp) === 13 ? ((int) substr((string) $b->timestamp, 0, -3)) : $b->timestamp;
1301
1302 return $b_timestamp - $a_timestamp;
1303 });
1304
1305 return $results;
1306 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$results

References Vendor\Package\$a, Vendor\Package\$b, $DIC, $results, ilChatroomUser\getUserId(), and ILIAS\Repository\int().

Referenced by ilChatroomViewGUI\showRoom().

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

◆ getLastSession()

ilChatroom::getLastSession ( ilChatroomUser  $user)

Definition at line 748 of file class.ilChatroom.php.

748 : ?array
749 {
750 global $DIC;
751
752 $query = 'SELECT * FROM ' . self::$sessionTable . ' WHERE user_id = ' .
753 $DIC->database()->quote($user->getUserId(), 'integer') .
754 ' ORDER BY connected DESC';
755
756 $DIC->database()->setLimit(1);
757 $res = $DIC->database()->query($query);
758
759 if ($row = $DIC->database()->fetchAssoc($res)) {
760 return $row;
761 }
762
763 return null;
764 }

References $DIC, $query, $res, and ilChatroomUser\getUserId().

+ Here is the call graph for this function:

◆ getPrivateRooms()

ilChatroom::getPrivateRooms ( )

Definition at line 1087 of file class.ilChatroom.php.

1087 : array
1088 {
1089 global $DIC;
1090
1091 $query = 'SELECT * FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s';
1092 $rset = $DIC->database()->queryF($query, ['integer'], [$this->roomId]);
1093
1094 $rooms = [];
1095 while ($row = $DIC->database()->fetchAssoc($rset)) {
1096 $rooms[] = $row;
1097 }
1098
1099 return $rooms;
1100 }

References $DIC, and $query.

◆ getPrivateRoomSessions()

ilChatroom::getPrivateRoomSessions ( ilDateTime  $from,
ilDateTime  $to,
int  $user_id,
int  $room_id 
)

Definition at line 624 of file class.ilChatroom.php.

629 : array {
630 global $DIC;
631
632 $query = 'SELECT proom_id, title FROM ' . self::$privateRoomsTable . ' WHERE proom_id IN (
633 SELECT proom_id FROM ' . self::$privateSessionsTable . ' WHERE connected >= %s AND disconnected <= %s AND user_id = %s
634 ) AND parent_id = %s';
635
636 $res = $DIC->database()->queryF(
637 $query,
638 ['integer', 'integer', 'integer', 'integer'],
639 [$from->getUnixTime(), $to->getUnixTime(), $user_id, $room_id]
640 );
641 $result = [];
642 while ($row = $DIC->database()->fetchAssoc($res)) {
643 $result[] = $row;
644 }
645
646 return $result;
647 }

◆ getPrivateSubRooms()

ilChatroom::getPrivateSubRooms ( int  $parent_room,
int  $user_id 
)
Parameters
int$parent_room
int$user_id
Returns
array<int, int>

Definition at line 1191 of file class.ilChatroom.php.

1191 : array
1192 {
1193 global $DIC;
1194
1195 $query = "
1196 SELECT proom_id, parent_id
1197 FROM " . self::$privateRoomsTable . "
1198 WHERE parent_id = %s
1199 AND owner = %s
1200 AND closed = 0
1201 ";
1202
1203 $types = ['integer', 'integer'];
1204 $values = [$parent_room, $user_id];
1205 $res = $DIC->database()->queryF($query, $types, $values);
1206
1207 $priv_rooms = [];
1208 while ($row = $DIC->database()->fetchAssoc($res)) {
1209 $proom_id = (int) $row['proom_id'];
1210 $priv_rooms[$proom_id] = (int) $row['parent_id'];
1211 }
1212
1213 return $priv_rooms;
1214 }

References $DIC, $query, $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getPrivilegedUsersForPrivateRoom()

ilChatroom::getPrivilegedUsersForPrivateRoom ( int  $subRoomId)
Parameters
int$subRoomId
Returns
int[]

Definition at line 1106 of file class.ilChatroom.php.

1106 : array
1107 {
1108 global $DIC;
1109
1110 $query = 'SELECT user_id FROM ' . self::$privateRoomsAccessTable . ' WHERE proom_id = %s';
1111 $rset = $DIC->database()->queryF($query, ['integer'], [$subRoomId]);
1112
1113 $userIds = [];
1114 while ($row = $DIC->database()->fetchAssoc($rset)) {
1115 $userIds[] = (int) $row['user_id'];
1116 }
1117
1118 return $userIds;
1119 }

References $DIC, $query, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRefIdByRoomId()

ilChatroom::getRefIdByRoomId ( int  $room_id)

Definition at line 1216 of file class.ilChatroom.php.

1216 : int
1217 {
1218 global $DIC;
1219
1220 $query = "
1221 SELECT objr.ref_id
1222 FROM object_reference objr
1223
1224 INNER JOIN chatroom_settings cs
1225 ON cs.object_id = objr.obj_id
1226
1227 INNER JOIN object_data od
1228 ON od.obj_id = cs.object_id
1229
1230 WHERE cs.room_id = %s
1231 ";
1232
1233 $types = ['integer'];
1234 $values = [$room_id];
1235
1236 $res = $DIC->database()->queryF($query, $types, $values);
1237
1238 $row = $DIC->database()->fetchAssoc($res);
1239
1240 return (int) ($row['ref_id'] ?? 0);
1241 }

References $DIC, $query, and $res.

◆ getRoomId()

ilChatroom::getRoomId ( )

Definition at line 619 of file class.ilChatroom.php.

619 : int
620 {
621 return $this->roomId;
622 }

Referenced by ilChatroomViewGUI\showRoom().

+ Here is the caller graph for this function:

◆ getSessions()

ilChatroom::getSessions ( ilChatroomUser  $user)

Definition at line 766 of file class.ilChatroom.php.

766 : array
767 {
768 global $DIC;
769
770 $query = 'SELECT * FROM ' . self::$sessionTable
771 . ' WHERE room_id = ' .
772 $DIC->database()->quote($this->getRoomId(), 'integer') .
773 ' ORDER BY connected DESC';
774
775 $res = $DIC->database()->query($query);
776
777 $result = [];
778 while ($row = $DIC->database()->fetchAssoc($res)) {
779 $result[] = $row;
780 }
781
782 return $result;
783 }

References $DIC, $query, and $res.

◆ getSetting()

ilChatroom::getSetting ( string  $name)

Definition at line 296 of file class.ilChatroom.php.

297 {
298 return $this->settings[$name];
299 }
if($format !==null) $name
Definition: metadata.php:247

References $name, and ILIAS\Repository\settings().

Referenced by disconnectUsers(), getDescription(), and ilChatroomViewGUI\showRoom().

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

◆ getSettings()

ilChatroom::getSettings ( )

Definition at line 498 of file class.ilChatroom.php.

498 : array
499 {
500 return $this->settings;
501 }

References $settings.

◆ getTitle()

ilChatroom::getTitle ( )

Definition at line 922 of file class.ilChatroom.php.

922 : string
923 {
924 if (!$this->object) {
925 $this->object = ilObjectFactory::getInstanceByObjId((int) $this->getSetting('object_id'));
926 }
927
928 return $this->object->getTitle();
929 }

References ilObjectFactory\getInstanceByObjId(), and ILIAS\LTI\ToolProvider\getSetting().

+ Here is the call graph for this function:

◆ getUniquePrivateRoomTitle()

ilChatroom::getUniquePrivateRoomTitle ( string  $title)

Definition at line 1121 of file class.ilChatroom.php.

1121 : string
1122 {
1123 global $DIC;
1124
1125 $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s and closed = 0';
1126 $rset = $DIC->database()->queryF($query, ['integer'], [$this->roomId]);
1127
1128 $titles = [];
1129 while ($row = $DIC->database()->fetchAssoc($rset)) {
1130 $titles[] = $row['title'];
1131 }
1132
1133 $suffix = '';
1134 $i = 0;
1135 do {
1136 if (!in_array($title . $suffix, $titles, true)) {
1137 $title .= $suffix;
1138 break;
1139 }
1140
1141 ++$i;
1142
1143 $suffix = ' (' . $i . ')';
1144 } while (true);
1145
1146 return $title;
1147 }
$i
Definition: metadata.php:41

References $DIC, $i, and $query.

◆ initialize()

ilChatroom::initialize ( array  $rowdata)

Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $this->availableSettings.

Parameters
array$rowdata

Definition at line 196 of file class.ilChatroom.php.

196 : void
197 {
198 $this->roomId = (int) $rowdata['room_id'];
199
200 foreach ($this->availableSettings as $setting => $type) {
201 if (isset($rowdata[$setting])) {
202 settype($rowdata[$setting], $this->availableSettings[$setting]);
203 $this->setSetting($setting, $rowdata[$setting]);
204 }
205 }
206 }
setSetting(string $name, $value)
Sets given name and value as setting into $this->settings array.
$type

References $type, ILIAS\Repository\int(), and setSetting().

+ Here is the call graph for this function:

◆ inviteUserToPrivateRoom()

ilChatroom::inviteUserToPrivateRoom ( int  $user_id,
int  $proom_id 
)

Definition at line 955 of file class.ilChatroom.php.

955 : void
956 {
957 global $DIC;
958
959 $DIC->database()->replace(
960 self::$privateRoomsAccessTable,
961 [
962 'user_id' => ['integer', $user_id],
963 'proom_id' => ['integer', $proom_id]
964 ],
965 []
966 );
967 }

References $DIC.

◆ inviteUserToPrivateRoomByLogin()

ilChatroom::inviteUserToPrivateRoomByLogin ( string  $login,
int  $proom_id 
)

Definition at line 947 of file class.ilChatroom.php.

947 : void
948 {
949 $user_id = (int) ilObjUser::_lookupId($login);
950 if ($user_id) {
951 $this->inviteUserToPrivateRoom($user_id, $proom_id);
952 }
953 }
inviteUserToPrivateRoom(int $user_id, int $proom_id)
static _lookupId($a_user_str)

References ilObjUser\_lookupId(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ isAllowedToEnterPrivateRoom()

ilChatroom::isAllowedToEnterPrivateRoom ( int  $chat_userid,
int  $proom_id 
)

Definition at line 517 of file class.ilChatroom.php.

517 : bool
518 {
519 global $DIC;
520
521 $query = 'SELECT COUNT(user_id) cnt FROM ' . self::$privateRoomsAccessTable .
522 ' WHERE proom_id = %s AND user_id = %s';
523
524 $types = ['integer', 'integer'];
525 $values = [$proom_id, $chat_userid];
526 $res = $DIC->database()->queryF($query, $types, $values);
527
528 if (($row = $DIC->database()->fetchAssoc($res)) && (int) $row['cnt'] === 1) {
529 return true;
530 }
531
532 $query = 'SELECT COUNT(*) cnt FROM ' . self::$privateRoomsTable .
533 ' WHERE proom_id = %s AND owner = %s';
534
535 $types = ['integer', 'integer'];
536 $values = [$proom_id, $chat_userid];
537 $res = $DIC->database()->queryF($query, $types, $values);
538
539 return ($row = $DIC->database()->fetchAssoc($res)) && (int) $row['cnt'] === 1;
540 }

References $DIC, $query, $res, and ILIAS\Repository\int().

Referenced by ilChatroomPrivateRoomGUI\exitIfEnterRoomIsNotAllowed(), and ilChatroomViewGUI\showRoom().

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

◆ isOwnerOfPrivateRoom()

ilChatroom::isOwnerOfPrivateRoom ( int  $user_id,
int  $proom_id 
)

Definition at line 817 of file class.ilChatroom.php.

817 : bool
818 {
819 global $DIC;
820
821 $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s AND owner = %s';
822 $types = ['integer', 'integer'];
823 $values = [$proom_id, $user_id];
824
825 $res = $DIC->database()->queryF($query, $types, $values);
826 if ($DIC->database()->fetchAssoc($res)) {
827 return true;
828 }
829
830 return false;
831 }

References $DIC, $query, and $res.

Referenced by ilChatroomGUIHandler\canModerate().

+ Here is the caller graph for this function:

◆ isSubscribed()

ilChatroom::isSubscribed ( int  $chat_userid)

Definition at line 503 of file class.ilChatroom.php.

503 : bool
504 {
505 global $DIC;
506
507 $query = 'SELECT COUNT(user_id) as cnt FROM ' . self::$userTable .
508 ' WHERE room_id = %s AND user_id = %s';
509
510 $types = ['integer', 'integer'];
511 $values = [$this->roomId, $chat_userid];
512 $res = $DIC->database()->queryF($query, $types, $values);
513
514 return ($row = $DIC->database()->fetchAssoc($res)) && (int) $row['cnt'] === 1;
515 }

References $DIC, $query, $res, $roomId, and ILIAS\Repository\int().

Referenced by ilChatroomPrivateRoomGUI\exitIfNoRoomSubscription(), and ilChatroomViewGUI\showRoom().

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

◆ isUserBanned()

ilChatroom::isUserBanned ( int  $user_id)

Definition at line 705 of file class.ilChatroom.php.

705 : bool
706 {
707 global $DIC;
708
709 $query = 'SELECT COUNT(user_id) cnt FROM ' . self::$banTable . ' WHERE user_id = %s AND room_id = %s';
710 $types = ['integer', 'integer'];
711 $values = [$user_id, $this->getRoomId()];
712
713 $res = $DIC->database()->queryF($query, $types, $values);
714
715 return ($row = $DIC->database()->fetchAssoc($res)) && $row['cnt'];
716 }

References $DIC, $query, and $res.

Referenced by ilChatroomViewGUI\showRoom().

+ Here is the caller graph for this function:

◆ listUsersInPrivateRoom()

ilChatroom::listUsersInPrivateRoom ( int  $private_room_id)
Parameters
int$private_room_id
Returns
int[]

Definition at line 999 of file class.ilChatroom.php.

999 : array
1000 {
1001 global $DIC;
1002
1003 $query = '
1004 SELECT chatroom_users.user_id FROM ' . self::$privateSessionsTable . '
1005 INNER JOIN chatroom_users
1006 ON chatroom_users.user_id = ' . self::$privateSessionsTable . ' .user_id WHERE proom_id = %s AND disconnected = 0
1007 ';
1008 $types = ['integer'];
1009 $values = [$private_room_id];
1010 $rset = $DIC->database()->queryF($query, $types, $values);
1011
1012 $users = [];
1013 while ($row = $DIC->database()->fetchAssoc($rset)) {
1014 $users[(int) $row['user_id']] = (int) $row['user_id'];
1015 }
1016
1017 return array_values($users);
1018 }

References $DIC, $query, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ lookupPrivateRoomTitle()

static ilChatroom::lookupPrivateRoomTitle ( int  $proom_id)
static

Definition at line 931 of file class.ilChatroom.php.

931 : string
932 {
933 global $DIC;
934
935 $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s';
936 $types = ['integer'];
937 $values = [$proom_id];
938
939 $rset = $DIC->database()->queryF($query, $types, $values);
940 if ($row = $DIC->database()->fetchAssoc($rset)) {
941 return $row['title'];
942 }
943
944 return 'unknown';
945 }

References $DIC, and $query.

Referenced by ilContactGUI\inviteToChat().

+ Here is the caller graph for this function:

◆ phpTypeToMDBType()

ilChatroom::phpTypeToMDBType ( string  $type)
private

Definition at line 343 of file class.ilChatroom.php.

343 : string
344 {
345 switch ($type) {
346 case 'string':
347 return 'text';
348
349 case 'boolean':
350 return 'integer';
351
352 default:
353 return $type;
354 }
355 }

References $type.

Referenced by saveSettings().

+ Here is the caller graph for this function:

◆ save()

ilChatroom::save ( )

Definition at line 301 of file class.ilChatroom.php.

301 : void
302 {
303 $this->saveSettings($this->settings);
304 }
saveSettings(array $settings)

References saveSettings(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ saveFileUploadToDb()

ilChatroom::saveFileUploadToDb ( int  $user_id,
string  $filename,
string  $type 
)

Definition at line 649 of file class.ilChatroom.php.

649 : void
650 {
651 global $DIC;
652
653 $upload_id = $DIC->database()->nextId(self::$uploadTable);
654 $DIC->database()->insert(
655 self::$uploadTable,
656 [
657 'upload_id' => ['integer', $upload_id],
658 'room_id' => ['integer', $this->roomId],
659 'user_id' => ['integer', $user_id],
660 'filename' => ['text', $filename],
661 'filetype' => ['text', $type],
662 'timestamp' => ['integer', time()]
663 ]
664 );
665 }
$filename
Definition: buildRTE.php:78

References $DIC, $filename, and $type.

◆ saveSettings()

ilChatroom::saveSettings ( array  $settings)

Definition at line 306 of file class.ilChatroom.php.

306 : void
307 {
308 global $DIC;
309
310 $localSettings = [];
311
312 foreach ($this->availableSettings as $setting => $type) {
313 if (isset($settings[$setting])) {
314 if ($type === 'boolean') {
315 $settings[$setting] = (bool) $settings[$setting];
316 }
317 $localSettings[$setting] = [$this->phpTypeToMDBType($type), $settings[$setting]];
318 }
319 }
320
321 if (!isset($localSettings['room_type']) || !$localSettings['room_type'][1]) {
322 $localSettings['room_type'][0] = 'text';
323 $localSettings['room_type'][1] = 'repository';
324 }
325
326 if ($this->roomId > 0) {
327 $DIC->database()->update(
328 self::$settingsTable,
329 $localSettings,
330 ['room_id' => ['integer', $this->roomId]]
331 );
332 } else {
333 $this->roomId = $DIC->database()->nextId(self::$settingsTable);
334
335 $localSettings['room_id'] = [
336 'integer', $this->roomId
337 ];
338
339 $DIC->database()->insert(self::$settingsTable, $localSettings);
340 }
341 }
phpTypeToMDBType(string $type)

References $DIC, $roomId, $settings, $type, and phpTypeToMDBType().

Referenced by save().

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

◆ setSetting()

ilChatroom::setSetting ( string  $name,
  $value 
)

Sets given name and value as setting into $this->settings array.

Parameters
string$name
mixed$value

Definition at line 213 of file class.ilChatroom.php.

213 : void
214 {
215 $this->settings[$name] = $value;
216 }

References $name, and ILIAS\Repository\settings().

Referenced by initialize().

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

◆ subscribeUserToPrivateRoom()

ilChatroom::subscribeUserToPrivateRoom ( int  $room_id,
int  $user_id 
)

Definition at line 1020 of file class.ilChatroom.php.

1020 : void
1021 {
1022 global $DIC;
1023
1024 if (!$this->userIsInPrivateRoom($room_id, $user_id)) {
1025 $id = $DIC->database()->nextId(self::$privateSessionsTable);
1026 $DIC->database()->insert(
1027 self::$privateSessionsTable,
1028 [
1029 'psess_id' => ['integer', $id],
1030 'proom_id' => ['integer', $room_id],
1031 'user_id' => ['integer', $user_id],
1032 'connected' => ['integer', time()],
1033 'disconnected' => ['integer', 0],
1034 ]
1035 );
1036 }
1037 }
userIsInPrivateRoom(int $room_id, int $user_id)

References $DIC, and $id.

Referenced by ilChatroomViewGUI\showRoom().

+ Here is the caller graph for this function:

◆ unbanUser()

ilChatroom::unbanUser (   $user_id)

Deletes entry from banTable matching roomId and given $user_id and returns the number of affected rows.

Parameters
int | int[]$user_id

Definition at line 690 of file class.ilChatroom.php.

690 : int
691 {
692 global $DIC;
693
694 if (!is_array($user_id)) {
695 $user_id = [$user_id];
696 }
697
698 $query = 'DELETE FROM ' . self::$banTable . ' WHERE room_id = %s AND ' . $DIC->database()->in('user_id', $user_id, false, 'integer');
699 $types = ['integer'];
700 $values = [$this->getRoomId()];
701
702 return $DIC->database()->manipulateF($query, $types, $values);
703 }

References $DIC, and $query.

◆ unsubscribeUserFromPrivateRoom()

ilChatroom::unsubscribeUserFromPrivateRoom ( int  $room_id,
int  $user_id 
)

Definition at line 1055 of file class.ilChatroom.php.

1055 : void
1056 {
1057 global $DIC;
1058
1059 $DIC->database()->update(
1060 self::$privateSessionsTable,
1061 [
1062 'disconnected' => ['integer', time()]
1063 ],
1064 [
1065 'proom_id' => ['integer', $room_id],
1066 'user_id' => ['integer', $user_id]
1067 ]
1068 );
1069 }

References $DIC.

◆ userIsInPrivateRoom()

ilChatroom::userIsInPrivateRoom ( int  $room_id,
int  $user_id 
)

Definition at line 1039 of file class.ilChatroom.php.

1039 : bool
1040 {
1041 global $DIC;
1042
1043 $query = 'SELECT proom_id id FROM ' . self::$privateSessionsTable .
1044 ' WHERE user_id = %s AND proom_id = %s AND disconnected = 0';
1045 $types = ['integer', 'integer'];
1046 $values = [$user_id, $room_id];
1047 $rset = $DIC->database()->queryF($query, $types, $values);
1048 if ($DIC->database()->fetchAssoc($rset)) {
1049 return true;
1050 }
1051
1052 return false;
1053 }

References $DIC, and $query.

Field Documentation

◆ $availableSettings

array ilChatroom::$availableSettings
private
Initial value:
= [
'object_id' => 'integer',
'online_status' => 'boolean',
'allow_anonymous' => 'boolean',
'allow_custom_usernames' => 'boolean',
'enable_history' => 'boolean',
'restrict_history' => 'boolean',
'autogen_usernames' => 'string',
'room_type' => 'string',
'allow_private_rooms' => 'boolean',
'display_past_msgs' => 'integer',
'private_rooms_enabled' => 'boolean'
]

Definition at line 52 of file class.ilChatroom.php.

◆ $banTable

string ilChatroom::$banTable = 'chatroom_bans'
staticprivate

Definition at line 40 of file class.ilChatroom.php.

◆ $historyTable

string ilChatroom::$historyTable = 'chatroom_history'
staticprivate

Definition at line 37 of file class.ilChatroom.php.

◆ $object

ilObjChatroom ilChatroom::$object = null
private

Definition at line 66 of file class.ilChatroom.php.

◆ $privateRoomsAccessTable

string ilChatroom::$privateRoomsAccessTable = 'chatroom_proomaccess'
staticprivate

Definition at line 44 of file class.ilChatroom.php.

◆ $privateRoomsTable

string ilChatroom::$privateRoomsTable = 'chatroom_prooms'
staticprivate

Definition at line 41 of file class.ilChatroom.php.

◆ $privateSessionsTable

string ilChatroom::$privateSessionsTable = 'chatroom_psessions'
staticprivate

Definition at line 42 of file class.ilChatroom.php.

◆ $roomId

int ilChatroom::$roomId = 0
private

◆ $sessionTable

string ilChatroom::$sessionTable = 'chatroom_sessions'
staticprivate

Definition at line 39 of file class.ilChatroom.php.

◆ $settings

array ilChatroom::$settings = []
private

Definition at line 45 of file class.ilChatroom.php.

Referenced by getSettings(), and saveSettings().

◆ $settingsTable

string ilChatroom::$settingsTable = 'chatroom_settings'
staticprivate

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

◆ $uploadTable

string ilChatroom::$uploadTable = 'chatroom_uploads'
staticprivate

Definition at line 43 of file class.ilChatroom.php.

◆ $userTable

string ilChatroom::$userTable = 'chatroom_users'
staticprivate

Definition at line 38 of file class.ilChatroom.php.

◆ ROOM_INVITATION

const ilChatroom::ROOM_INVITATION = 'invitation_to_room'

Definition at line 35 of file class.ilChatroom.php.


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