19 declare(strict_types=1);
53 'object_id' =>
'integer',
54 'online_status' =>
'boolean',
55 'allow_anonymous' =>
'boolean',
56 'allow_custom_usernames' =>
'boolean',
57 'enable_history' =>
'boolean',
58 'restrict_history' =>
'boolean',
59 'autogen_usernames' =>
'string',
60 'room_type' =>
'string',
61 'allow_private_rooms' =>
'boolean',
62 'display_past_msgs' =>
'integer',
63 'private_rooms_enabled' =>
'boolean' 78 $main_tpl = $DIC->ui()->mainTemplate();
80 if (!is_array($permissions)) {
81 $permissions = [$permissions];
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);
91 return $hasPermissions;
104 if (!is_array($permissions)) {
105 $permissions = [$permissions];
108 return self::checkPermissions($usr_id, $ref_id, $permissions);
123 foreach ($permissions as $permission) {
124 if ($pub_ref_id === $refId) {
125 $hasAccess = $DIC->rbac()->system()->checkAccessOfUser($usrId, $permission, $refId);
127 $hasWritePermission = $DIC->rbac()->system()->checkAccessOfUser($usrId,
'write', $refId);
128 if ($hasWritePermission) {
136 switch ($permission) {
139 $DIC->access()->addInfoItem(
141 $DIC->language()->txt(
'offline')
145 if (!$active && !$visible) {
152 $DIC->access()->addInfoItem(
154 $DIC->language()->txt(
'offline')
162 $hasAccess = $DIC->access()->checkAccessOfUser($usrId, $permission,
'', $refId);
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);
182 if ($row = $DIC->database()->fetchAssoc($rset)) {
184 $room->initialize($row);
198 $this->roomId = (
int) $rowdata[
'room_id'];
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]);
222 $query =
'SELECT * FROM ' . self::$settingsTable .
' WHERE room_id = %s';
224 $types = [
'integer'];
225 $values = [$room_id];
227 $rset = $DIC->database()->queryF(
$query, $types, $values);
229 if ($row = $DIC->database()->fetchAssoc($rset)) {
231 $room->initialize($row);
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 256 GROUP BY private_rooms.proom_id 257 HAVING MIN(disconnected) > 0 AND MAX(disconnected) < %s';
258 $rset = $DIC->database()->queryF(
266 while ($row = $DIC->database()->fetchAssoc($rset)) {
267 $rooms[$row[
'id']] = $row[
'id'];
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');
274 $rset = $DIC->database()->query(
$query);
276 while ($row = $DIC->database()->fetchAssoc($rset)) {
278 'proom_id' => (
int) $row[
'proom_id'],
279 'room_id' => (
int) $row[
'room_id'],
280 'object_id' => (
int) $row[
'object_id']
289 if (!$this->
object) {
293 return $this->
object->getDescription();
312 foreach ($this->availableSettings as $setting =>
$type) {
313 if (isset($settings[$setting])) {
314 if (
$type ===
'boolean') {
315 $settings[$setting] = (bool) $settings[$setting];
321 if (!isset($localSettings[
'room_type']) || !$localSettings[
'room_type'][1]) {
322 $localSettings[
'room_type'][0] =
'text';
323 $localSettings[
'room_type'][1] =
'repository';
326 if ($this->roomId > 0) {
327 $DIC->database()->update(
328 self::$settingsTable,
330 [
'room_id' => [
'integer', $this->roomId]]
333 $this->roomId = $DIC->database()->nextId(self::$settingsTable);
335 $localSettings[
'room_id'] = [
339 $DIC->database()->insert(self::$settingsTable, $localSettings);
374 $id = $DIC->database()->nextId(self::$historyTable);
375 $DIC->database()->insert(
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)],
396 $query =
'SELECT user_id FROM ' . self::$userTable .
' WHERE room_id = %s AND user_id = %s';
397 $types = [
'integer',
'integer'];
400 if (!$DIC->database()->fetchAssoc($DIC->database()->queryF(
$query, $types, $values))) {
403 $DIC->database()->replace(
406 'room_id' => [
'integer', $this->roomId],
407 'user_id' => [
'integer', $user->
getUserId()]
410 'userdata' => [
'text', json_encode($userdata, JSON_THROW_ON_ERROR)],
411 'connected' => [
'integer', time()],
425 $query =
'SELECT ' . ($only_data ?
'userdata' :
'*') .
' FROM ' . self::$userTable .
' WHERE room_id = %s';
426 $types = [
'integer'];
428 $rset = $DIC->database()->queryF(
$query, $types, $values);
431 while ($row = $DIC->database()->fetchAssoc($rset)) {
432 $users[] = $only_data ? json_decode($row[
'userdata'],
false, 512, JSON_THROW_ON_ERROR) : $row;
450 $query =
'SELECT * FROM ' . self::$userTable .
' WHERE room_id = %s AND ' .
451 $DIC->database()->in(
'user_id', $userIds,
false,
'integer');
453 $types = [
'integer'];
455 $res = $DIC->database()->queryF(
$query, $types, $values);
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]);
463 while ($row_prooms = $DIC->database()->fetchAssoc($rset_prooms)) {
464 $prooms[] = $row_prooms[
'proom_id'];
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()]);
472 $query =
'DELETE FROM ' . self::$userTable .
' WHERE room_id = %s AND ' .
473 $DIC->database()->in(
'user_id', $userIds,
false,
'integer');
475 $types = [
'integer'];
477 $DIC->database()->manipulateF(
$query, $types, $values);
481 $id = $DIC->database()->nextId(self::$sessionTable);
482 $DIC->database()->insert(
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()]
494 }
while ($row = $DIC->database()->fetchAssoc(
$res));
507 $query =
'SELECT COUNT(user_id) as cnt FROM ' . self::$userTable .
508 ' WHERE room_id = %s AND user_id = %s';
510 $types = [
'integer',
'integer'];
512 $res = $DIC->database()->queryF(
$query, $types, $values);
514 return ($row = $DIC->database()->fetchAssoc(
$res)) && (
int) $row[
'cnt'] === 1;
521 $query =
'SELECT COUNT(user_id) cnt FROM ' . self::$privateRoomsAccessTable .
522 ' WHERE proom_id = %s AND user_id = %s';
524 $types = [
'integer',
'integer'];
525 $values = [$proom_id, $chat_userid];
526 $res = $DIC->database()->queryF(
$query, $types, $values);
528 if (($row = $DIC->database()->fetchAssoc(
$res)) && (
int) $row[
'cnt'] === 1) {
532 $query =
'SELECT COUNT(*) cnt FROM ' . self::$privateRoomsTable .
533 ' WHERE proom_id = %s AND owner = %s';
535 $types = [
'integer',
'integer'];
536 $values = [$proom_id, $chat_userid];
537 $res = $DIC->database()->queryF(
$query, $types, $values);
539 return ($row = $DIC->database()->fetchAssoc(
$res)) && (
int) $row[
'cnt'] === 1;
545 int $restricted_session_userid = null,
547 bool $respect_target =
true 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 ';
563 'SELECT historyTable.* ' .
564 'FROM ' . self::$historyTable .
' historyTable ' . $join .
' ' .
565 'WHERE historyTable.room_id = ' . $this->
getRoomId();
567 if ($proom_id !== null) {
568 $query .=
' AND historyTable.sub_room = ' . $DIC->database()->quote($proom_id,
'integer');
573 if ($from !== null) {
574 $filter[] =
'timestamp >= ' . $DIC->database()->quote($from->getUnixTime(),
'integer');
578 $filter[] =
'timestamp <= ' . $DIC->database()->quote($to->getUnixTime(),
'integer');
582 $query .=
' AND ' . implode(
' AND ', $filter);
584 $query .=
' ORDER BY timestamp ASC';
586 $rset = $DIC->database()->query(
$query);
589 while ($row = $DIC->database()->fetchAssoc($rset)) {
591 $message = json_decode($row[
'message'],
false, 512, JSON_THROW_ON_ERROR);
596 $message = json_decode(
'{}',
false, 512, JSON_THROW_ON_ERROR);
601 $row[
'message']->timestamp = $row[
'timestamp'];
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)
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';
636 $res = $DIC->database()->queryF(
638 [
'integer',
'integer',
'integer',
'integer'],
642 while ($row = $DIC->database()->fetchAssoc(
$res)) {
653 $upload_id = $DIC->database()->nextId(self::$uploadTable);
654 $DIC->database()->insert(
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()]
671 $DIC->database()->replace(
674 'room_id' => [
'integer', $this->roomId],
675 'user_id' => [
'integer', $user_id]
678 'actor_id' => [
'integer', $actor_id],
679 'timestamp' => [
'integer', time()],
694 if (!is_array($user_id)) {
695 $user_id = [$user_id];
698 $query =
'DELETE FROM ' . self::$banTable .
' WHERE room_id = %s AND ' . $DIC->database()->in(
'user_id', $user_id,
false,
'integer');
699 $types = [
'integer'];
702 return $DIC->database()->manipulateF(
$query, $types, $values);
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()];
713 $res = $DIC->database()->queryF(
$query, $types, $values);
715 return ($row = $DIC->database()->fetchAssoc(
$res)) && $row[
'cnt'];
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'];
725 $res = $DIC->database()->queryF(
$query, $types, $values);
728 while ($row = $DIC->database()->fetchAssoc(
$res)) {
729 if ($row[
'user_id'] > 0) {
730 $user =
new ilObjUser((
int) $row[
'user_id']);
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']
741 $result[] = $userdata;
752 $query =
'SELECT * FROM ' . self::$sessionTable .
' WHERE user_id = ' .
753 $DIC->database()->quote($user->
getUserId(),
'integer') .
754 ' ORDER BY connected DESC';
756 $DIC->database()->setLimit(1);
759 if ($row = $DIC->database()->fetchAssoc(
$res)) {
770 $query =
'SELECT * FROM ' . self::$sessionTable
771 .
' WHERE room_id = ' .
772 $DIC->database()->quote($this->
getRoomId(),
'integer') .
773 ' ORDER BY connected DESC';
778 while ($row = $DIC->database()->fetchAssoc(
$res)) {
789 $nextId = $DIC->database()->nextId(self::$privateRoomsTable);
790 $DIC->database()->insert(
791 self::$privateRoomsTable,
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']],
810 $DIC->database()->manipulateF(
811 'UPDATE ' . self::$privateRoomsTable .
' SET closed = %s WHERE proom_id = %s',
812 [
'integer',
'integer'],
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];
825 $res = $DIC->database()->queryF(
$query, $types, $values);
826 if ($DIC->database()->fetchAssoc(
$res)) {
841 public function sendInvitationNotification(
846 string $invitationLink =
'' 850 if ($gui && $invitationLink ===
'') {
851 $invitationLink = $this->
getChatURL($gui, $subScope);
860 if (is_numeric($sender) && $sender > 0) {
861 $sender_id = $sender;
864 $public_name = $usr->getPublicName();
866 if ($sender->getUserId() > 0) {
867 $sender_id = $sender->getUserId();
871 $public_name = $sender->getUsername();
874 '$sender must be an instance of ilChatroomUser or an id of an ilObjUser instance' 879 $userLang->loadLanguageModule(
'mail');
881 'link' => $invitationLink,
882 'inviter_name' => $public_name,
889 $bodyParams[
'room_name'] .=
' - ' . self::lookupPrivateRoomTitle($subScope);
892 $notification =
new ilNotificationConfig(ChatInvitationNotificationProvider::NOTIFICATION_TYPE);
893 $notification->setTitleVar(
'chat_invitation', $bodyParams,
'chatroom');
894 $notification->setShortDescriptionVar(
'chat_invitation_short', $bodyParams,
'chatroom');
895 $notification->setLongDescriptionVar(
'chat_invitation_long', $bodyParams,
'chatroom');
896 $notification->setLinks($links);
897 $notification->setIconPath(
'templates/default/images/icon_chtr.svg');
898 $notification->setValidForSeconds(ilNotificationConfig::TTL_LONG);
899 $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
901 ChatInvitationNotificationProvider::NOTIFICATION_TYPE,
904 $notification->setHandlerParam(
'mail.sender', (
string) $sender_id);
906 $notification->notifyByUsers([$recipient_id]);
924 if (!$this->
object) {
928 return $this->
object->getTitle();
935 $query =
'SELECT title FROM ' . self::$privateRoomsTable .
' WHERE proom_id = %s';
936 $types = [
'integer'];
937 $values = [$proom_id];
939 $rset = $DIC->database()->queryF(
$query, $types, $values);
940 if ($row = $DIC->database()->fetchAssoc($rset)) {
941 return $row[
'title'];
959 $DIC->database()->replace(
960 self::$privateRoomsAccessTable,
962 'user_id' => [
'integer', $user_id],
963 'proom_id' => [
'integer', $proom_id]
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 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'];
984 $rset = $DIC->database()->queryF(
$query, $types, $values);
986 while ($row = $DIC->database()->fetchAssoc($rset)) {
988 $row[
'owner'] = $row[
'rowner'];
989 $rooms[$row[
'proom_id']] = $row;
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 1008 $types = [
'integer'];
1009 $values = [$private_room_id];
1010 $rset = $DIC->database()->queryF(
$query, $types, $values);
1013 while ($row = $DIC->database()->fetchAssoc($rset)) {
1014 $users[(
int) $row[
'user_id']] = (
int) $row[
'user_id'];
1017 return array_values($users);
1025 $id = $DIC->database()->nextId(self::$privateSessionsTable);
1026 $DIC->database()->insert(
1027 self::$privateSessionsTable,
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],
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)) {
1059 $DIC->database()->update(
1060 self::$privateSessionsTable,
1062 'disconnected' => [
'integer', time()]
1065 'proom_id' => [
'integer', $room_id],
1066 'user_id' => [
'integer', $user_id]
1075 $query =
'SELECT COUNT(user_id) cnt FROM ' . self::$userTable .
' WHERE room_id = %s';
1076 $types = [
'integer'];
1078 $res = $DIC->database()->queryF(
$query, $types, $values);
1080 if ($row = $DIC->database()->fetchAssoc(
$res)) {
1081 return (
int) $row[
'cnt'];
1091 $query =
'SELECT * FROM ' . self::$privateRoomsTable .
' WHERE parent_id = %s';
1092 $rset = $DIC->database()->queryF(
$query, [
'integer'], [$this->roomId]);
1095 while ($row = $DIC->database()->fetchAssoc($rset)) {
1110 $query =
'SELECT user_id FROM ' . self::$privateRoomsAccessTable .
' WHERE proom_id = %s';
1111 $rset = $DIC->database()->queryF(
$query, [
'integer'], [$subRoomId]);
1114 while ($row = $DIC->database()->fetchAssoc($rset)) {
1115 $userIds[] = (
int) $row[
'user_id'];
1125 $query =
'SELECT title FROM ' . self::$privateRoomsTable .
' WHERE parent_id = %s and closed = 0';
1126 $rset = $DIC->database()->queryF(
$query, [
'integer'], [$this->roomId]);
1129 while ($row = $DIC->database()->fetchAssoc($rset)) {
1130 $titles[] = $row[
'title'];
1136 if (!in_array($title . $suffix, $titles,
true)) {
1143 $suffix =
' (' .
$i .
')';
1159 SELECT room_id, od.title, objr.ref_id 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 1167 ON tree.child = objr.ref_id 1172 $types = [
'integer',
'text'];
1173 $values = [1,
'chtr'];
1174 $res = $DIC->database()->queryF(
$query, $types, $values);
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'];
1196 SELECT proom_id, parent_id 1197 FROM " . self::$privateRoomsTable .
" 1198 WHERE parent_id = %s 1203 $types = [
'integer',
'integer'];
1204 $values = [$parent_room, $user_id];
1205 $res = $DIC->database()->queryF(
$query, $types, $values);
1208 while ($row = $DIC->database()->fetchAssoc(
$res)) {
1209 $proom_id = (
int) $row[
'proom_id'];
1210 $priv_rooms[$proom_id] = (
int) $row[
'parent_id'];
1222 FROM object_reference objr 1224 INNER JOIN chatroom_settings cs 1225 ON cs.object_id = objr.obj_id 1227 INNER JOIN object_data od 1228 ON od.obj_id = cs.object_id 1230 WHERE cs.room_id = %s 1233 $types = [
'integer'];
1234 $values = [$room_id];
1236 $res = $DIC->database()->queryF(
$query, $types, $values);
1238 $row = $DIC->database()->fetchAssoc(
$res);
1240 return (
int) ($row[
'ref_id'] ?? 0);
1250 $DIC->database()->setLimit($number);
1251 $rset = $DIC->database()->query(
1253 FROM ' . self::$historyTable .
' 1254 WHERE room_id = ' . $DIC->database()->quote($this->roomId,
'integer') .
' 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() .
'%') .
' 1261 ORDER BY timestamp DESC' 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)) {
1280 $rset = $DIC->database()->queryF(
1282 FROM ' . self::$historyTable .
' 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'],
1292 while (($row = $DIC->database()->fetchAssoc($rset))) {
1293 $tmp = json_decode($row[
'message'],
false, 512, JSON_THROW_ON_ERROR);
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;
1302 return $b_timestamp - $a_timestamp;
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]
1319 $DIC->database()->queryF(
1320 'DELETE FROM ' . self::$privateSessionsTable .
' WHERE proom_id = %s AND disconnected < %s',
1321 [
'integer',
'integer'],
1325 $DIC->database()->queryF(
1326 'DELETE FROM ' . self::$sessionTable .
' WHERE room_id = %s AND disconnected < %s',
1327 [
'integer',
'integer'],
1328 [$this->roomId, time()]
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
static string $privateSessionsTable
const IL_NO_OBJECT_ACCESS
getPrivateRoomSessions(ilDateTime $from, ilDateTime $to, int $user_id, int $room_id)
getPrivilegedUsersForPrivateRoom(int $subRoomId)
getUserId()
Returns Ilias User ID.
description of a localized parameter this information is used locate translations while processing no...
getRefIdByRoomId(int $room_id)
banUser(int $user_id, int $actor_id, string $comment='')
getLastSession(ilChatroomUser $user)
static lookupPrivateRoomTitle(int $proom_id)
getLastMessages(int $number, ilChatroomUser $chatuser)
disconnectUsers(array $userIds)
getPrivateSubRooms(int $parent_room, int $user_id)
static _lookupId($a_user_str)
static string $historyTable
getConnectedUsers(bool $only_data=true)
inviteUserToPrivateRoomByLogin(string $login, int $proom_id)
phpTypeToMDBType(string $type)
setSetting(string $name, $value)
Sets given name and value as setting into $this->settings array.
static _lookupObjId(int $ref_id)
saveFileUploadToDb(int $user_id, string $filename, string $type)
getHistory(ilDateTime $from=null, ilDateTime $to=null, int $restricted_session_userid=null, ?int $proom_id=0, bool $respect_target=true)
static string $settingsTable
clearMessages(int $sub_room)
addHistoryEntry($message)
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.
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
static isActivated(int $refId, int $objId, bool &$a_visible_flag=null)
isSubscribed(int $chat_userid)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
getSessions(ilChatroomUser $user)
static findDeletablePrivateRooms()
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
Get static link.
addPrivateRoom(string $title, ilChatroomUser $owner, array $settings)
isUserBanned(int $user_id)
static string $privateRoomsTable
listUsersInPrivateRoom(int $private_room_id)
static byRoomId(int $room_id, bool $initObject=false)
getChatURL(ilChatroomObjectGUI $gui, int $scope_id=0)
static string $privateRoomsAccessTable
closePrivateRoom(int $id)
unbanUser($user_id)
Deletes entry from banTable matching roomId and given $user_id and returns the number of affected row...
connectUser(ilChatroomUser $user)
getUniquePrivateRoomTitle(string $title)
inviteUserToPrivateRoom(int $user_id, int $proom_id)
isAllowedToEnterPrivateRoom(int $chat_userid, int $proom_id)
foreach($mandatory_scripts as $file) $timestamp
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static byObjectId(int $object_id)
disconnectUser(int $user_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
isOwnerOfPrivateRoom(int $user_id, int $proom_id)
static string $sessionTable
getUsername()
Returns username from Object or SESSION.
unsubscribeUserFromPrivateRoom(int $room_id, int $user_id)
getAccessibleRoomIdByTitleMap(int $user_id)
Fetches and returns a Array<Integer, String> of all accessible repository object chats in the main tr...
subscribeUserToPrivateRoom(int $room_id, int $user_id)
initialize(array $rowdata)
Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $...
userIsInPrivateRoom(int $room_id, int $user_id)
saveSettings(array $settings)
static checkPermissions(int $usrId, int $refId, array $permissions)
getActivePrivateRooms(int $userid)
static string $uploadTable