ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilChatroom Class Reference

Class ilChatroom. More...

+ Collaboration diagram for ilChatroom:

Public Member Functions

 getTitle ()
 
 getDescription ()
 
 getSetting ($name)
 Returns setting from $this->settings array by given name. More...
 
 setSetting ($name, $value)
 Sets given name and value as setting into $this->settings array. More...
 
 save ()
 Saves settings using $this->settings. 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...
 
 saveSettings (array $settings)
 Saves settings into settingsTable using given settings array. More...
 
 getSettings ()
 Returns $this->settings array. More...
 
 initialize (array $rowdata)
 Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $this->availableSettings. More...
 
 getRoomId ()
 Returns roomID from $this->roomId. More...
 
 isSubscribed ($chat_userid)
 Returns true if entry exists in userTable matching given $chat_userid and $this->roomId. More...
 
 isAllowedToEnterPrivateRoom ($chat_userid, $proom_id)
 
 disconnectAllUsersFromAllRooms ()
 Deletes all entrys from userTable. More...
 
 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...
 
 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. 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. 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. More...
 
 addPrivateRoom ($title, ilChatroomUser $owner, $settings)
 
 closePrivateRoom ($id)
 
 isOwnerOfPrivateRoom ($user_id, $proom_id)
 
 getChatURL ($gui, $scope_id=0)
 ilCtrl $ilCtrl More...
 
 inviteUserToPrivateRoomByLogin ($login, $proom_id)
 
 getActivePrivateRooms ($userid)
 
 listUsersInPrivateRoom ($private_room_id)
 
 userIsInPrivateRoom ($room_id, $user_id)
 
 subscribeUserToPrivateRoom ($room_id, $user_id)
 
 unsubscribeUserFromPrivateRoom ($room_id, $user_id)
 ilDB $ilDB More...
 
 countActiveUsers ()
 
 getUniquePrivateRoomTitle ($title)
 
 getPrivateSubRooms ($parent_room, $user_id)
 
 getRefIdByRoomId ($room_id)
 Returns ref_id of given room_id. More...
 
 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. More...
 
static lookupPrivateRoomTitle ($proom_id)
 
static findDeletablePrivateRooms ()
 

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

Member Function Documentation

◆ addHistoryEntry()

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

Inserts entry into historyTable.

Todo:
$recipient, $publicMessage speichern

ilDBMySQL $ilDB

Parameters
string$message
string$recipient
boolean$publicMessage

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

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

Referenced by ilChatroomViewTask\cancelJoin().

