ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ($name, $value)
 Sets given name and value as setting into $this->settings array. More...
 
 getDescription ()
 
 getSetting ($name)
 Returns setting from $this->settings array by given name. More...
 
 save ()
 Saves settings using $this->settings. More...
 
 saveSettings (array $settings)
 Saves settings into settingsTable using given settings array. More...
 
 addHistoryEntry ($message, $recipient=null, $publicMessage=true)
 Inserts entry into historyTable. More...
 
 getConnectedUsers ()
 Returns an array of connected users. More...
 
 disconnectUser ($user_id)
 Creates userId array by given $user object and calls disconnectUsers method. More...
 
 disconnectUsers (array $userIds)
 Disconnects users by deleting userdata from userTable using given userId array. More...
 
 getSettings ()
 Returns $this->settings array. More...
 
 isSubscribed ($chat_userid)
 Returns true if entry exists in userTable matching given $chat_userid and $this->roomId. More...
 
 isAllowedToEnterPrivateRoom ($chat_userid, $proom_id)
 
 getHistory (ilDateTime $from=null, ilDateTime $to=null, $restricted_session_userid=null, $proom_id=0)
 Returns array containing history data selected from historyTable by given ilDateTime, $restricted_session_userid and matching roomId. More...
 
 getRoomId ()
 Returns roomID from $this->roomId. More...
 
 getPrivateRoomSessions (ilDateTime $from=null, ilDateTime $to=null, $user_id=0, $room_id=0)
 
 saveFileUploadToDb ($user_id, $filename, $type)
 Saves information about file uploads in DB. More...
 
 banUser ($user_id, $comment='')
 Inserts user into banTable, using given $user_id ilDBInterface $ilDB. More...
 
 unbanUser ($user_id)
 Deletes entry from banTable matching roomId and given $user_id and returns true if sucessful. More...
 
 isUserBanned ($user_id)
 Returns true if there's an entry in banTable matching roomId and given $user_id ilDBInterface $ilDB. More...
 
 getBannedUsers ()
 Returns an multidimensional array containing userdata from users having an entry in banTable with matching roomId. More...
 
 getLastSession (ilChatroomUser $user)
 Returns last session from user. More...
 
 getSessions (ilChatroomUser $user)
 Returns all session from user Returns all from sessionTable where user_id matches userId from given $user object. More...
 
 addPrivateRoom ($title, ilChatroomUser $owner, $settings)
 
 closePrivateRoom ($id)
 
 isOwnerOfPrivateRoom ($user_id, $proom_id)
 
 getChatURL ($gui, $scope_id=0)
 ilCtrl $ilCtrl More...
 
 getTitle ()
 
 inviteUserToPrivateRoomByLogin ($login, $proom_id)
 
 getActivePrivateRooms ($userid)
 
 listUsersInPrivateRoom ($private_room_id)
 
 subscribeUserToPrivateRoom ($room_id, $user_id)
 
 userIsInPrivateRoom ($room_id, $user_id)
 
 unsubscribeUserFromPrivateRoom ($room_id, $user_id)
 ilDBInterface $ilDB More...
 
 countActiveUsers ()
 
 getUniquePrivateRoomTitle ($title)
 
 getPrivateSubRooms ($parent_room, $user_id)
 
 getRefIdByRoomId ($room_id)
 Returns ref_id of given room_id ilDBInterface $ilDB. More...
 
 getLastMessagesForChatViewer ($number, $chatuser=null)
 
 getLastMessages ($number, $chatuser=null)
 
 clearMessages ($sub_room)
 

Static Public Member Functions

static checkUserPermissions ($permissions, $ref_id, $send_info=true)
 Checks user permissions by given array and ref_id. More...
 
static checkPermissionsOfUser ($usr_id, $permissions, $ref_id)
 Checks user permissions in question for a given user id in relation to a given ref_id. More...
 
static byObjectId ($object_id)
 Returns ilChatroom object by given $object_id. More...
 
static byRoomId ($room_id, $initObject=false)
 Returns ilChatroom by given $room_id ilDBInterface $ilDB. More...
 
static disconnectAllUsersFromAllRooms ()
 Deletes all entrys from userTable. More...
 
static findDeletablePrivateRooms ()
 
static lookupPrivateRoomTitle ($proom_id)
 

Private Member Functions

 phpTypeToMDBType ($type)
 

Private Attributes

 $settings = array()
 
 $availableSettings
 
 $roomId
 
 $object
 

Static Private Attributes

static $settingsTable = 'chatroom_settings'
 
static $historyTable = 'chatroom_history'
 
static $userTable = 'chatroom_users'
 
static $sessionTable = 'chatroom_sessions'
 
static $banTable = 'chatroom_bans'
 
static $privateRoomsTable = 'chatroom_prooms'
 
static $privateSessionsTable = 'chatroom_psessions'
 
static $uploadTable = 'chatroom_uploads'
 
static $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 10 of file class.ilChatroom.php.

Member Function Documentation

◆ addHistoryEntry()

ilChatroom::addHistoryEntry (   $message,
  $recipient = null,
  $publicMessage = true 
)

Inserts entry into historyTable.

Todo:
$recipient, $publicMessage speichern ilDBInterface $ilDB
Parameters
string$message
string$recipient
boolean$publicMessage

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

References $ilDB, $query, array, ilChatroomUser\getUserId(), ilChatroomUser\getUsername(), and time.

