29 'object_id' =>
'integer',
30 'online_status' =>
'integer',
31 'allow_anonymous' =>
'boolean',
32 'allow_custom_usernames' =>
'boolean',
33 'enable_history' =>
'boolean',
34 'restrict_history' =>
'boolean',
35 'autogen_usernames' =>
'string',
36 'room_type' =>
'string',
37 'allow_private_rooms' =>
'integer',
38 'display_past_msgs' =>
'integer',
39 'private_rooms_enabled' =>
'boolean' 56 if (!is_array($permissions)) {
57 $permissions = array($permissions);
60 $hasPermissions = self::checkPermissions($DIC->user()->getId(), $ref_id, $permissions);
61 if (!$hasPermissions && $send_info) {
67 return $hasPermissions;
80 if (!is_array($permissions)) {
81 $permissions = array($permissions);
84 return self::checkPermissions($usr_id, $ref_id, $permissions);
97 require_once
'Modules/Chatroom/classes/class.ilObjChatroom.php';
100 foreach ($permissions as $permission) {
101 if ($pub_ref_id == $refId) {
102 $hasAccess = $DIC->rbac()->system()->checkAccessOfUser($usrId, $permission, $refId);
104 $hasWritePermission = $DIC->rbac()->system()->checkAccessOfUser($usrId,
'write', $refId);
105 if ($hasWritePermission) {
113 switch ($permission) {
119 if (!$active && !$visible) {
133 $hasAccess = $DIC->access()->checkAccessOfUser($usrId, $permission,
'', $refId);
153 $query =
'SELECT * FROM ' . self::$settingsTable .
' WHERE object_id = %s';
154 $types = array(
'integer');
158 if (
$row = $DIC->database()->fetchAssoc($rset)) {
160 $room->initialize(
$row);
172 $this->roomId = $rowdata[
'room_id'];
174 foreach ($this->availableSettings as $setting =>
$type) {
175 if (isset($rowdata[$setting])) {
176 settype($rowdata[$setting], $this->availableSettings[$setting]);
177 $this->
setSetting($setting, $rowdata[$setting]);
197 public static function byRoomId($room_id, $initObject =
false)
201 $query =
'SELECT * FROM ' . self::$settingsTable .
' WHERE room_id = %s';
203 $types = array(
'integer');
208 if (
$row = $DIC->database()->fetchAssoc($rset)) {
210 $room->initialize(
$row);
227 $DIC->database()->manipulate(
'DELETE FROM ' . self::$userTable);
228 $DIC->database()->manipulate(
'UPDATE ' . self::$privateRoomsTable .
' SET closed = ' . $DIC->database()->quote(time(),
'integer') .
' WHERE closed = 0 OR closed IS NULL');
229 $DIC->database()->manipulate(
'UPDATE ' . self::$privateSessionsTable .
' SET disconnected = ' . $DIC->database()->quote(time(),
'integer') .
' WHERE disconnected = 0');
240 SELECT private_rooms.proom_id id, MIN(disconnected) min_disconnected, MAX(disconnected) max_disconnected 241 FROM ' . self::$privateSessionsTable .
' private_sessions 242 INNER JOIN ' . self::$privateRoomsTable .
' private_rooms 243 ON private_sessions.proom_id = private_rooms.proom_id 245 GROUP BY private_rooms.proom_id 246 HAVING MIN(disconnected) > 0 AND MAX(disconnected) < %s';
247 $rset = $DIC->database()->queryF(
250 array(time() + 60 * 5)
255 while (
$row = $DIC->database()->fetchAssoc($rset)) {
256 $rooms[
$row[
'id']] = $row[
'id'];
259 $query =
'SELECT DISTINCT proom_id, room_id, object_id FROM ' . self::$privateRoomsTable
260 .
' INNER JOIN ' . self::$settingsTable .
' ON parent_id = room_id ' 261 .
' WHERE ' . $DIC->database()->in(
'proom_id', $rooms,
false,
'integer');
263 $rset = $DIC->database()->query(
$query);
265 while (
$row = $DIC->database()->fetchAssoc($rset)) {
267 'proom_id' =>
$row[
'proom_id'],
268 'room_id' =>
$row[
'room_id'],
269 'object_id' =>
$row[
'object_id']
283 SELECT od.obj_id, od.title, ore.ref_id, od.type, odp.title parent_title 285 INNER JOIN object_reference ore ON ore.obj_id = od.obj_id 286 INNER JOIN tree t ON t.child = ore.ref_id 287 INNER JOIN tree p ON p.child = t.parent 288 INNER JOIN object_reference orep ON orep.ref_id = p.child 289 INNER JOIN object_data odp ON odp.obj_id = orep.obj_id 290 INNER JOIN object_reference pre ON pre.ref_id = t.parent 291 INNER JOIN object_data pod ON pod.obj_id = pre.obj_id 294 if (isset($filter[
'last_activity'])) {
295 $threshold = $DIC->database()->quote($filter[
'last_activity'],
'integer');
297 INNER JOIN chatroom_settings ON chatroom_settings.object_id = od.obj_id 298 INNER JOIN chatroom_history ON chatroom_history.room_id = chatroom_settings.room_id AND chatroom_history.timestamp > $threshold 303 WHERE od.type = %s AND t.tree > 0 AND ore.deleted IS NULL 304 GROUP BY od.obj_id, od.title, ore.ref_id, od.type, odp.title 307 $res = $DIC->database()->queryF(
$query, array(
'text'), array(
'chtr'));
310 while (
$row = $DIC->database()->fetchAssoc(
$res)) {
319 if (!$this->
object) {
323 return $this->
object->getDescription();
352 $localSettings = array();
354 foreach ($this->availableSettings as $setting =>
$type) {
355 if (isset($settings[$setting])) {
356 if (
$type ==
'boolean') {
357 $settings[$setting] = (boolean) $settings[$setting];
363 if (!$localSettings[
'room_type'][1]) {
364 $localSettings[
'room_type'][1] =
'repository';
368 $DIC->database()->update(
369 self::$settingsTable,
371 array(
'room_id' => array(
'integer', $this->roomId))
374 $this->roomId = $DIC->database()->nextId(self::$settingsTable);
376 $localSettings[
'room_id'] = array(
377 $this->availableSettings[
'room_id'], $this->roomId
380 $DIC->database()->insert(self::$settingsTable, $localSettings);
415 $id = $DIC->database()->nextId(self::$historyTable);
416 $DIC->database()->insert(
419 'hist_id' => array(
'integer',
$id),
420 'room_id' => array(
'integer', $this->roomId),
421 'sub_room' => array(
'integer', $subRoom),
422 'message' => array(
'text', json_encode(
$message)),
446 $query =
'SELECT user_id FROM ' . self::$userTable .
' WHERE room_id = %s AND user_id = %s';
447 $types = array(
'integer',
'integer');
450 if (!$DIC->database()->fetchAssoc($DIC->database()->queryF($query, $types,
$values))) {
453 $DIC->database()->replace(
456 'room_id' => array(
'integer', $this->roomId),
457 'user_id' => array(
'integer', $user->
getUserId())
460 'userdata' => array(
'text', json_encode($userdata)),
461 'connected' => array(
'integer', time()),
482 $query =
'SELECT ' . ($only_data ?
'userdata' :
'*') .
' FROM ' . self::$userTable .
' WHERE room_id = %s';
483 $types = array(
'integer');
484 $values = array($this->roomId);
488 while (
$row = $DIC->database()->fetchAssoc($rset)) {
515 $query =
'SELECT * FROM ' . self::$userTable .
' WHERE room_id = %s AND ' .
516 $DIC->database()->in(
'user_id', $userIds,
false,
'integer');
518 $types = array(
'integer');
519 $values = array($this->roomId);
522 if (
$row = $DIC->database()->fetchAssoc($rset)) {
523 $query =
'SELECT proom_id FROM ' . self::$privateRoomsTable .
' WHERE parent_id = %s';
524 $rset_prooms = $DIC->database()->queryF(
$query, array(
'integer'), array($this->roomId));
528 while ($row_prooms = $DIC->database()->fetchAssoc($rset_prooms)) {
529 $prooms[] = $row_prooms[
'proom_id'];
532 if (
true || $this->
getSetting(
'enable_history')) {
533 $query =
'UPDATE ' . self::$privateSessionsTable .
' SET disconnected = %s WHERE ' . $DIC->database()->in(
'user_id', $userIds,
false,
'integer') .
' AND ' . $DIC->database()->in(
'proom_id', $prooms,
false,
'integer');
534 $DIC->database()->manipulateF(
$query, array(
'integer'), array(time()));
536 $query =
'DELETE FROM ' . self::$privateSessionsTable .
' WHERE ' . $DIC->database()->in(
'user_id', $userIds,
false,
'integer') .
' AND ' . $DIC->database()->in(
'proom_id', $prooms,
false,
'integer');
537 $DIC->database()->manipulate(
$query);
540 $query =
'DELETE FROM ' . self::$userTable .
' WHERE room_id = %s AND ' .
541 $DIC->database()->in(
'user_id', $userIds,
false,
'integer');
543 $types = array(
'integer');
544 $values = array($this->roomId);
549 $id = $DIC->database()->nextId(self::$sessionTable);
550 $DIC->database()->insert(
553 'sess_id' => array(
'integer',
$id),
554 'room_id' => array(
'integer', $this->roomId),
555 'user_id' => array(
'integer',
$row[
'user_id']),
556 'userdata' => array(
'text',
$row[
'userdata']),
557 'connected' => array(
'integer',
$row[
'connected']),
558 'disconnected' => array(
'integer', time())
562 }
while (
$row = $DIC->database()->fetchAssoc($rset));
585 $query =
'SELECT count(user_id) as cnt FROM ' . self::$userTable .
586 ' WHERE room_id = %s AND user_id = %s';
588 $types = array(
'integer',
'integer');
589 $values = array($this->roomId, $chat_userid);
592 if ($rset && (
$row = $DIC->database()->fetchAssoc($rset)) &&
$row[
'cnt'] == 1) {
603 $query =
'SELECT count(user_id) cnt FROM ' . self::$privateRoomsAccessTable .
604 ' WHERE proom_id = %s AND user_id = %s';
606 $types = array(
'integer',
'integer');
607 $values = array($proom_id, $chat_userid);
610 if ($rset && (
$row = $DIC->database()->fetchAssoc($rset)) &&
$row[
'cnt'] == 1) {
614 $query =
'SELECT count(*) cnt FROM ' . self::$privateRoomsTable .
615 ' WHERE proom_id = %s AND owner = %s';
617 $types = array(
'integer',
'integer');
618 $values = array($proom_id, $chat_userid);
621 if ($rset && (
$row = $DIC->database()->fetchAssoc($rset)) &&
$row[
'cnt'] == 1) {
645 'INNER JOIN ' . self::$privateSessionsTable .
' pSessionTable ' .
646 'ON pSessionTable.user_id = ' . $DIC->database()->quote($restricted_session_userid,
'integer') .
' ' .
647 'AND pSessionTable.proom_id = historyTable.sub_room ' .
648 'AND timestamp >= pSessionTable.connected ' .
649 'AND timestamp <= pSessionTable.disconnected ';
653 'SELECT historyTable.* ' .
654 'FROM ' . self::$historyTable .
' historyTable ' . $join .
' ' .
655 'WHERE historyTable.room_id = ' . $this->
getRoomId();
657 if ($proom_id !== null) {
658 $query .=
' AND historyTable.sub_room = ' . $DIC->database()->quote($proom_id,
'integer');
664 $filter[] =
'timestamp >= ' . $DIC->database()->quote(
$from->getUnixTime(),
'integer');
668 $filter[] =
'timestamp <= ' . $DIC->database()->quote($to->getUnixTime(),
'integer');
672 $query .=
' AND ' . join(
' AND ', $filter);
674 $query .=
' ORDER BY timestamp ASC';
676 $rset = $DIC->database()->query(
$query);
679 while (
$row = $DIC->database()->fetchAssoc($rset)) {
686 $row[
'message']->timestamp =
$row[
'timestamp'];
689 $row[
'message']->target !== null &&
690 !
$row[
'message']->target->public &&
691 !in_array($DIC->user()->getId(), explode(
',',
$row[
'recipients']))
714 $query =
'SELECT proom_id, title FROM ' . self::$privateRoomsTable .
' WHERE proom_id IN ( 715 SELECT proom_id FROM ' . self::$privateSessionsTable .
' WHERE connected >= %s AND disconnected <= %s AND user_id = %s 717 ) AND parent_id = %s';
719 $rset = $DIC->database()->queryF(
$query, array(
'integer',
'integer',
'integer',
'integer'), array(
$from->getUnixTime(), $to->getUnixTime(), $user_id, $room_id));
721 while (
$row = $DIC->database()->fetchAssoc($rset)) {
737 $upload_id = $DIC->database()->nextId(self::$uploadTable);
739 $DIC->database()->insert(
742 'upload_id' => array(
'integer', $upload_id),
743 'room_id' => array(
'integer', $this->roomId),
744 'user_id' => array(
'integer', $user_id),
746 'filetype' => array(
'text',
$type),
747 'timestamp' => array(
'integer', time())
762 $DIC->database()->replace(
765 'room_id' => array(
'integer', $this->roomId),
766 'user_id' => array(
'integer', $user_id)
769 'actor_id' => array(
'integer', $actor_id),
770 'timestamp' => array(
'integer', time()),
786 if (!is_array($user_id)) {
787 $user_id = array($user_id);
790 $query =
'DELETE FROM ' . self::$banTable .
' WHERE room_id = %s AND ' . $DIC->database()->in(
'user_id', $user_id,
false,
'integer');
792 $types = array(
'integer');
795 return $DIC->database()->manipulateF(
$query, $types,
$values);
808 $query =
'SELECT COUNT(user_id) cnt FROM ' . self::$banTable .
' WHERE user_id = %s AND room_id = %s';
810 $types = array(
'integer',
'integer');
815 if ($rset && (
$row = $DIC->database()->fetchAssoc($rset)) &&
$row[
'cnt']) {
831 $query =
'SELECT chb.* FROM ' . self::$banTable .
' chb INNER JOIN usr_data ud ON chb.user_id = ud.usr_id WHERE chb.room_id = %s ';
832 $types = array(
'integer');
838 while (
$row = $DIC->database()->fetchAssoc($rset)) {
839 if (
$row[
'user_id'] > 0) {
842 'user_id' =>
$user->getId(),
843 'firstname' =>
$user->getFirstname(),
844 'lastname' =>
$user->getLastname(),
845 'login' =>
$user->getLogin(),
846 'timestamp' =>
$row[
'timestamp'],
847 'actor_id' =>
$row[
'actor_id'],
848 'remark' =>
$row[
'remark']
870 $query =
'SELECT * FROM ' . self::$sessionTable .
' WHERE user_id = ' .
871 $DIC->database()->quote($user->
getUserId(),
'integer') .
872 ' ORDER BY connected DESC';
874 $DIC->database()->setLimit(1);
875 $rset = $DIC->database()->query(
$query);
877 if (
$row = $DIC->database()->fetchAssoc($rset)) {
893 $query =
'SELECT * FROM ' . self::$sessionTable
894 .
' WHERE room_id = ' .
895 $DIC->database()->quote($this->
getRoomId(),
'integer') .
896 ' ORDER BY connected DESC';
898 $rset = $DIC->database()->query(
$query);
902 while (
$row = $DIC->database()->fetchAssoc($rset)) {
913 $nextId = $DIC->database()->nextId(self::$privateRoomsTable);
914 $DIC->database()->insert(
915 self::$privateRoomsTable,
917 'proom_id' => array(
'integer', $nextId),
918 'parent_id' => array(
'integer', $this->roomId),
919 'title' => array(
'text',
$title),
920 'owner' => array(
'integer', $owner->
getUserId()),
922 'created' => array(
'integer', (isset($settings[
'created']) ? $settings[
'created'] : time())),
923 'is_public' => array(
'integer', $settings[
'public']),
934 $DIC->database()->manipulateF(
935 'UPDATE ' . self::$privateRoomsTable .
' SET closed = %s WHERE proom_id = %s',
936 array(
'integer',
'integer'),
945 $query =
'SELECT proom_id FROM ' . self::$privateRoomsTable .
' WHERE proom_id = %s AND owner = %s';
946 $types = array(
'integer',
'integer');
947 $values = array($proom_id, $user_id);
951 if ($rset && $DIC->database()->fetchAssoc($rset)) {
965 public function sendInvitationNotification($gui, $sender, $recipient_id, $subScope = 0, $invitationLink =
'')
969 if ($gui && !$invitationLink) {
970 $invitationLink = $this->
getChatURL($gui, $subScope);
973 if ($recipient_id > 0 && !in_array(ANONYMOUS_USER_ID, array($recipient_id))) {
974 if (is_numeric($sender) && $sender > 0) {
975 $sender_id = $sender;
980 $public_name = $usr->getPublicName();
982 if ($sender->getUserId() > 0) {
983 $sender_id = $sender->getUserId();
985 $sender_id = ANONYMOUS_USER_ID;
987 $public_name = $sender->getUsername();
989 throw new InvalidArgumentException(
'$sender must be an instance of ilChatroomUser or an id of an ilObjUser instance');
993 $userLang->loadLanguageModule(
'mail');
994 require_once
'Services/Mail/classes/class.ilMail.php';
996 'link' => $invitationLink,
997 'inviter_name' => $public_name,
1003 $bodyParams[
'room_name'] .=
' - ' . self::lookupPrivateRoomTitle($subScope);
1006 require_once
'Services/Notifications/classes/class.ilNotificationConfig.php';
1008 $notification->setTitleVar(
'chat_invitation', $bodyParams,
'chatroom');
1009 $notification->setShortDescriptionVar(
'chat_invitation_short', $bodyParams,
'chatroom');
1010 $notification->setLongDescriptionVar(
'chat_invitation_long', $bodyParams,
'chatroom');
1011 $notification->setAutoDisable(
false);
1012 $notification->setLink($invitationLink);
1013 $notification->setIconPath(
'templates/default/images/icon_chtr.svg');
1017 $notification->setHandlerParam(
'mail.sender', $sender_id);
1019 $notification->notifyByUsers(array($recipient_id));
1030 include_once
'Services/Link/classes/class.ilLink.php';
1034 if (is_object($gui)) {
1047 if (!$this->
object) {
1051 return $this->
object->getTitle();
1058 $query =
'SELECT title FROM ' . self::$privateRoomsTable .
' WHERE proom_id = %s';
1059 $types = array(
'integer');
1064 if (
$row = $DIC->database()->fetchAssoc($rset)) {
1065 return $row[
'title'];
1085 $DIC->database()->replace(self::$privateRoomsAccessTable, array(
1086 'user_id' => array(
'integer', $user_id),
1087 'proom_id' => array(
'integer', $proom_id)
1096 SELECT roomtable.title, roomtable.proom_id, accesstable.user_id id, roomtable.owner rowner 1097 FROM ' . self::$privateRoomsTable .
' roomtable 1098 LEFT JOIN ' . self::$privateRoomsAccessTable .
' accesstable 1099 ON roomtable.proom_id = accesstable.proom_id 1100 AND accesstable.user_id = %s 1101 WHERE parent_id = %s 1102 AND (closed = 0 OR closed IS NULL) 1103 AND (accesstable.user_id IS NOT NULL OR roomtable.owner = %s)';
1104 $types = array(
'integer',
'integer',
'integer');
1109 while (
$row = $DIC->database()->fetchAssoc($rset)) {
1123 SELECT chatroom_users.user_id FROM ' . self::$privateSessionsTable .
' 1124 INNER JOIN chatroom_users ON chatroom_users.user_id = ' . self::$privateSessionsTable .
'.user_id WHERE proom_id = %s AND disconnected = 0 1126 $types = array(
'integer');
1127 $values = array($private_room_id);
1132 while (
$row = $DIC->database()->fetchAssoc($rset)) {
1136 return array_values(
$users);
1144 $id = $DIC->database()->nextId(self::$privateSessionsTable);
1145 $DIC->database()->insert(
1146 self::$privateSessionsTable,
1148 'psess_id' => array(
'integer',
$id),
1149 'proom_id' => array(
'integer', $room_id),
1150 'user_id' => array(
'integer', $user_id),
1151 'connected' => array(
'integer', time()),
1152 'disconnected' => array(
'integer', 0),
1162 $query =
'SELECT proom_id id FROM ' . self::$privateSessionsTable .
' WHERE user_id = %s AND proom_id = %s AND disconnected = 0';
1163 $types = array(
'integer',
'integer');
1164 $values = array($user_id, $room_id);
1166 if ($DIC->database()->fetchAssoc($rset)) {
1180 $DIC->database()->update(
1181 self::$privateSessionsTable,
1183 'disconnected' => array(
'integer', time())
1186 'proom_id' => array(
'integer', $room_id),
1187 'user_id' => array(
'integer', $user_id)
1196 $query =
'SELECT count(user_id) as cnt FROM ' . self::$userTable .
1197 ' WHERE room_id = %s';
1199 $types = array(
'integer');
1200 $values = array($this->roomId);
1203 if ($rset && (
$row = $DIC->database()->fetchAssoc($rset)) &&
$row[
'cnt'] == 1) {
1214 $query =
'SELECT * FROM ' . self::$privateRoomsTable .
' WHERE parent_id = %s';
1215 $rset = $DIC->database()->queryF(
$query, array(
'integer'), array($this->roomId));
1219 while (
$row = $DIC->database()->fetchAssoc($rset)) {
1234 $query =
'SELECT user_id FROM ' . self::$privateRoomsAccessTable .
' WHERE proom_id = %s';
1235 $rset = $DIC->database()->queryF(
$query, array(
'integer'), array($subRoomId));
1239 while (
$row = $DIC->database()->fetchAssoc($rset)) {
1240 $userIds[] =
$row[
'user_id'];
1250 $query =
'SELECT title FROM ' . self::$privateRoomsTable .
' WHERE parent_id = %s and closed = 0';
1251 $rset = $DIC->database()->queryF(
$query, array(
'integer'), array($this->roomId));
1255 while (
$row = $DIC->database()->fetchAssoc($rset)) {
1256 $titles[] =
$row[
'title'];
1262 if (!in_array(
$title . $suffix, $titles)) {
1269 $suffix =
' (' .
$i .
')';
1285 SELECT room_id, od.title, objr.ref_id 1287 INNER JOIN " . self::$settingsTable .
" 1288 ON object_id = od.obj_id 1289 INNER JOIN object_reference objr 1290 ON objr.obj_id = od.obj_id 1291 AND objr.deleted IS NULL 1293 ON tree.child = objr.ref_id 1298 $types = array(
'integer',
'text');
1305 while (
$row = $DIC->database()->fetchAssoc(
$res)) {
1307 $rooms[
$row[
'room_id']] = $row[
'title'];
1319 SELECT proom_id, parent_id 1320 FROM " . self::$privateRoomsTable .
" 1321 WHERE parent_id = %s 1326 $types = array(
'integer',
'integer');
1327 $values = array($parent_room, $user_id);
1331 $priv_rooms = array();
1333 while (
$row = $DIC->database()->fetchAssoc(
$res)) {
1334 $proom_id =
$row[
'proom_id'];
1335 $priv_rooms[$proom_id] =
$row[
'parent_id'];
1352 FROM object_reference objr 1354 INNER JOIN chatroom_settings cs 1355 ON cs.object_id = objr.obj_id 1357 INNER JOIN object_data od 1358 ON od.obj_id = cs.object_id 1360 WHERE cs.room_id = %s 1363 $types = array(
'integer');
1368 $row = $DIC->database()->fetchAssoc(
$res);
1370 return $row[
'ref_id'];
1385 $DIC->database()->setLimit($number);
1386 $rset = $DIC->database()->query(
1388 FROM ' . self::$historyTable .
' 1389 WHERE room_id = ' . $DIC->database()->quote($this->roomId,
'integer') .
' 1392 (' . $DIC->database()->like(
'message',
'text',
'%"type":"message"%') .
' AND NOT ' . $DIC->database()->like(
'message',
'text',
'%"public":0%') .
') 1393 OR ' . $DIC->database()->like(
'message',
'text',
'%"target":{%"id":"' . $chatuser->getUserId() .
'"%') .
' 1394 OR ' . $DIC->database()->like(
'message',
'text',
'%"from":{"id":' . $chatuser->getUserId() .
'%') .
' 1396 ORDER BY timestamp DESC' 1401 while ((
$row = $DIC->database()->fetchAssoc($rset)) && $result_count < $number) {
1402 $tmp = json_decode(
$row[
'message']);
1403 if ($chatuser !== null && $tmp->target != null && $tmp->target->public == 0) {
1404 if ($chatuser->getUserId() == $tmp->target->id || $chatuser->getUserId() == $tmp->from->id) {
1414 $rset = $DIC->database()->query(
1416 FROM ' . self::$historyTable .
' 1417 WHERE room_id = ' . $DIC->database()->quote($this->roomId,
'integer') .
' 1419 AND ' . $DIC->database()->like(
'message',
'text',
'%"type":"notice"%') .
' 1420 AND timestamp <= ' . $DIC->database()->quote(
$results[0]->timestamp,
'integer') .
' AND timestamp >= ' . $DIC->database()->quote(
$results[$result_count - 1]->timestamp,
'integer') .
' 1422 ORDER BY timestamp DESC' 1425 while ((
$row = $DIC->database()->fetchAssoc($rset))) {
1426 $tmp = json_decode(
$row[
'message']);
1430 \usort(
$results,
function ($a, $b) {
1431 $a_timestamp = strlen($a->timestamp) == 13 ? substr($a->timestamp, 0, -3) : $a->timestamp;
1432 $b_timestamp = strlen($b->timestamp) == 13 ? substr($b->timestamp, 0, -3) : $b->timestamp;
1434 return $b_timestamp - $a_timestamp;
1444 $DIC->database()->queryF(
1445 'DELETE FROM ' . self::$historyTable .
' WHERE room_id = %s AND sub_room = %s',
1446 array(
'integer',
'integer'),
1447 array($this->roomId, (
int) $sub_room)
1451 $DIC->database()->queryF(
1452 'DELETE FROM ' . self::$privateSessionsTable .
' WHERE proom_id = %s AND disconnected < %s',
1453 array(
'integer',
'integer'),
1454 array($sub_room, time())
1457 $DIC->database()->queryF(
1458 'DELETE FROM ' . self::$sessionTable .
' WHERE room_id = %s AND disconnected < %s',
1459 array(
'integer',
'integer'),
1460 array($this->roomId, time())
setSetting($name, $value)
Sets given name and value as setting into $this->settings array.
static $privateRoomsTable
getUserId()
Returns Ilias User ID.
getActivePrivateRooms($userid)
static getUntrashedChatReferences($filter=array())
getUniquePrivateRoomTitle($title)
getPrivateSubRooms($parent_room, $user_id)
getRoomId()
Returns roomID from $this->roomId.
isUserBanned($user_id)
Returns true if there's an entry in banTable matching roomId and given $user_id.
inviteUserToPrivateRoom($user_id, $proom_id)
const IL_NO_OBJECT_ACCESS
if(empty($userids)) $userid
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
getLastMessages($number, $chatuser=null)
getSettings()
Returns $this->settings array.
getLastSession(ilChatroomUser $user)
Returns last session from user.
getRefIdByRoomId($room_id)
Returns ref_id of given room_id.
getSetting($name)
Returns setting from $this->settings array by given name.
isSubscribed($chat_userid)
Returns true if entry exists in userTable matching given $chat_userid and $this->roomId.
static byRoomId($room_id, $initObject=false)
Returns ilChatroom by given $room_id.
if(!array_key_exists('StateId', $_REQUEST)) $id
getPrivateRoomSessions(ilDateTime $from=null, ilDateTime $to=null, $user_id=0, $room_id=0)
disconnectUsers(array $userIds)
Disconnects users by deleting userdata from userTable using given userId array.
static _lookupId($a_user_str)
Lookup id by login.
unsubscribeUserFromPrivateRoom($room_id, $user_id)
getPrivilegedUsersForPrivateRoom($subRoomId)
userIsInPrivateRoom($room_id, $user_id)
getChatURL($gui, $scope_id=0)
Describes a notification and provides methods for publishing this notification.
listUsersInPrivateRoom($private_room_id)
save()
Saves settings using $this->settings.
isOwnerOfPrivateRoom($user_id, $proom_id)
catch(Exception $e) $message
static $privateSessionsTable
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
foreach($_POST as $key=> $value) $res
getBannedUsers()
Returns an multidimensional array containing userdata from users having an entry in banTable with mat...
addPrivateRoom($title, ilChatroomUser $owner, $settings)
getHistory(ilDateTime $from=null, ilDateTime $to=null, $restricted_session_userid=null, $proom_id=0, $respect_target=true)
Returns array containing history data selected from historyTable by given ilDateTime, $restricted_session_userid and matching roomId.
getSessions(ilChatroomUser $user)
Returns all session from user Returns all from sessionTable where user_id matches userId from given $...
static _lookupObjId($a_id)
static findDeletablePrivateRooms()
addHistoryEntry($message, $recipient=null, $publicMessage=true)
Inserts entry into historyTable.
static lookupPrivateRoomTitle($proom_id)
subscribeUserToPrivateRoom($room_id, $user_id)
saveFileUploadToDb($user_id, $filename, $type)
Saves information about file uploads in DB.
unbanUser($user_id)
Deletes entry from banTable matching roomId and given $user_id and returns true if sucessful...
connectUser(ilChatroomUser $user)
Connects user by inserting userdata into userTable.
disconnectUser($user_id)
Creates userId array by given $user object and calls disconnectUsers method.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static disconnectAllUsersFromAllRooms()
Deletes all entrys from userTable.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _getLanguageOfUser($a_usr_id)
Get language object of user.
getLastMessagesForChatViewer($number, $chatuser=null)
static $privateRoomsAccessTable
foreach($mandatory_scripts as $file) $timestamp
inviteUserToPrivateRoomByLogin($login, $proom_id)
static checkPermissions($usrId, $refId, array $permissions)
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
getUsername()
Returns username from Object or SESSION.
static isActivated($refId, $objId, &$a_visible_flag=null)
initialize(array $rowdata)
Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $...
static checkPermissionsOfUser($usr_id, $permissions, $ref_id)
Checks user permissions in question for a given user id in relation to a given ref_id.
saveSettings(array $settings)
Saves settings into settingsTable using given settings array.
banUser($user_id, $actor_id, $comment='')
Inserts user into banTable, using given $user_id.
getConnectedUsers($only_data=true)
Returns an array of connected users.
isAllowedToEnterPrivateRoom($chat_userid, $proom_id)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
getAccessibleRoomIdByTitleMap($user_id)
Fetches and returns a Array<Integer, String> of all accessible repository object chats in the main tr...
static getSalutation($a_usr_id, ilLanguage $a_language=null)