172  {
173  global $ilDB;
174 
175  $subRoom = 0;
176  if (is_array($message)) {
177  $subRoom = (int) $message['sub'];
178  }
179  else if (is_object($message)) {
180  $subRoom = (int) $message->sub;
181  }
182 
183  $ilDB->insert(
184  self::$historyTable,
185  array(
186  'room_id' => array('integer', $this->roomId),
187  'sub_room' => array('integer', $subRoom),
188  'message' => array('text', json_encode($message)),
189  'timestamp' => array('integer', time()),
190  )
191  );
192  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addPrivateRoom()

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

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

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

Referenced by ilChatroomServerConnector\createPrivateRoom().

845  {
846  global $ilDB;
847 
848  $nextId = $ilDB->nextId('chatroom_prooms');
849 
850  $ilDB->insert(
851  self::$privateRoomsTable,
852  array(
853  'proom_id' => array('integer', $nextId),
854  'parent_id' => array('integer', $this->roomId),
855  'title' => array('text', $title),
856  'owner' => array('integer', $owner->getUserId()),
857  'created' => array('integer', time()),
858  'is_public' => array('integer', $settings['public']),
859  )
860  );
861 
862  return $nextId;
863  }
getUserId()
Returns Ilias User ID.
global $ilDB
+ 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.

ilDBMySQL $ilDB

Parameters
integer$user_id
string$comment

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

References $comment, and $ilDB.

678  {
679  global $ilDB;
680 
681  $ilDB->insert(
682  self::$banTable,
683  array(
684  'room_id' => array('integer', $this->roomId),
685  'user_id' => array('integer', $user_id),
686  'timestamp' => array('integer', time()),
687  'remark' => array('text', $comment),
688  )
689  );
690  }
$comment
Definition: buildRTE.php:83
global $ilDB

◆ byObjectId()

static ilChatroom::byObjectId (   $object_id)
static

Returns ilChatroom object by given $object_id.

ilDBMySQL $ilDB

Parameters
integer$object_id
Returns
ilChatroom

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

References $ilDB, $query, and $row.

Referenced by ilChatroomKickTask\__construct(), ilChatroomBanTask\active(), ilChatroomHistoryTask\byDay(), ilChatroomInviteUsersToPrivateRoomTask\byId(), ilChatroomHistoryTask\bySession(), ilChatroomViewTask\cancelJoin(), ilChatroomServerHandler\cleanupPrivateRooms(), ilObjChatroom\cloneObject(), ilChatroomPrivateRoomTask\create(), ilChatroomPrivateRoomTask\delete(), ilChatroomPrivateRoomTask\enter(), ilChatroomInitialTask\executeDefault(), ilChatroomClearTask\executeDefault(), ilChatroomPostMessageTask\executeDefault(), ilChatroomBlockGUI\getChatroomSelectionList(), ilChatroomPrivateRoomTask\leave(), ilChatroomPrivateRoomTask\listUsers(), ilChatroomBanTask\show(), ilChatroomHistoryTask\showMessages(), ilChatroomKickTask\sub(), and ilChatroomUploadFileTask\uploadFile().

423  {
424  global $ilDB;
425  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE object_id = %s';
426  $types = array('integer');
427  $values = array($object_id);
428  $rset = $ilDB->queryF( $query, $types, $values );
429 
430  if( $row = $ilDB->fetchAssoc( $rset ) )
431  {
432  $room = new self();
433  $room->initialize( $row );
434  return $room;
435  }
436  }
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.

ilDBMySQL $ilDB

Parameters
integer$room_id
Returns
ilChatroom

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

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

Referenced by ilChatroomServerHandler\disconnectedUsers(), and ilMailAddressbookGUI\search().

446  {
447  global $ilDB;
448 
449  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE room_id = %s';
450 
451  $types = array('integer');
452  $values = array($room_id);
453 
454  $rset = $ilDB->queryF( $query, $types, $values );
455 
456  if( $row = $ilDB->fetchAssoc( $rset ) )
457  {
458  $room = new self();
459  $room->initialize( $row );
460 
461  if ($initObject) {
462  $room->object = ilObjectFactory::getInstanceByObjId($row['object_id']);
463  }
464 
465  return $room;
466  }
467  }
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
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 101 of file class.ilChatroom.php.

References $lng, and $ref_id.

Referenced by ilMailAddressbookGUI\search(), and ilChatroomKickTask\sub().

102  {
103  global $rbacsystem, $lng;
104 
105  if( !is_array($permissions) )
106  {
107  $permissions = array( $permissions );
108  }
109 
110  foreach( $permissions as $permission )
111  {
112  if( !$rbacsystem->checkAccessOfUser($usr_id, $permission, $ref_id ) )
113  {
114  return false;
115  }
116  }
117 
118  return true;
119  }
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:40
+ 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 67 of file class.ilChatroom.php.

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

Referenced by ilChatroomSettingsTask\__construct(), ilChatroomKickTask\__construct(), ilChatroomInfoTask\__construct(), ilChatroomBanTask\active(), ilChatroomInviteUsersToPrivateRoomTask\byId(), ilChatroomViewTask\cancelJoin(), ilChatroomViewTask\checkPrivHosts(), ilChatroomPrivateRoomTask\create(), ilChatroomPrivateRoomTask\enter(), ilChatroomClearTask\executeDefault(), ilChatroomPostMessageTask\executeDefault(), ilChatroomBanTask\show(), ilChatroomHistoryTask\showMessages(), ilChatroomUploadFileTask\uploadFile(), and ilChatroomSmileyTask\view().

68  {
69  global $rbacsystem, $lng;
70 
71  if( !is_array($permissions) )
72  {
73  $permissions = array( $permissions );
74  }
75 
76  foreach( $permissions as $permission )
77  {
78  if( !$rbacsystem->checkAccess( $permission, $ref_id ) )
79  {
80  if ($send_info) {
81  ilUtil::sendFailure( $lng->txt("permission_denied"), true );
82  }
83  return false;
84  }
85  }
86 
87  return true;
88  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearMessages()

ilChatroom::clearMessages (   $sub_room)

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

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

1390  {
1391  global $ilDB;
1392 
1393  $ilDB->queryF(
1394  'DELETE FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = %s',
1395  array('integer', 'integer'),
1396  array($this->roomId, (int)$sub_room)
1397  );
1398 
1399  if ($sub_room) {
1400  $ilDB->queryF(
1401  'DELETE FROM ' . self::$privateSessionsTable . ' WHERE proom_id = %s AND disconnected < %s',
1402  array('integer', 'integer'),
1403  array($sub_room, time())
1404  );
1405  }
1406  else {
1407  $ilDB->queryF(
1408  'DELETE FROM ' . self::$sessionTable . ' WHERE room_id = %s AND disconnected < %s',
1409  array('integer', 'integer'),
1410  array($this->roomId, time())
1411  );
1412  }
1413  }
global $ilDB

◆ closePrivateRoom()

ilChatroom::closePrivateRoom (   $id)

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

References $ilDB.

866  {
867  global $ilDB;
868 
869  $ilDB->manipulateF(
870  'UPDATE ' . self::$privateRoomsTable . ' SET closed = %s WHERE proom_id = %s',
871  array('integer', 'integer'),
872  array(time(), $id)
873  );
874  }
global $ilDB

◆ countActiveUsers()

ilChatroom::countActiveUsers ( )

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

References $ilDB, $query, and $row.

1137  {
1138  global $ilDB;
1139 
1140  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
1141  ' WHERE room_id = %s';
1142 
1143  $types = array('integer');
1144  $values = array($this->roomId);
1145  $rset = $ilDB->queryF( $query, $types, $values );
1146 
1147  if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
1148  return $row['cnt'];
1149 
1150  return 0;
1151  }
global $ilDB

◆ disconnectAllUsersFromAllRooms()

ilChatroom::disconnectAllUsersFromAllRooms ( )

Deletes all entrys from userTable.

ilDBMySQL $ilDB

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

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

References $ilDB.

Referenced by ilChatroomServerHandler\serverStarted().

557  {
558  global $ilDB;
559 
560  $ilDB->manipulate( 'DELETE FROM ' . self::$userTable );
561  $ilDB->manipulate( 'UPDATE ' . self::$privateRoomsTable . ' SET closed = ' . $ilDB->quote( time() ,'integer') . ' WHERE closed = 0 OR closed IS NULL');
562  $ilDB->manipulate( 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = ' . $ilDB->quote( time() ,'integer') . ' WHERE disconnected = 0 OR disconnected IS NULL');
566  }
global $ilDB
+ 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 277 of file class.ilChatroom.php.

References disconnectUsers().

278  {
279  $this->disconnectUsers( array($user_id) );
280  }
disconnectUsers(array $userIds)
Disconnects users by deleting userdata from userTable using given userId array.
+ 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.

ilDB $ilDB

Parameters
array$userIds

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

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

Referenced by disconnectUser().

292  {
293  global $ilDB;
294 
295  $query = 'SELECT * FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
296  $ilDB->in( 'user_id', $userIds, false, 'integer' );
297 
298  $types = array('integer');
299  $values = array($this->roomId);
300  $rset = $ilDB->queryF( $query, $types, $values );
301 
302  if( $row = $ilDB->fetchAssoc( $rset ) )
303  {
304  $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s';
305  $rset_prooms = $ilDB->queryF($query, array('integer'), array($this->roomId));
306 
307  $prooms = array();
308 
309  while($row_prooms = $ilDB->fetchAssoc($rset_prooms)) {
310  $prooms[] = $row_prooms['proom_id'];
311  }
312 
313  if (true || $this->getSetting( 'enable_history' )) {
314  $query = 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = %s WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
315  $ilDB->manipulateF($query, array('integer'), array(time()));
316  }
317  else {
318  $query = 'DELETE FROM ' . self::$privateSessionsTable . ' WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
319  $ilDB->manipulate($query);
320  }
321 
322  $query = 'DELETE FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
323  $ilDB->in( 'user_id', $userIds, false, 'integer' );
324 
325  $types = array('integer');
326  $values = array($this->roomId);
327  $ilDB->manipulateF( $query, $types, $values );
328 
329  do
330  {
331  if ($this->getSetting( 'enable_history' )) {
332  $ilDB->insert(
333  self::$sessionTable,
334  array(
335  'room_id' => array('integer', $this->roomId),
336  'user_id' => array('integer', $row['user_id']),
337  'userdata' => array('text', $row['userdata']),
338  'connected' => array('integer', $row['connected']),
339  'disconnected' => array('integer', time()),
340  )
341  );
342  }
343  }
344  while( $row = $ilDB->fetchAssoc( $rset ) );
345  }
346 
347  }
getSetting($name)
Returns setting from $this->settings array by given name.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDeletablePrivateRooms()

static ilChatroom::findDeletablePrivateRooms ( )
static

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

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

Referenced by ilChatroomServerHandler\cleanupPrivateRooms().

1181  {
1182  global $ilDB;
1183 
1184  $query = '
1185  SELECT private_rooms.proom_id id, MIN(disconnected) min_disconnected, MAX(disconnected) max_disconnected
1186  FROM ' . self::$privateSessionsTable . ' private_sessions
1187  INNER JOIN '.self::$privateRoomsTable.' private_rooms
1188  ON private_sessions.proom_id = private_rooms.proom_id
1189  WHERE closed = 0
1190  GROUP BY private_rooms.proom_id
1191  HAVING MIN(disconnected) > 0 AND MAX(disconnected) < %s';
1192  $rset = $ilDB->queryF(
1193  $query,
1194  array('integer'),
1195  array(time() + 60 * 5)
1196  );
1197 
1198  $rooms = array();
1199 
1200  while ($row = $ilDB->fetchAssoc($rset)) {
1201  $rooms[$row['id']] = $row['id'];
1202  }
1203 
1204  $query = 'SELECT DISTINCT proom_id, room_id, object_id FROM ' . self::$privateRoomsTable
1205  . ' INNER JOIN ' . self::$settingsTable . ' ON parent_id = room_id '
1206  . ' WHERE ' . $ilDB->in('proom_id', $rooms, false, 'integer');
1207 
1208  $rset = $ilDB->query($query);
1209  $rooms = array();
1210  while($row = $ilDB->fetchAssoc($rset)) {
1211  $rooms[] = array(
1212  'proom_id' => $row['proom_id'],
1213  'room_id' => $row['room_id'],
1214  'object_id' => $row['object_id']
1215  );
1216  }
1217 
1218  return $rooms;
1219  }
global $ilDB
+ Here is the caller graph for this function:

◆ getActivePrivateRooms()

ilChatroom::getActivePrivateRooms (   $userid)

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

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

Referenced by ilChatroomViewTask\cancelJoin().

1043  {
1044  global $ilDB;
1045 
1046  $query = '
1047  SELECT roomtable.title, roomtable.proom_id, accesstable.user_id id, roomtable.owner owner FROM ' . self::$privateRoomsTable . ' roomtable
1048  LEFT JOIN '.self::$privateRoomsAccessTable.' accesstable ON roomtable.proom_id = accesstable.proom_id AND accesstable.user_id = %s
1049  WHERE parent_id = %s AND (closed = 0 OR closed IS NULL) AND (accesstable.user_id IS NOT NULL OR roomtable.owner = %s)';
1050  $types = array('integer', 'integer', 'integer');
1051  $values = array($userid, $this->roomId, $userid);
1052  $rset = $ilDB->queryF( $query, $types, $values );
1053  $rooms = array();
1054 
1055  while( $row = $ilDB->fetchAssoc( $rset ) )
1056  {
1057  $row['active_users'] = $this->listUsersInPrivateRoom($row['id']);
1058  $row['owner'] = $row['owner'];
1059  $rooms[$row['proom_id']] = $row;
1060  }
1061 
1062  return $rooms;
1063  }
listUsersInPrivateRoom($private_room_id)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBannedUsers()

ilChatroom::getBannedUsers ( )

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

ilDBMySQL $ilDB

Returns
array

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

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

750  {
751  global $ilDB;
752 
753  $query = 'SELECT * FROM ' . self::$banTable . ' WHERE room_id = %s ';
754  $types = array('integer');
755  $values = array($this->getRoomId());
756  $rset = $ilDB->queryF( $query, $types, $values );
757  $result = array();
758 
759  if( $rset )
760  {
761  while( $row = $ilDB->fetchAssoc( $rset ) )
762  {
763  if( $row['user_id'] > 0 )
764  {
765  $user = new ilObjUser( $row['user_id'] );
766  $userdata = array(
767  'user_id' => $user->getId(),
768  'firstname' => $user->getFirstname(),
769  'lastname' => $user->getLastname(),
770  'login' => $user->getLogin(),
771  'remark' => $row['remark']
772  );
773 
774  $result[] = $userdata;
775  }
776  else
777  {
778  //@todo anonymous user
779  }
780  }
781  }
782 
783  return $result;
784  }
getRoomId()
Returns roomID from $this->roomId.
$result
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 920 of file class.ilChatroom.php.

References $lng, ilLink\_getStaticLink(), ilObjectFactory\getInstanceByObjId(), and getTitle().

921  {
922  include_once 'Services/Link/classes/class.ilLink.php';
923 
924  $url = '';
925 
926  if(is_object($gui))
927  {
928  if($scope_id)
929  {
930  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType(), true, '_'.$scope_id);
931  }
932  else
933  {
934  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType());
935  }
936  }
937 
938  return $url;
939  }
+ Here is the call 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.

ilDBMySQL $ilDB

Returns
array

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

References $ilDB, $query, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

254  {
255  global $ilDB;
256 
257  $query = 'SELECT userdata FROM ' . self::$userTable . ' WHERE room_id = %s';
258  $types = array('integer');
259  $values = array($this->roomId);
260  $rset = $ilDB->queryF( $query, $types, $values );
261  $users = array();
262 
263  while( $row = $ilDB->fetchAssoc( $rset ) )
264  {
265  $users[] = json_decode( $row['userdata'] );
266  }
267 
268  return $users;
269  }
global $ilDB
+ Here is the caller graph for this function:

◆ getDescription()

ilChatroom::getDescription ( )

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

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

122  {
123  if (!$this->object)
124  {
125  $this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
126  }
127 
128  return $this->object->getDescription();
129  }
getSetting($name)
Returns setting from $this->settings array by given name.
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.

ilDBMySQL $ilDB

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

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

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

579  {
580  global $ilDB, $ilUser;
581 
582  $join = '';
583 
584  if ($proom_id) {
585  $join .= ' INNER JOIN ' . self::$privateSessionsTable .
586  ' pSessionTable ON pSessionTable.user_id = ' .
587  $ilDB->quote( $restricted_session_userid, 'integer' ) .
588  ' AND historyTable.sub_room = pSessionTable.proom_id AND timestamp >= pSessionTable.connected AND timestamp <= pSessionTable.disconnected ';
589  }
590 
591  $query = 'SELECT historyTable.* FROM ' . self::$historyTable . ' historyTable ' .
592  $join . ' WHERE historyTable.room_id = ' . $this->getRoomId();
593 
594  $filter = array();
595 
596  if( $from != null )
597  {
598  $filter[] = 'timestamp >= ' . $ilDB->quote( $from->getUnixTime(), 'integer' );
599  }
600 
601  if( $to != null )
602  {
603  $filter[] = 'timestamp <= ' . $ilDB->quote( $to->getUnixTime(), 'integer' );
604  }
605 
606  if( $filter )
607  $query .= ' AND ' . join( ' AND ', $filter );
608  $query .= ' ORDER BY timestamp ASC';
609 
610  $rset = $ilDB->query( $query );
611  $result = array();
612 
613  while( $row = $ilDB->fetchAssoc( $rset ) )
614  {
615  $row['message'] = json_decode( $row['message'] );
616  $row['message']->timestamp = $row['timestamp'];
617  if ($row['message']->public !== null && !$row['message']->public && !in_array($ilUser->getId(), explode(',', $row['recipients']))) {
618  continue;
619  }
620 
621  $result[] = $row;
622  }
623  return $result;
624  }
getRoomId()
Returns roomID from $this->roomId.
$result
getUnixTime()
get unix time
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ Here is the call graph for this function:

◆ getLastMessages()

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

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

References $ilDB, $results, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

1329  {
1330  global $ilDB;
1331 
1332  // There is currently no way to check if a message is private or not
1333  // by sql. So we fetch twice as much as we need and hope that there
1334  // are not more than $number private messages.
1335  $ilDB->setLimit($number * 2);
1336  $rset = $ilDB->queryF('SELECT * FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = 0 ORDER BY timestamp DESC', array('integer'), array($this->roomId));
1337 
1338  $result_count = 0;
1339  $results = array();
1340  while(($row = $ilDB->fetchAssoc($rset)) && $result_count < $number) {
1341  $tmp = json_decode($row['message']);
1342  if ($chatuser !== null && $tmp->public == 0 && $tmp->recipients) {
1343  if (in_array($chatuser->getUserId(), explode(',',$tmp->recipients))) {
1344  $results[] = $tmp;
1345  ++$result_count;
1346  }
1347  }
1348  else if ($tmp->public == 1) {
1349  $results[] = $tmp;
1350  ++$result_count;
1351  }
1352 
1353  }
1354  return $results;
1355  }
$results
global $ilDB
+ Here is the caller 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.

ilDBMySQL $ilDB

Parameters
ilChatroomUser$user
Returns
array

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

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

797  {
798  global $ilDB;
799 
800  $query = 'SELECT * FROM ' . self::$sessionTable . ' WHERE user_id = ' .
801  $ilDB->quote( $user->getUserId(), 'integer' ) .
802  ' ORDER BY connected DESC';
803 
804  $ilDB->setLimit( 1 );
805  $rset = $ilDB->query( $query );
806 
807  if( $row = $ilDB->fetchAssoc( $rset ) )
808  {
809  return $row;
810  }
811  }
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 626 of file class.ilChatroom.php.

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

626  {
627  global $ilDB;
628 
629  $query = 'SELECT proom_id, title FROM ' . self::$privateRoomsTable . ' WHERE proom_id IN (
630  SELECT proom_id FROM '.self::$privateSessionsTable.' WHERE connected >= %s AND disconnected <= %s AND user_id = %s
631 
632  ) AND parent_id = %s';
633 
634  $rset = $ilDB->queryF($query, array('integer','integer','integer','integer'), array($from->getUnixTime(), $to->getUnixTime(), $user_id, $room_id));
635  $result = array();
636  while( $row = $ilDB->fetchAssoc( $rset ) )
637  {
638  $result[] = $row;
639  }
640  return $result;
641  }
$result
getUnixTime()
get unix time
global $ilDB