388  {
389  global $ilDB;
390 
391  $subRoom = 0;
392  if(is_array($message))
393  {
394  $subRoom = (int)$message['sub'];
395  }
396  else if(is_object($message))
397  {
398  $subRoom = (int)$message->sub;
399  }
400 
401  $id = $ilDB->nextId(self::$historyTable);
402  $ilDB->insert(
403  self::$historyTable,
404  array(
405  'hist_id' => array('integer', $id),
406  'room_id' => array('integer', $this->roomId),
407  'sub_room' => array('integer', $subRoom),
408  'message' => array('text', json_encode($message)),
409  'timestamp' => array('integer', time()),
410  )
411  );
412  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ addPrivateRoom()

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

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

References $ilDB, $settings, $title, array, ilChatroomUser\getUserId(), and time.

Referenced by ilChatroomViewGUI\renderFileUploadForm().

923  {
924  global $ilDB;
925 
926  $nextId = $ilDB->nextId(self::$privateRoomsTable);
927  $ilDB->insert(
928  self::$privateRoomsTable,
929  array(
930  'proom_id' => array('integer', $nextId),
931  'parent_id' => array('integer', $this->roomId),
932  'title' => array('text', $title),
933  'owner' => array('integer', $owner->getUserId()),
934  'created' => array('integer', time()),
935  'is_public' => array('integer', $settings['public']),
936  )
937  );
938 
939  return $nextId;
940  }
getUserId()
Returns Ilias User ID.
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ banUser()

ilChatroom::banUser (   $user_id,
  $comment = '' 
)

Inserts user into banTable, using given $user_id ilDBInterface $ilDB.

Parameters
integer$user_id
string$comment

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

References $comment, $ilDB, array, and time.

759  {
760  global $ilDB;
761 
762  $ilDB->replace(
763  self::$banTable,
764  array(
765  'room_id' => array('integer', $this->roomId),
766  'user_id' => array('integer', $user_id)
767  ),
768  array(
769  'timestamp' => array('integer', time()),
770  'remark' => array('text', $comment)
771  )
772  );
773  }
$comment
Definition: buildRTE.php:83
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ byObjectId()

static ilChatroom::byObjectId (   $object_id)
static

Returns ilChatroom object by given $object_id.

ilDBInterface $ilDB

Parameters
integer$object_id
Returns
ilChatroom

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

References $ilDB, $query, $row, and array.

Referenced by ilChatroomHistoryGUI\__construct(), ilChatroomBanGUI\active(), ilChatroomServerHandler\cleanupPrivateRooms(), ilChatroomPrivateRoomGUI\create(), ilObjChatroom\createDefaultRole(), ilChatroomPrivateRoomGUI\delete(), ilChatroomPrivateRoomGUI\enter(), ilChatroomPostMessageGUI\executeDefault(), ilChatroomInitialGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomBanGUI\executeDefault(), ilChatroomBlockGUI\getChatroomSelectionList(), ilChatroomTabGUIFactory\getLabel(), ilChatroomGUIHandler\getRoomByObjectId(), ilObjChatroomListGUI\init(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomPrivateRoomGUI\leave(), ilChatroomPrivateRoomGUI\listUsers(), ilChatroomKickGUI\main(), ilChatroomViewGUI\renderFileUploadForm(), ilChatroomKickGUI\sub(), and ilChatroomUploadFileGUI\uploadFile().

111  {
112  global $ilDB;
113  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE object_id = %s';
114  $types = array('integer');
115  $values = array($object_id);
116  $rset = $ilDB->queryF($query, $types, $values);
117 
118  if($row = $ilDB->fetchAssoc($rset))
119  {
120  $room = new self();
121  $room->initialize($row);
122  return $room;
123  }
124  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ byRoomId()

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

Returns ilChatroom by given $room_id ilDBInterface $ilDB.

Parameters
integer$room_id
Returns
ilChatroom

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

References $ilDB, $query, $row, array, and ilObjectFactory\getInstanceByObjId().

Referenced by ilChatroomServerHandler\disconnectedUsers(), and ilContactGUI\submitInvitation().

162  {
163  global $ilDB;
164 
165  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE room_id = %s';
166 
167  $types = array('integer');
168  $values = array($room_id);
169 
170  $rset = $ilDB->queryF($query, $types, $values);
171 
172  if($row = $ilDB->fetchAssoc($rset))
173  {
174  $room = new self();
175  $room->initialize($row);
176 
177  if($initObject)
178  {
179  $room->object = ilObjectFactory::getInstanceByObjId($row['object_id']);
180  }
181 
182  return $room;
183  }
184  }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPermissionsOfUser()

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

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

ilRbacSystem $rbacsystem ilLanguage $lng

Parameters
integer$usr_id
mixed$permissions
integer$ref_id
Returns
boolean

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

References $lng, $ref_id, and array.

Referenced by ilChatroomKickGUI\sub(), and ilContactGUI\submitInvitation().

85  {
86  global $rbacsystem, $lng;
87 
88  if(!is_array($permissions))
89  {
90  $permissions = array($permissions);
91  }
92 
93  foreach($permissions as $permission)
94  {
95  if(!$rbacsystem->checkAccessOfUser($usr_id, $permission, $ref_id))
96  {
97  return false;
98  }
99  }
100 
101  return true;
102  }
Create styles array
The data for the language used.
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ checkUserPermissions()

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

Checks user permissions by given array and ref_id.

Rbacsystem $rbacsystem

Parameters
mixed$permissions
integer$ref_id

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

References $lng, $ref_id, array, and ilUtil\sendFailure().

Referenced by ilChatroomHistoryGUI\__construct(), ilChatroomSettingsGUI\__construct(), ilChatroomAdminViewGUI\clientsettings(), ilChatroomTabGUIFactory\convertLowerCamelCaseToUnderscoreCaseConversion(), ilChatroomPrivateRoomGUI\enter(), ilChatroomPostMessageGUI\executeDefault(), ilChatroomBanGUI\executeDefault(), ilChatroomGUIHandler\redirectIfNoPermission(), ilChatroomViewGUI\renderFileUploadForm(), ilChatroomAdminViewGUI\serversettings(), ilChatroomUploadFileGUI\uploadFile(), and ilChatroomAdminSmileyGUI\view().

51  {
52  global $rbacsystem, $lng;
53 
54  if(!is_array($permissions))
55  {
56  $permissions = array($permissions);
57  }
58 
59  foreach($permissions as $permission)
60  {
61  if(!$rbacsystem->checkAccess($permission, $ref_id))
62  {
63  if($send_info)
64  {
65  ilUtil::sendFailure($lng->txt("permission_denied"), true);
66  }
67  return false;
68  }
69  }
70 
71  return true;
72  }
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearMessages()

ilChatroom::clearMessages (   $sub_room)

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

References $ilDB, array, and time.

1468  {
1469  global $ilDB;
1470 
1471  $ilDB->queryF(
1472  'DELETE FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = %s',
1473  array('integer', 'integer'),
1474  array($this->roomId, (int)$sub_room)
1475  );
1476 
1477  if($sub_room)
1478  {
1479  $ilDB->queryF(
1480  'DELETE FROM ' . self::$privateSessionsTable . ' WHERE proom_id = %s AND disconnected < %s',
1481  array('integer', 'integer'),
1482  array($sub_room, time())
1483  );
1484  }
1485  else
1486  {
1487  $ilDB->queryF(
1488  'DELETE FROM ' . self::$sessionTable . ' WHERE room_id = %s AND disconnected < %s',
1489  array('integer', 'integer'),
1490  array($this->roomId, time())
1491  );
1492  }
1493  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ closePrivateRoom()

ilChatroom::closePrivateRoom (   $id)

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

References $ilDB, array, and time.

943  {
944  global $ilDB;
945 
946  $ilDB->manipulateF(
947  'UPDATE ' . self::$privateRoomsTable . ' SET closed = %s WHERE proom_id = %s',
948  array('integer', 'integer'),
949  array(time(), $id)
950  );
951  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ countActiveUsers()

ilChatroom::countActiveUsers ( )

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

References $ilDB, $query, $row, and array.

1239  {
1240  global $ilDB;
1241 
1242  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
1243  ' WHERE room_id = %s';
1244 
1245  $types = array('integer');
1246  $values = array($this->roomId);
1247  $rset = $ilDB->queryF($query, $types, $values);
1248 
1249  if($rset && ($row = $ilDB->fetchAssoc($rset)) && $row['cnt'] == 1)
1250  return $row['cnt'];
1251 
1252  return 0;
1253  }
Create styles array
The data for the language used.
global $ilDB

◆ disconnectAllUsersFromAllRooms()

static ilChatroom::disconnectAllUsersFromAllRooms ( )
static

Deletes all entrys from userTable.

ilDBInterface $ilDB

Todo:
nicht nur löschen, auch in Session Tabelle nachpflegen

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

References $ilDB, and time.

Referenced by ilChatroomServerHandler\serverStarted().

191  {
192  global $ilDB;
193 
194  $ilDB->manipulate('DELETE FROM ' . self::$userTable);
195  $ilDB->manipulate('UPDATE ' . self::$privateRoomsTable . ' SET closed = ' . $ilDB->quote(time(), 'integer') . ' WHERE closed = 0 OR closed IS NULL');
196  $ilDB->manipulate('UPDATE ' . self::$privateSessionsTable . ' SET disconnected = ' . $ilDB->quote(time(), 'integer') . ' WHERE disconnected = 0');
200  }
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ disconnectUser()

ilChatroom::disconnectUser (   $user_id)

Creates userId array by given $user object and calls disconnectUsers method.

Parameters
int$user_id

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

References array, and disconnectUsers().

493  {
494  $this->disconnectUsers(array($user_id));
495  }
disconnectUsers(array $userIds)
Disconnects users by deleting userdata from userTable using given userId array.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ disconnectUsers()

ilChatroom::disconnectUsers ( array  $userIds)

Disconnects users by deleting userdata from userTable using given userId array.

Deletes entrys from userTable, matching roomId and userId if existing and inserts userdata and disconnection time into sessionTable. ilDBInterface $ilDB

Parameters
array$userIds

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

References $ilDB, $query, $row, array, getSetting(), and time.

Referenced by disconnectUser().

505  {
506  global $ilDB;
507 
508  $query = 'SELECT * FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
509  $ilDB->in('user_id', $userIds, false, 'integer');
510 
511  $types = array('integer');
512  $values = array($this->roomId);
513  $rset = $ilDB->queryF($query, $types, $values);
514 
515  if($row = $ilDB->fetchAssoc($rset))
516  {
517  $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s';
518  $rset_prooms = $ilDB->queryF($query, array('integer'), array($this->roomId));
519 
520  $prooms = array();
521 
522  while($row_prooms = $ilDB->fetchAssoc($rset_prooms))
523  {
524  $prooms[] = $row_prooms['proom_id'];
525  }
526 
527  if(true || $this->getSetting('enable_history'))
528  {
529  $query = 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = %s WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
530  $ilDB->manipulateF($query, array('integer'), array(time()));
531  }
532  else
533  {
534  $query = 'DELETE FROM ' . self::$privateSessionsTable . ' WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
535  $ilDB->manipulate($query);
536  }
537 
538  $query = 'DELETE FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
539  $ilDB->in('user_id', $userIds, false, 'integer');
540 
541  $types = array('integer');
542  $values = array($this->roomId);
543  $ilDB->manipulateF($query, $types, $values);
544 
545  do
546  {
547  if($this->getSetting('enable_history'))
548  {
549  $id = $ilDB->nextId(self::$sessionTable);
550  $ilDB->insert(
551  self::$sessionTable,
552  array(
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())
559  )
560  );
561  }
562  }
563  while($row = $ilDB->fetchAssoc($rset));
564  }
565 
566  }
getSetting($name)
Returns setting from $this->settings array by given name.
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDeletablePrivateRooms()

static ilChatroom::findDeletablePrivateRooms ( )
static

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

References $ilDB, $query, $res, $row, array, and time.

Referenced by ilChatroomServerHandler\cleanupPrivateRooms().

203  {
204  global $ilDB;
205 
206  $query = '
207  SELECT private_rooms.proom_id id, MIN(disconnected) min_disconnected, MAX(disconnected) max_disconnected
208  FROM ' . self::$privateSessionsTable . ' private_sessions
209  INNER JOIN ' . self::$privateRoomsTable . ' private_rooms
210  ON private_sessions.proom_id = private_rooms.proom_id
211  WHERE closed = 0
212  GROUP BY private_rooms.proom_id
213  HAVING MIN(disconnected) > 0 AND MAX(disconnected) < %s';
214  $rset = $ilDB->queryF(
215  $query,
216  array('integer'),
217  array(time() + 60 * 5)
218  );
219 
220  $rooms = array();
221 
222  while($row = $ilDB->fetchAssoc($rset))
223  {
224  $rooms[$row['id']] = $row['id'];
225  }
226 
227  $query = 'SELECT DISTINCT proom_id, room_id, object_id FROM ' . self::$privateRoomsTable
228  . ' INNER JOIN ' . self::$settingsTable . ' ON parent_id = room_id '
229  . ' WHERE ' . $ilDB->in('proom_id', $rooms, false, 'integer');
230 
231  $rset = $ilDB->query($query);
232  $rooms = array();
233  while($row = $ilDB->fetchAssoc($rset))
234  {
235  $rooms[] = array(
236  'proom_id' => $row['proom_id'],
237  'room_id' => $row['room_id'],
238  'object_id' => $row['object_id']
239  );
240  }
241 
242  return $rooms;
243  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ getActivePrivateRooms()

ilChatroom::getActivePrivateRooms (   $userid)

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

References $ilDB, $query, $row, array, and listUsersInPrivateRoom().

1135  {
1136  global $ilDB;
1137 
1138  $query = '
1139  SELECT roomtable.title, roomtable.proom_id, accesstable.user_id id, roomtable.owner rowner
1140  FROM ' . self::$privateRoomsTable . ' roomtable
1141  LEFT JOIN ' . self::$privateRoomsAccessTable . ' accesstable
1142  ON roomtable.proom_id = accesstable.proom_id
1143  AND accesstable.user_id = %s
1144  WHERE parent_id = %s
1145  AND (closed = 0 OR closed IS NULL)
1146  AND (accesstable.user_id IS NOT NULL OR roomtable.owner = %s)';
1147  $types = array('integer', 'integer', 'integer');
1148  $values = array($userid, $this->roomId, $userid);
1149  $rset = $ilDB->queryF($query, $types, $values);
1150  $rooms = array();
1151 
1152  while($row = $ilDB->fetchAssoc($rset))
1153  {
1154  $row['active_users'] = $this->listUsersInPrivateRoom($row['id']);
1155  $row['owner'] = $row['rowner'];
1156  $rooms[$row['proom_id']] = $row;
1157  }
1158 
1159  return $rooms;
1160  }
listUsersInPrivateRoom($private_room_id)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ getBannedUsers()

ilChatroom::getBannedUsers ( )

Returns an multidimensional array containing userdata from users having an entry in banTable with matching roomId.

ilDBInterface $ilDB

Returns
array

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

References $ilDB, $query, $result, $row, array, and getRoomId().

832  {
833  global $ilDB;
834 
835  $query = 'SELECT chb.* FROM ' . self::$banTable . ' chb INNER JOIN usr_data ud ON chb.user_id = ud.usr_id WHERE chb.room_id = %s ';
836  $types = array('integer');
837  $values = array($this->getRoomId());
838  $rset = $ilDB->queryF($query, $types, $values);
839  $result = array();
840 
841  if($rset)
842  {
843  while($row = $ilDB->fetchAssoc($rset))
844  {
845  if($row['user_id'] > 0)
846  {
847  $user = new ilObjUser($row['user_id']);
848  $userdata = array(
849  'user_id' => $user->getId(),
850  'firstname' => $user->getFirstname(),
851  'lastname' => $user->getLastname(),
852  'login' => $user->getLogin(),
853  'remark' => $row['remark']
854  );
855 
856  $result[] = $userdata;
857  }
858  else
859  {
860  //@todo anonymous user
861  }
862  }
863  }
864 
865  return $result;
866  }
getRoomId()
Returns roomID from $this->roomId.
$result
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ getChatURL()

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

ilCtrl $ilCtrl

Parameters
<type>$gui
<type>$scope_id

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

References $url, and ilLink\_getStaticLink().

Referenced by isOwnerOfPrivateRoom().

1056  {
1057  include_once 'Services/Link/classes/class.ilLink.php';
1058 
1059  $url = '';
1060 
1061  if(is_object($gui))
1062  {
1063  if($scope_id)
1064  {
1065  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType(), true, '_' . $scope_id);
1066  }
1067  else
1068  {
1069  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType());
1070  }
1071  }
1072 
1073  return $url;
1074  }
$url
Definition: shib_logout.php:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConnectedUsers()

ilChatroom::getConnectedUsers ( )

Returns an array of connected users.

Returns an array of user objects containing all users having an entry in userTable, matching the roomId. ilDBInterface $ilDB

Returns
array

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

References $ilDB, $query, $row, and array.

470  {
471  global $ilDB;
472 
473  $query = 'SELECT userdata FROM ' . self::$userTable . ' WHERE room_id = %s';
474  $types = array('integer');
475  $values = array($this->roomId);
476  $rset = $ilDB->queryF($query, $types, $values);
477  $users = array();
478 
479  while($row = $ilDB->fetchAssoc($rset))
480  {
481  $users[] = json_decode($row['userdata']);
482  }
483 
484  return $users;
485  }
Create styles array
The data for the language used.
global $ilDB

◆ getDescription()

ilChatroom::getDescription ( )

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

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

292  {
293  if(!$this->object)
294  {
295  $this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
296  }
297 
298  return $this->object->getDescription();
299  }
getSetting($name)
Returns setting from $this->settings array by given name.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ getHistory()

ilChatroom::getHistory ( ilDateTime  $from = null,
ilDateTime  $to = null,
  $restricted_session_userid = null,
  $proom_id = 0 
)

Returns array containing history data selected from historyTable by given ilDateTime, $restricted_session_userid and matching roomId.

ilDBInterface $ilDB

Parameters
ilDateTime$from
ilDateTime$to
integer$restricted_session_userid
Returns
array

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

References $ilDB, $ilUser, $query, $result, $row, array, and getRoomId().

639  {
640  global $ilDB, $ilUser;
641 
642  $join = '';
643 
644  if($proom_id)
645  {
646  $join .=
647  'INNER JOIN ' . self::$privateSessionsTable . ' pSessionTable ' .
648  'ON pSessionTable.user_id = ' . $ilDB->quote($restricted_session_userid, 'integer') . ' ' .
649  'AND pSessionTable.proom_id = historyTable.sub_room ' .
650  'AND timestamp >= pSessionTable.connected ' .
651  'AND timestamp <= pSessionTable.disconnected ';
652  }
653 
654  $query =
655  'SELECT historyTable.* ' .
656  'FROM ' . self::$historyTable . ' historyTable ' . $join . ' ' .
657  'WHERE historyTable.room_id = ' . $this->getRoomId();
658 
659  $query .= ' AND historyTable.sub_room = ' . $ilDB->quote($proom_id, 'integer');
660 
661  $filter = array();
662 
663  if($from != null)
664  {
665  $filter[] = 'timestamp >= ' . $ilDB->quote($from->getUnixTime(), 'integer');
666  }
667 
668  if($to != null)
669  {
670  $filter[] = 'timestamp <= ' . $ilDB->quote($to->getUnixTime(), 'integer');
671  }
672 
673  if($filter)
674  $query .= ' AND ' . join(' AND ', $filter);
675  $query .= ' ORDER BY timestamp ASC';
676 
677  $rset = $ilDB->query($query);
678  $result = array();
679 
680  while($row = $ilDB->fetchAssoc($rset))
681  {
682  $message = json_decode($row['message']);
683  if ($message === null) {
684  $message = json_decode('{}');
685  }
686 
687  $row['message'] = $message;
688  $row['message']->timestamp = $row['timestamp'];
689  if($row['message']->target !== null && !$row['message']->target->public && !in_array($ilUser->getId(), explode(',', $row['recipients'])))
690  {
691  continue;
692  }
693 
694  $result[] = $row;
695  }
696  return $result;
697  }
getRoomId()
Returns roomID from $this->roomId.
$result
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
getUnixTime()
get unix time
global $ilDB
+ Here is the call graph for this function:

◆ getLastMessages()

ilChatroom::getLastMessages (   $number,
  $chatuser = null 
)

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

References $ilDB, $results, $row, and array.

Referenced by getLastMessagesForChatViewer().

1398  {
1399  global $ilDB;
1400 
1401  // There is currently no way to check if a message is private or not
1402  // by sql. So we fetch twice as much as we need and hope that there
1403  // are not more than $number private messages.
1404  $ilDB->setLimit($number);
1405  $rset = $ilDB->query(
1406  'SELECT *
1407  FROM ' . self::$historyTable . '
1408  WHERE room_id = ' . $ilDB->quote($this->roomId, 'integer') . '
1409  AND sub_room = 0
1410  AND (
1411  (' . $ilDB->like('message', 'text', '%"type":"message"%') . ' AND NOT ' . $ilDB->like('message', 'text', '%"public":0%') . ')
1412  OR ' . $ilDB->like('message', 'text', '%"target":{%"id":"' . $chatuser->getUserId() . '"%') . '
1413  OR ' . $ilDB->like('message', 'text', '%"from":{"id":' . $chatuser->getUserId() . '%') . '
1414  )
1415  ORDER BY timestamp DESC'
1416  );
1417  /*$rset = $ilDB->queryF('SELECT * FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = 0 ORDER BY timestamp DESC', array('integer'), array($this->roomId));*/
1418 
1419  $result_count = 0;
1420  $results = array();
1421  while(($row = $ilDB->fetchAssoc($rset)) && $result_count < $number)
1422  {
1423  $tmp = json_decode($row['message']);
1424  if($chatuser !== null && $tmp->target != null && $tmp->target->public == 0)
1425  {
1426  if($chatuser->getUserId() == $tmp->target->id || $chatuser->getUserId() == $tmp->from->id)
1427  {
1428  $results[] = $tmp;
1429  ++$result_count;
1430  }
1431  }
1432  else
1433  {
1434  $results[] = $tmp;
1435  ++$result_count;
1436  }
1437  }
1438 
1439  $rset = $ilDB->query(
1440  'SELECT *
1441  FROM ' . self::$historyTable . '
1442  WHERE room_id = ' . $ilDB->quote($this->roomId, 'integer') . '
1443  AND sub_room = 0
1444  AND ' . $ilDB->like('message', 'text', '%"type":"notice"%') . '
1445  AND timestamp <= ' . $ilDB->quote($results[0]->timestamp, 'integer') . ' AND timestamp >= ' . $ilDB->quote($results[$result_count - 1]->timestamp, 'integer') . '
1446 
1447  ORDER BY timestamp DESC'
1448  );
1449 
1450  while(($row = $ilDB->fetchAssoc($rset)))
1451  {
1452  $tmp = json_decode($row['message']);
1453  $results[] = $tmp;
1454  }
1455 
1456  \usort($results, function ($a, $b)
1457  {
1458  $a_timestamp = strlen($a->timestamp) == 13 ? substr($a->timestamp, 0, -3) : $a->timestamp;
1459  $b_timestamp = strlen($b->timestamp) == 13 ? substr($b->timestamp, 0, -3) : $b->timestamp;
1460 
1461  return $b_timestamp - $a_timestamp;
1462  });
1463 
1464  return $results;
1465  }
$results
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getLastMessagesForChatViewer()

ilChatroom::getLastMessagesForChatViewer (   $number,
  $chatuser = null 
)

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

References getLastMessages().

1393  {
1394  return $this->getLastMessages($number, $chatuser);
1395  }
getLastMessages($number, $chatuser=null)
+ Here is the call graph for this function:

◆ getLastSession()

ilChatroom::getLastSession ( ilChatroomUser  $user)

Returns last session from user.

Returns row from sessionTable where user_id matches userId from given $user object. ilDBInterface $ilDB

Parameters
ilChatroomUser$user
Returns
array

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

References $ilDB, $query, $row, and ilChatroomUser\getUserId().

877  {
878  global $ilDB;
879 
880  $query = 'SELECT * FROM ' . self::$sessionTable . ' WHERE user_id = ' .
881  $ilDB->quote($user->getUserId(), 'integer') .
882  ' ORDER BY connected DESC';
883 
884  $ilDB->setLimit(1);
885  $rset = $ilDB->query($query);
886 
887  if($row = $ilDB->fetchAssoc($rset))
888  {
889  return $row;
890  }
891  }
getUserId()
Returns Ilias User ID.
global $ilDB
+ Here is the call graph for this function:

◆ getPrivateRoomSessions()

ilChatroom::getPrivateRoomSessions ( ilDateTime  $from = null,
ilDateTime  $to = null,
  $user_id = 0,
  $room_id = 0 
)

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

References $ilDB, $query, $result, $row, and array.

709  {
710  global $ilDB;
711 
712  $query = 'SELECT proom_id, title FROM ' . self::$privateRoomsTable . ' WHERE proom_id IN (
713  SELECT proom_id FROM ' . self::$privateSessionsTable . ' WHERE connected >= %s AND disconnected <= %s AND user_id = %s
714 
715  ) AND parent_id = %s';
716 
717  $rset = $ilDB->queryF($query, array('integer', 'integer', 'integer', 'integer'), array($from->getUnixTime(), $to->getUnixTime(), $user_id, $room_id));
718  $result = array();
719  while($row = $ilDB->fetchAssoc($rset))
720  {
721  $result[] = $row;
722  }
723  return $result;
724  }
$result
Create styles array
The data for the language used.
getUnixTime()
get unix time
global $ilDB

◆ getPrivateSubRooms()

ilChatroom::getPrivateSubRooms (   $parent_room,
  $user_id 
)

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

References $ilDB, $query, $res, $row, and array.

1332  {
1333  global $ilDB;
1334 
1335  $query = "
1336  SELECT proom_id, parent_id
1337  FROM chatroom_prooms
1338  WHERE parent_id = %s
1339  AND owner = %s
1340  AND closed = 0
1341  ";
1342 
1343  $types = array('integer', 'integer');
1344  $values = array($parent_room, $user_id);
1345 
1346  $res = $ilDB->queryF($query, $types, $values);
1347 
1348  $priv_rooms = array();
1349 
1350  while($row = $ilDB->fetchAssoc($res))
1351  {
1352  $proom_id = $row['proom_id'];
1353  $priv_rooms[$proom_id] = $row['parent_id'];
1354  }
1355 
1356  return $priv_rooms;
1357  }
Create styles array
The data for the language used.
global $ilDB

◆ getRefIdByRoomId()

ilChatroom::getRefIdByRoomId (   $room_id)

Returns ref_id of given room_id ilDBInterface $ilDB.

Parameters
integer$room_id
Returns
integer

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

References $ilDB, $query, $res, $row, and array.

1366  {
1367  global $ilDB;
1368 
1369  $query = "
1370  SELECT objr.ref_id
1371  FROM object_reference objr
1372 
1373  INNER JOIN chatroom_settings cs
1374  ON cs.object_id = objr.obj_id
1375 
1376  INNER JOIN object_data od
1377  ON od.obj_id = cs.object_id
1378 
1379  WHERE cs.room_id = %s
1380  ";
1381 
1382  $types = array('integer');
1383  $values = array($room_id);
1384 
1385  $res = $ilDB->queryF($query, $types, $values);
1386 
1387  $row = $ilDB->fetchAssoc($res);
1388 
1389  return $row['ref_id'];
1390  }
Create styles array
The data for the language used.
global $ilDB

◆ getRoomId()

ilChatroom::getRoomId ( )

Returns roomID from $this->roomId.

Returns
integer

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

References $roomId.

Referenced by getBannedUsers(), getHistory(), getSessions(), isUserBanned(), ilChatroomViewGUI\renderFileUploadForm(), and unbanUser().

704  {
705  return $this->roomId;
706  }
+ Here is the caller graph for this function:

◆ getSessions()

ilChatroom::getSessions ( ilChatroomUser  $user)

Returns all session from user Returns all from sessionTable where user_id matches userId from given $user object.

ilDBInterface $ilDB

Parameters
ilChatroomUser$user
Returns
array

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

References $ilDB, $query, $result, $row, array, and getRoomId().

902  {
903  global $ilDB;
904 
905  $query = 'SELECT * FROM ' . self::$sessionTable
906  . ' WHERE room_id = ' .
907  $ilDB->quote($this->getRoomId(), 'integer') .
908  ' ORDER BY connected DESC';
909 
910  $rset = $ilDB->query($query);
911 
912  $result = array();
913 
914  while($row = $ilDB->fetchAssoc($rset))
915  {
916  $result[] = $row;
917  }
918 
919  return $result;
920  }
getRoomId()
Returns roomID from $this->roomId.
$result
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ getSetting()

ilChatroom::getSetting (   $name)

Returns setting from $this->settings array by given name.

Parameters
string$name
Returns
mixed

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

References settings().

Referenced by disconnectUsers(), getDescription(), getTitle(), and ilChatroomViewGUI\renderFileUploadForm().

307  {
308  return $this->settings[$name];
309  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

ilChatroom::getSettings ( )

Returns $this->settings array.

Returns
array

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

References $settings.

573  {
574  return $this->settings;
575  }

◆ getTitle()

ilChatroom::getTitle ( )

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

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

Referenced by isOwnerOfPrivateRoom().

1077  {
1078  if(!$this->object)
1079  {
1080  $this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
1081  }
1082 
1083  return $this->object->getTitle();
1084  }
getSetting($name)
Returns setting from $this->settings array by given name.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUniquePrivateRoomTitle()

ilChatroom::getUniquePrivateRoomTitle (   $title)

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

References $ilDB, $query, $res, $row, $title, and array.

Referenced by ilChatroomViewGUI\renderFileUploadForm().

1256  {
1257  global $ilDB;
1258 
1259  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s and closed = 0';
1260  $rset = $ilDB->queryF($query, array('integer'), array($this->roomId));
1261 
1262  $titles = array();
1263 
1264  while($row = $ilDB->fetchAssoc($rset))
1265  {
1266  $titles[] = $row['title'];
1267  }
1268 
1269  $suffix = '';
1270  $i = 0;
1271  do
1272  {
1273  if(!in_array($title . $suffix, $titles))
1274  {
1275  $title .= $suffix;
1276  break;
1277  }
1278 
1279  ++$i;
1280 
1281  $suffix = ' (' . $i . ')';
1282  }
1283  while(true);
1284 
1285  return $title;
1286  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ 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 131 of file class.ilChatroom.php.

References setSetting().

132  {
133  $this->roomId = $rowdata['room_id'];
134 
135  foreach($this->availableSettings as $setting => $type)
136  {
137  if(isset($rowdata[$setting]))
138  {
139  settype($rowdata[$setting], $this->availableSettings[$setting]);
140  $this->setSetting($setting, $rowdata[$setting]);
141  }
142  }
143  }
setSetting($name, $value)
Sets given name and value as setting into $this->settings array.
+ Here is the call graph for this function:

◆ inviteUserToPrivateRoomByLogin()

ilChatroom::inviteUserToPrivateRoomByLogin (   $login,
  $proom_id 
)

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

References $ilDB, $query, ilObjUser\_lookupId(), and array.

1105  {
1106  global $ilDB;
1107  $user_id = ilObjUser::_lookupId($login);
1108  $this->inviteUserToPrivateRoom($user_id, $proom_id);
1109  }
static _lookupId($a_user_str)
Lookup id by login.
global $ilDB
+ Here is the call graph for this function:

◆ isAllowedToEnterPrivateRoom()

ilChatroom::isAllowedToEnterPrivateRoom (   $chat_userid,
  $proom_id 
)

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

References $ilDB, $query, $row, and array.

602  {
603  //echo call_user_func_array('sprintf', array_merge(array($query), $values));
604  global $ilDB;
605 
606  $query = 'SELECT count(user_id) cnt FROM ' . self::$privateRoomsAccessTable .
607  ' WHERE proom_id = %s AND user_id = %s';
608 
609  $types = array('integer', 'integer');
610  $values = array($proom_id, $chat_userid);
611  $rset = $ilDB->queryF($query, $types, $values);
612 
613  if($rset && ($row = $ilDB->fetchAssoc($rset)) && $row['cnt'] == 1)
614  return true;
615 
616  $query = 'SELECT count(*) cnt FROM ' . self::$privateRoomsTable .
617  ' WHERE proom_id = %s AND owner = %s';
618 
619  $types = array('integer', 'integer');
620  $values = array($proom_id, $chat_userid);
621  $rset = $ilDB->queryF($query, $types, $values);
622 
623  if($rset && ($row = $ilDB->fetchAssoc($rset)) && $row['cnt'] == 1)
624  return true;
625 
626  return false;
627  }
Create styles array
The data for the language used.
global $ilDB

◆ isOwnerOfPrivateRoom()

ilChatroom::isOwnerOfPrivateRoom (   $user_id,
  $proom_id 
)

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

References $ilDB, $lng, $query, array, ilNotificationConfig\DEFAULT_TTS, getChatURL(), ilObjectFactory\getInstanceByObjId(), getTitle(), and ilNotificationConfig\TTL_LONG.

954  {
955  global $ilDB;
956 
957  $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s AND owner = %s';
958  $types = array('integer', 'integer');
959  $values = array($proom_id, $user_id);
960 
961  $rset = $ilDB->queryF($query, $types, $values);
962 
963  if($rset && $ilDB->fetchAssoc($rset))
964  {
965  return true;
966  }
967  return false;
968  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ isSubscribed()

ilChatroom::isSubscribed (   $chat_userid)

Returns true if entry exists in userTable matching given $chat_userid and $this->roomId.

ilDBInterface $ilDB

Parameters
integer$chat_userid
Returns
boolean

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

References $ilDB, $query, $row, and array.

Referenced by ilChatroomViewGUI\renderFileUploadForm().

585  {
586  global $ilDB;
587 
588  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
589  ' WHERE room_id = %s AND user_id = %s';
590 
591  $types = array('integer', 'integer');
592  $values = array($this->roomId, $chat_userid);
593  $rset = $ilDB->queryF($query, $types, $values);
594 
595  if($rset && ($row = $ilDB->fetchAssoc($rset)) && $row['cnt'] == 1)
596  return true;
597 
598  return false;
599  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ isUserBanned()

ilChatroom::isUserBanned (   $user_id)

Returns true if there's an entry in banTable matching roomId and given $user_id ilDBInterface $ilDB.

Parameters
integer$user_id
Returns
boolean

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

References $ilDB, $query, $row, array, and getRoomId().

807  {
808  global $ilDB;
809 
810  $query = 'SELECT COUNT(user_id) cnt FROM ' . self::$banTable . ' WHERE user_id = %s AND room_id = %s';
811 
812  $types = array('integer', 'integer');
813  $values = array($user_id, $this->getRoomId());
814 
815  $rset = $ilDB->queryF($query, $types, $values);
816 
817  if($rset && ($row = $ilDB->fetchAssoc($rset)) && $row['cnt'])
818  {
819  return true;
820  }
821 
822  return false;
823  }
getRoomId()
Returns roomID from $this->roomId.
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ listUsersInPrivateRoom()

ilChatroom::listUsersInPrivateRoom (   $private_room_id)

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

References $ilDB, $query, $row, and array.

Referenced by getActivePrivateRooms().

1163  {
1164  global $ilDB;
1165 
1166  $query = '
1167  SELECT chatroom_users.user_id FROM ' . self::$privateSessionsTable . '
1168  INNER JOIN chatroom_users ON chatroom_users.user_id = ' . self::$privateSessionsTable . '.user_id WHERE proom_id = %s AND disconnected = 0
1169  ';
1170  $types = array('integer');
1171  $values = array($private_room_id);
1172  $rset = $ilDB->queryF($query, $types, $values);
1173 
1174  $users = array();
1175 
1176  while($row = $ilDB->fetchAssoc($rset))
1177  {
1178  $users[$row['user_id']] = $row['user_id'];
1179  }
1180 
1181  return array_values($users);
1182  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ lookupPrivateRoomTitle()

static ilChatroom::lookupPrivateRoomTitle (   $proom_id)
static

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

References $ilDB, $query, $row, and array.

Referenced by ilContactGUI\inviteToChat().

1087  {
1088  global $ilDB;
1089 
1090  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s';
1091  $types = array('integer');
1092  $values = array($proom_id);
1093 
1094  $rset = $ilDB->queryF($query, $types, $values);
1095 
1096  if($row = $ilDB->fetchAssoc($rset))
1097  {
1098  return $row['title'];
1099  }
1100 
1101  return 'unkown';
1102  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ phpTypeToMDBType()

ilChatroom::phpTypeToMDBType (   $type)
private

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

Referenced by saveSettings().

368  {
369  switch($type)
370  {
371  case 'string':
372  return 'text';
373  default:
374  return $type;
375  }
376 
377  }
+ Here is the caller graph for this function:

◆ save()

ilChatroom::save ( )

Saves settings using $this->settings.

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

References saveSettings(), and settings().

315  {
316  $this->saveSettings($this->settings);
317  }
settings()
Definition: settings.php:2
saveSettings(array $settings)
Saves settings into settingsTable using given settings array.
+ Here is the call graph for this function:

◆ saveFileUploadToDb()

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

Saves information about file uploads in DB.

ilDBInterface $ilDB

Parameters
integer$user_id
string$filename
string$type

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

References $filename, $ilDB, array, and time.

734  {
735  global $ilDB;
736 
737  $upload_id = $ilDB->nextId(self::$uploadTable);
738 
739  $ilDB->insert(
740  self::$uploadTable,
741  array(
742  'upload_id' => array('integer', $upload_id),
743  'room_id' => array('integer', $this->roomId),
744  'user_id' => array('integer', $user_id),
745  'filename' => array('text', $filename),
746  'filetype' => array('text', $type),
747  'timestamp' => array('integer', time())
748  )
749  );
750  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ saveSettings()

ilChatroom::saveSettings ( array  $settings)

Saves settings into settingsTable using given settings array.

ilDBInterface $ilDB

Parameters
array$settings

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

References $ilDB, array, and phpTypeToMDBType().

Referenced by save().

325  {
326  global $ilDB;
327 
328  $localSettings = array();
329 
330  foreach($this->availableSettings as $setting => $type)
331  {
332  if(isset($settings[$setting]))
333  {
334  if($type == 'boolean')
335  {
336  $settings[$setting] = (boolean)$settings[$setting];
337  }
338  $localSettings[$setting] = array($this->phpTypeToMDBType($type), $settings[$setting]);
339  }
340  }
341 
342  if(!$localSettings['room_type'][1])
343  {
344  $localSettings['room_type'][1] = 'repository';
345  }
346 
347  if($this->roomId)
348  {
349  $ilDB->update(
350  self::$settingsTable,
351  $localSettings,
352  array('room_id' => array('integer', $this->roomId))
353  );
354  }
355  else
356  {
357  $this->roomId = $ilDB->nextId(self::$settingsTable);
358 
359  $localSettings['room_id'] = array(
360  $this->availableSettings['room_id'], $this->roomId
361  );
362 
363  $ilDB->insert(self::$settingsTable, $localSettings);
364  }
365  }
Create styles array
The data for the language used.
global $ilDB
phpTypeToMDBType($type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSetting()

ilChatroom::setSetting (   $name,
  $value 
)

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

Parameters
string$name
mixed$value

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

References settings().

Referenced by initialize().

151  {
152  $this->settings[$name] = $value;
153  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subscribeUserToPrivateRoom()

ilChatroom::subscribeUserToPrivateRoom (   $room_id,
  $user_id 
)

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

References $ilDB, array, time, and userIsInPrivateRoom().

1185  {
1186  global $ilDB;
1187 
1188  if(!$this->userIsInPrivateRoom($room_id, $user_id))
1189  {
1190  $id = $ilDB->nextId(self::$privateSessionsTable);
1191  $ilDB->insert(
1192  self::$privateSessionsTable,
1193  array(
1194  'psess_id' => array('integer', $id),
1195  'proom_id' => array('integer', $room_id),
1196  'user_id' => array('integer', $user_id),
1197  'connected' => array('integer', time()),
1198  'disconnected' => array('integer', 0),
1199  )
1200  );
1201  }
1202  }
userIsInPrivateRoom($room_id, $user_id)
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ unbanUser()

ilChatroom::unbanUser (   $user_id)

Deletes entry from banTable matching roomId and given $user_id and returns true if sucessful.

ilDBInterface $ilDB

Parameters
mixed$user_id
Returns
boolean

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

References $ilDB, $query, array, and getRoomId().

783  {
784  global $ilDB;
785 
786  if(!is_array($user_id))
787  {
788  $user_id = array($user_id);
789  }
790 
791  $query = 'DELETE FROM ' . self::$banTable . ' WHERE room_id = %s AND ' . $ilDB->in('user_id', $user_id, false, 'integer');
792 
793  $types = array('integer');
794  $values = array($this->getRoomId());
795 
796  return $ilDB->manipulateF($query, $types, $values);
797  }
getRoomId()
Returns roomID from $this->roomId.
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ unsubscribeUserFromPrivateRoom()

ilChatroom::unsubscribeUserFromPrivateRoom (   $room_id,
  $user_id 
)

ilDBInterface $ilDB

Parameters
integer$room_id
integer$user_id

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

References $ilDB, array, and time.

1223  {
1224  global $ilDB;
1225 
1226  $ilDB->update(
1227  self::$privateSessionsTable,
1228  array(
1229  'disconnected' => array('integer', time())
1230  ),
1231  array(
1232  'proom_id' => array('integer', $room_id),
1233  'user_id' => array('integer', $user_id)
1234  )
1235  );
1236  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ userIsInPrivateRoom()

ilChatroom::userIsInPrivateRoom (   $room_id,
  $user_id 
)

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

References $ilDB, $query, and array.

Referenced by subscribeUserToPrivateRoom().

1205  {
1206  global $ilDB;
1207 
1208  $query = 'SELECT proom_id id FROM ' . self::$privateSessionsTable . ' WHERE user_id = %s AND proom_id = %s AND disconnected = 0';
1209  $types = array('integer', 'integer');
1210  $values = array($user_id, $room_id);
1211  $rset = $ilDB->queryF($query, $types, $values);
1212  if($ilDB->fetchAssoc($rset))
1213  return true;
1214  return false;
1215  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $availableSettings

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

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

◆ $banTable

ilChatroom::$banTable = 'chatroom_bans'
staticprivate

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

◆ $historyTable

ilChatroom::$historyTable = 'chatroom_history'
staticprivate

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

◆ $object

ilChatroom::$object
private

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

◆ $privateRoomsAccessTable

ilChatroom::$privateRoomsAccessTable = 'chatroom_proomaccess'
staticprivate

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

◆ $privateRoomsTable

ilChatroom::$privateRoomsTable = 'chatroom_prooms'
staticprivate

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

◆ $privateSessionsTable

ilChatroom::$privateSessionsTable = 'chatroom_psessions'
staticprivate

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

◆ $roomId

ilChatroom::$roomId
private

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

Referenced by getRoomId().

◆ $sessionTable

ilChatroom::$sessionTable = 'chatroom_sessions'
staticprivate

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

◆ $settings

ilChatroom::$settings = array()
private

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

Referenced by addPrivateRoom(), and getSettings().

◆ $settingsTable

ilChatroom::$settingsTable = 'chatroom_settings'
staticprivate

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

◆ $uploadTable

ilChatroom::$uploadTable = 'chatroom_uploads'
staticprivate

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

◆ $userTable

ilChatroom::$userTable = 'chatroom_users'
staticprivate

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


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