◆ getPrivateSubRooms()

ilChatroom::getPrivateSubRooms (   $parent_room,
  $user_id 
)

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

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

1268  {
1269  global $ilDB;
1270 
1271  $query = "
1272  SELECT proom_id, parent_id
1273  FROM chatroom_prooms
1274  WHERE parent_id = %s
1275  AND owner = %s
1276  AND closed = 0
1277  ";
1278 
1279  $types = array( 'integer', 'integer' );
1280  $values = array( $parent_room, $user_id );
1281 
1282  $res = $ilDB->queryF( $query, $types, $values );
1283 
1284  $priv_rooms = array();
1285 
1286  while( $row = $ilDB->fetchAssoc( $res ) )
1287  {
1288  $proom_id = $row['proom_id'];
1289  $priv_rooms[$proom_id] = $row['parent_id'];
1290  }
1291 
1292  return $priv_rooms;
1293  }
global $ilDB

◆ getRefIdByRoomId()

ilChatroom::getRefIdByRoomId (   $room_id)

Returns ref_id of given room_id.

ilDBMySQL $ilDB

Parameters
integer$room_id
Returns
integer

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

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

1303  {
1304  global $ilDB;
1305 
1306  $query = "
1307  SELECT objr.ref_id
1308  FROM object_reference objr
1309 
1310  INNER JOIN chatroom_settings cs
1311  ON cs.object_id = objr.obj_id
1312 
1313  INNER JOIN object_data od
1314  ON od.obj_id = cs.object_id
1315 
1316  WHERE cs.room_id = %s
1317  ";
1318 
1319  $types = array( 'integer' );
1320  $values = array( $room_id );
1321 
1322  $res = $ilDB->queryF( $query, $types, $values );
1323 
1324  $row = $ilDB->fetchAssoc( $res );
1325 
1326  return $row['ref_id'];
1327  }
global $ilDB

◆ getRoomId()

ilChatroom::getRoomId ( )

Returns roomID from $this->roomId.

Returns
integer

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

References $roomId.

Referenced by ilChatroomViewTask\cancelJoin(), ilChatroomServerConnector\createPrivateRoom(), getBannedUsers(), getHistory(), getSessions(), isUserBanned(), and unbanUser().

495  {
496  return $this->roomId;
497  }
+ 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.

ilDBMySQL $ilDB

Parameters
ilChatroomUser$user
Returns
array

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

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

824  {
825  global $ilDB;
826 
827  $query = 'SELECT * FROM ' . self::$sessionTable
828  . ' WHERE room_id = '.
829  $ilDB->quote( $this->getRoomId(), 'integer' ) .
830  ' ORDER BY connected DESC';
831 
832  $rset = $ilDB->query( $query );
833 
834  $result = array();
835 
836  while( $row = $ilDB->fetchAssoc( $rset ) )
837  {
838  $result[] = $row;
839  }
840 
841  return $result;
842  }
getRoomId()
Returns roomID from $this->roomId.
$result
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 137 of file class.ilChatroom.php.

Referenced by ilChatroomViewTask\cancelJoin(), disconnectUsers(), getDescription(), and getTitle().

138  {
139  return $this->settings[$name];
140  }
+ Here is the caller graph for this function:

◆ getSettings()

ilChatroom::getSettings ( )

Returns $this->settings array.

Returns
array

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

References $settings.

411  {
412  return $this->settings;
413  }

◆ getTitle()

ilChatroom::getTitle ( )

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

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

Referenced by getChatURL().

51  {
52  if( !$this->object )
53  {
54  $this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
55  }
56 
57  return $this->object->getTitle();
58  }
getSetting($name)
Returns setting from $this->settings array by given name.
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 1153 of file class.ilChatroom.php.

References $ilDB, $query, and $row.

1153  {
1154  global $ilDB;
1155 
1156  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s and closed = 0';
1157  $rset = $ilDB->queryF($query, array('integer'), array($this->roomId));
1158 
1159  $titles = array();
1160 
1161  while($row = $ilDB->fetchAssoc($rset)) {
1162  $titles[] = $row['title'];
1163  }
1164 
1165  $suffix = '';
1166  $i = 0;
1167  do {
1168  if(!in_array($title . $suffix, $titles)) {
1169  $title .= $suffix;
1170  break;
1171  }
1172 
1173  ++$i;
1174 
1175  $suffix = ' (' . $i . ')';
1176  } while(true);
1177 
1178  return $title;
1179  }
global $ilDB

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

References setSetting().

476  {
477  $this->roomId = $rowdata['room_id'];
478 
479  foreach( $this->availableSettings as $setting => $type )
480  {
481  if( isset($rowdata[$setting]) )
482  {
483  settype($rowdata[$setting], $this->availableSettings[$setting]);
484  $this->setSetting( $setting, $rowdata[$setting] );
485  }
486  }
487  }
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 1020 of file class.ilChatroom.php.

References $ilDB, and ilObjUser\_lookupId().

1020  {
1021  global $ilDB;
1022  $user_id = ilObjUser::_lookupId($login);
1023  $this->inviteUserToPrivateRoom($user_id, $proom_id);
1024  }
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 524 of file class.ilChatroom.php.

References $ilDB, $query, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

524  {
525  //echo call_user_func_array('sprintf', array_merge(array($query), $values));
526  global $ilDB;
527 
528  $query = 'SELECT count(user_id) cnt FROM ' . self::$privateRoomsAccessTable .
529  ' WHERE proom_id = %s AND user_id = %s';
530 
531  $types = array('integer', 'integer');
532  $values = array($proom_id, $chat_userid);
533  $rset = $ilDB->queryF( $query, $types, $values );
534 
535  if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
536  return true;
537 
538  $query = 'SELECT count(*) cnt FROM ' . self::$privateRoomsTable .
539  ' WHERE proom_id = %s AND owner = %s';
540 
541  $types = array('integer', 'integer');
542  $values = array($proom_id, $chat_userid);
543  $rset = $ilDB->queryF( $query, $types, $values );
544 
545  if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
546  return true;
547 
548  return false;
549  }
global $ilDB
+ Here is the caller graph for this function:

◆ isOwnerOfPrivateRoom()

ilChatroom::isOwnerOfPrivateRoom (   $user_id,
  $proom_id 
)

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

References $ilDB, and $query.

876  {
877  global $ilDB;
878 
879  $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s AND owner = %s';
880  $types = array('integer', 'integer');
881  $values = array($proom_id, $user_id);
882 
883  $rset = $ilDB->queryF($query, $types, $values);
884 
885  if ($rset && $ilDB->fetchAssoc($rset)) {
886  return true;
887  }
888  return false;
889  }
global $ilDB

◆ isSubscribed()

ilChatroom::isSubscribed (   $chat_userid)

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

ilDBMySQL $ilDB

Parameters
integer$chat_userid
Returns
boolean

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

References $ilDB, $query, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

508  {
509  global $ilDB;
510 
511  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
512  ' WHERE room_id = %s AND user_id = %s';
513 
514  $types = array('integer', 'integer');
515  $values = array($this->roomId, $chat_userid);
516  $rset = $ilDB->queryF( $query, $types, $values );
517 
518  if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
519  return true;
520 
521  return false;
522  }
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.

ilDBMySQL $ilDB

Parameters
integer$user_id
Returns
boolean

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

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

Referenced by ilChatroomViewTask\cancelJoin().

725  {
726  global $ilDB;
727 
728  $query = 'SELECT count(user_id) cnt FROM ' . self::$banTable .
729  ' WHERE user_id = %s AND room_id = %s';
730 
731  $types = array('integer', 'integer');
732  $values = array($user_id, $this->getRoomId());
733 
734  $rset = $ilDB->queryF( $query, $types, $values );
735 
736  if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] )
737  return true;
738 
739  return false;
740  }
getRoomId()
Returns roomID from $this->roomId.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listUsersInPrivateRoom()

ilChatroom::listUsersInPrivateRoom (   $private_room_id)

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

References $ilDB, $query, and $row.

Referenced by getActivePrivateRooms().

1065  {
1066  global $ilDB;
1067 
1068  $query = '
1069  SELECT chatroom_users.user_id FROM ' . self::$privateSessionsTable . '
1070  INNER JOIN chatroom_users ON chatroom_users.user_id = ' . self::$privateSessionsTable . '.user_id WHERE proom_id = %s AND disconnected = 0
1071  ';
1072  $types = array('integer');
1073  $values = array($private_room_id);
1074  $rset = $ilDB->queryF( $query, $types, $values );
1075 
1076  $users = array();
1077 
1078  while ($row = $ilDB->fetchAssoc($rset)) {
1079  $users[$row['user_id']] = $row['user_id'];
1080  }
1081 
1082  return array_values($users);
1083  }
global $ilDB
+ Here is the caller graph for this function:

◆ lookupPrivateRoomTitle()

static ilChatroom::lookupPrivateRoomTitle (   $proom_id)
static

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

References $ilDB, $query, and $row.

Referenced by ilChatroomServerConnector\inviteToPrivateRoom(), and ilMailAddressbookGUI\search().

1026  {
1027  global $ilDB;
1028 
1029  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s';
1030  $types = array('integer');
1031  $values = array($proom_id);
1032 
1033  $rset = $ilDB->queryF($query, $types, $values);
1034 
1035  if ($row = $ilDB->fetchAssoc($rset)) {
1036  return $row['title'];
1037  }
1038 
1039  return 'unkown';
1040  }
global $ilDB
+ Here is the caller graph for this function:

◆ phpTypeToMDBType()

ilChatroom::phpTypeToMDBType (   $type)
private

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

Referenced by saveSettings().

349  {
350  switch($type) {
351  case 'string':
352  return 'text';
353  default:
354  return $type;
355  }
356 
357  }
+ Here is the caller graph for this function:

◆ save()

ilChatroom::save ( )

Saves settings using $this->settings.

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

References saveSettings().

157  {
158  $this->saveSettings( $this->settings );
159  }
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.

ilDBMySQL $ilDB

Parameters
integer$user_id
string$filename
string$type

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

References $filename, and $ilDB.

652  {
653  global $ilDB;
654 
655  $upload_id = $ilDB->nextId( self::$uploadTable );
656 
657  $ilDB->insert(
658  self::$uploadTable,
659  array(
660  'upload_id' => array('integer', $upload_id),
661  'room_id' => array('integer', $this->roomId),
662  'user_id' => array('integer', $user_id),
663  'filename' => array('text', $filename),
664  'filetype' => array('text', $type),
665  'timestamp' => array('integer', time())
666  )
667  );
668  }
$filename
Definition: buildRTE.php:89
global $ilDB

◆ saveSettings()

ilChatroom::saveSettings ( array  $settings)

Saves settings into settingsTable using given settings array.

ilDBMySQL $ilDB

Parameters
array$settings

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

References $ilDB, and phpTypeToMDBType().

Referenced by save().

366  {
367  global $ilDB;
368 
369  $localSettings = array();
370 
371  foreach( $this->availableSettings as $setting => $type )
372  {
373  if( isset( $settings[$setting] ) ) {
374  if ($type == 'boolean') {
375  $settings[$setting] = (boolean)$settings[$setting];
376  }
377  $localSettings[$setting] = array($this->phpTypeToMDBType($type), $settings[$setting]);
378  }
379  }
380 
381  if (!$localSettings['room_type'][1]) {
382  $localSettings['room_type'][1] = 'repository';
383  }
384 
385  if( $this->roomId )
386  {
387  $ilDB->update(
388  self::$settingsTable,
389  $localSettings,
390  array( 'room_id' => array('integer', $this->roomId) )
391  );
392  }
393  else
394  {
395  $this->roomId = $ilDB->nextId( self::$settingsTable );
396 
397  $localSettings['room_id'] = array(
398  $this->availableSettings['room_id'], $this->roomId
399  );
400 
401  $ilDB->insert( self::$settingsTable, $localSettings );
402  }
403  }
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 148 of file class.ilChatroom.php.

Referenced by initialize().

149  {
150  $this->settings[$name] = $value;
151  }
+ Here is the caller graph for this function:

◆ subscribeUserToPrivateRoom()

ilChatroom::subscribeUserToPrivateRoom (   $room_id,
  $user_id 
)

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

References $ilDB, and userIsInPrivateRoom().

Referenced by ilChatroomViewTask\cancelJoin(), and ilChatroomServerConnector\createPrivateRoom().

1099  {
1100  global $ilDB;
1101 
1102  if (!$this->userIsInPrivateRoom($room_id, $user_id)) {
1103  $ilDB->insert(
1104  self::$privateSessionsTable,
1105  array(
1106  'proom_id' => array('integer', $room_id),
1107  'user_id' => array('integer', $user_id),
1108  'connected' => array('integer', time()),
1109  'disconnected' => array('integer', 0),
1110  )
1111  );
1112  }
1113  }
userIsInPrivateRoom($room_id, $user_id)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unbanUser()

ilChatroom::unbanUser (   $user_id)

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

ilDBMySQL $ilDB

Parameters
mixed$user_id
Returns
boolean

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

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

701  {
702  global $ilDB;
703 
704  if( !is_array( $user_id ) )
705  $user_id = array($user_id);
706 
707  $query = 'DELETE FROM ' . self::$banTable . ' WHERE room_id = %s AND ' .
708  $ilDB->in( 'user_id', $user_id, false, 'integer' );
709 
710  $types = array('integer');
711  $values = array($this->getRoomId());
712 
713  return $ilDB->manipulateF( $query, $types, $values );
714  }
getRoomId()
Returns roomID from $this->roomId.
global $ilDB
+ Here is the call graph for this function:

◆ unsubscribeUserFromPrivateRoom()

ilChatroom::unsubscribeUserFromPrivateRoom (   $room_id,
  $user_id 
)

ilDB $ilDB

Parameters
integer$room_id
integer$user_id

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

References $ilDB.

1122  {
1123  global $ilDB;
1124 
1125  $ilDB->update(
1126  self::$privateSessionsTable,
1127  array(
1128  'disconnected' => array('integer', time())
1129  ),
1130  array(
1131  'proom_id' => array('integer', $room_id),
1132  'user_id' => array('integer', $user_id),
1133  )
1134  );
1135  }
global $ilDB

◆ userIsInPrivateRoom()

ilChatroom::userIsInPrivateRoom (   $room_id,
  $user_id 
)

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

References $ilDB, and $query.

Referenced by subscribeUserToPrivateRoom().

1086  {
1087  global $ilDB;
1088 
1089  $query = 'SELECT proom_id id FROM ' . self::$privateSessionsTable . ' WHERE user_id = %s AND proom_id = %s AND disconnected = 0 OR disconnected IS NULL';
1090  $types = array('integer', 'integer');
1091  $values = array($user_id, $room_id);
1092  $rset = $ilDB->queryF( $query, $types, $values );
1093  if ($ilDB->fetchAssoc($rset))
1094  return true;
1095  return false;
1096  }
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $availableSettings

ilChatroom::$availableSettings
private
Initial value:
= array(
'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 34 of file class.ilChatroom.php.

◆ $banTable

ilChatroom::$banTable = 'chatroom_bans'
staticprivate

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

◆ $historyTable

ilChatroom::$historyTable = 'chatroom_history'
staticprivate

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

◆ $object

ilChatroom::$object
private

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

◆ $privateRoomsAccessTable

ilChatroom::$privateRoomsAccessTable = 'chatroom_proomaccess'
staticprivate

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

◆ $privateRoomsTable

ilChatroom::$privateRoomsTable = 'chatroom_prooms'
staticprivate

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

◆ $privateSessionsTable

ilChatroom::$privateSessionsTable = 'chatroom_psessions'
staticprivate

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

◆ $roomId

ilChatroom::$roomId
private

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

Referenced by getRoomId().

◆ $sessionTable

ilChatroom::$sessionTable = 'chatroom_sessions'
staticprivate

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

◆ $settings

ilChatroom::$settings = array()
private

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

Referenced by addPrivateRoom(), and getSettings().

◆ $settingsTable

ilChatroom::$settingsTable = 'chatroom_settings'
staticprivate

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

◆ $uploadTable

ilChatroom::$uploadTable = 'chatroom_uploads'
staticprivate

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

◆ $userTable

ilChatroom::$userTable = 'chatroom_users'
staticprivate

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


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