ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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  {
178  $subRoom = (int)$message['sub'];
179  }
180  else if(is_object($message))
181  {
182  $subRoom = (int)$message->sub;
183  }
184 
185  $id = $ilDB->nextId(self::$historyTable);
186  $ilDB->insert(
187  self::$historyTable,
188  array(
189  'hist_id' => array('integer', $id),
190  'room_id' => array('integer', $this->roomId),
191  'sub_room' => array('integer', $subRoom),
192  'message' => array('text', json_encode($message)),
193  'timestamp' => array('integer', time()),
194  )
195  );
196  }
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 858 of file class.ilChatroom.php.

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

Referenced by ilChatroomServerConnector\createPrivateRoom().

859  {
860  global $ilDB;
861 
862  $nextId = $ilDB->nextId(self::$privateRoomsTable);
863  $ilDB->insert(
864  self::$privateRoomsTable,
865  array(
866  'proom_id' => array('integer', $nextId),
867  'parent_id' => array('integer', $this->roomId),
868  'title' => array('text', $title),
869  'owner' => array('integer', $owner->getUserId()),
870  'created' => array('integer', time()),
871  'is_public' => array('integer', $settings['public']),
872  )
873  );
874 
875  return $nextId;
876  }
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 687 of file class.ilChatroom.php.

References $comment, and $ilDB.

688  {
689  global $ilDB;
690 
691  $ilDB->replace(
692  self::$banTable,
693  array(
694  'room_id' => array('integer', $this->roomId),
695  'user_id' => array('integer', $user_id)
696  ),
697  array(
698  'timestamp' => array('integer', time()),
699  'remark' => array('text', $comment)
700  )
701  );
702  }
$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 428 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().

429  {
430  global $ilDB;
431  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE object_id = %s';
432  $types = array('integer');
433  $values = array($object_id);
434  $rset = $ilDB->queryF( $query, $types, $values );
435 
436  if( $row = $ilDB->fetchAssoc( $rset ) )
437  {
438  $room = new self();
439  $room->initialize( $row );
440  return $room;
441  }
442  }
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 451 of file class.ilChatroom.php.

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

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

452  {
453  global $ilDB;
454 
455  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE room_id = %s';
456 
457  $types = array('integer');
458  $values = array($room_id);
459 
460  $rset = $ilDB->queryF( $query, $types, $values );
461 
462  if( $row = $ilDB->fetchAssoc( $rset ) )
463  {
464  $room = new self();
465  $room->initialize( $row );
466 
467  if ($initObject) {
468  $room->object = ilObjectFactory::getInstanceByObjId($row['object_id']);
469  }
470 
471  return $room;
472  }
473  }
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 ilContactGUI\activateTab(), 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(), ilChatroomAdminViewTask\checkPrivHosts(), ilChatroomPrivateRoomTask\create(), ilChatroomPrivateRoomTask\enter(), ilChatroomClearTask\executeDefault(), ilChatroomPostMessageTask\executeDefault(), ilChatroomBanTask\show(), ilChatroomHistoryTask\showMessages(), ilChatroomUploadFileTask\uploadFile(), and ilChatroomAdminSmileyTask\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 1412 of file class.ilChatroom.php.

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

1413  {
1414  global $ilDB;
1415 
1416  $ilDB->queryF(
1417  'DELETE FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = %s',
1418  array('integer', 'integer'),
1419  array($this->roomId, (int)$sub_room)
1420  );
1421 
1422  if($sub_room)
1423  {
1424  $ilDB->queryF(
1425  'DELETE FROM ' . self::$privateSessionsTable . ' WHERE proom_id = %s AND disconnected < %s',
1426  array('integer', 'integer'),
1427  array($sub_room, time())
1428  );
1429  }
1430  else
1431  {
1432  $ilDB->queryF(
1433  'DELETE FROM ' . self::$sessionTable . ' WHERE room_id = %s AND disconnected < %s',
1434  array('integer', 'integer'),
1435  array($this->roomId, time())
1436  );
1437  }
1438  }
global $ilDB

◆ closePrivateRoom()

ilChatroom::closePrivateRoom (   $id)

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

References $ilDB.

879  {
880  global $ilDB;
881 
882  $ilDB->manipulateF(
883  'UPDATE ' . self::$privateRoomsTable . ' SET closed = %s WHERE proom_id = %s',
884  array('integer', 'integer'),
885  array(time(), $id)
886  );
887  }
global $ilDB

◆ countActiveUsers()

ilChatroom::countActiveUsers ( )

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

References $ilDB, $query, and $row.

1159  {
1160  global $ilDB;
1161 
1162  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
1163  ' WHERE room_id = %s';
1164 
1165  $types = array('integer');
1166  $values = array($this->roomId);
1167  $rset = $ilDB->queryF( $query, $types, $values );
1168 
1169  if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
1170  return $row['cnt'];
1171 
1172  return 0;
1173  }
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 562 of file class.ilChatroom.php.

References $ilDB.

Referenced by ilChatroomServerHandler\serverStarted().

563  {
564  global $ilDB;
565 
566  $ilDB->manipulate( 'DELETE FROM ' . self::$userTable );
567  $ilDB->manipulate( 'UPDATE ' . self::$privateRoomsTable . ' SET closed = ' . $ilDB->quote( time() ,'integer') . ' WHERE closed = 0 OR closed IS NULL');
568  $ilDB->manipulate( 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = ' . $ilDB->quote( time() ,'integer') . ' WHERE disconnected = 0');
572  }
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 281 of file class.ilChatroom.php.

References disconnectUsers().

282  {
283  $this->disconnectUsers( array($user_id) );
284  }
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 295 of file class.ilChatroom.php.

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

Referenced by disconnectUser().

296  {
297  global $ilDB;
298 
299  $query = 'SELECT * FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
300  $ilDB->in( 'user_id', $userIds, false, 'integer' );
301 
302  $types = array('integer');
303  $values = array($this->roomId);
304  $rset = $ilDB->queryF( $query, $types, $values );
305 
306  if( $row = $ilDB->fetchAssoc( $rset ) )
307  {
308  $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s';
309  $rset_prooms = $ilDB->queryF($query, array('integer'), array($this->roomId));
310 
311  $prooms = array();
312 
313  while($row_prooms = $ilDB->fetchAssoc($rset_prooms)) {
314  $prooms[] = $row_prooms['proom_id'];
315  }
316 
317  if (true || $this->getSetting( 'enable_history' )) {
318  $query = 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = %s WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
319  $ilDB->manipulateF($query, array('integer'), array(time()));
320  }
321  else {
322  $query = 'DELETE FROM ' . self::$privateSessionsTable . ' WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
323  $ilDB->manipulate($query);
324  }
325 
326  $query = 'DELETE FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
327  $ilDB->in( 'user_id', $userIds, false, 'integer' );
328 
329  $types = array('integer');
330  $values = array($this->roomId);
331  $ilDB->manipulateF( $query, $types, $values );
332 
333  do
334  {
335  if ($this->getSetting( 'enable_history' )) {
336  $id = $ilDB->nextId(self::$sessionTable);
337  $ilDB->insert(
338  self::$sessionTable,
339  array(
340  'sess_id' => array('integer', $id),
341  'room_id' => array('integer', $this->roomId),
342  'user_id' => array('integer', $row['user_id']),
343  'userdata' => array('text', $row['userdata']),
344  'connected' => array('integer', $row['connected']),
345  'disconnected' => array('integer', time())
346  )
347  );
348  }
349  }
350  while( $row = $ilDB->fetchAssoc( $rset ) );
351  }
352 
353  }
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 1203 of file class.ilChatroom.php.

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

Referenced by ilChatroomServerHandler\cleanupPrivateRooms().

1203  {
1204  global $ilDB;
1205 
1206  $query = '
1207  SELECT private_rooms.proom_id id, MIN(disconnected) min_disconnected, MAX(disconnected) max_disconnected
1208  FROM ' . self::$privateSessionsTable . ' private_sessions
1209  INNER JOIN '.self::$privateRoomsTable.' private_rooms
1210  ON private_sessions.proom_id = private_rooms.proom_id
1211  WHERE closed = 0
1212  GROUP BY private_rooms.proom_id
1213  HAVING MIN(disconnected) > 0 AND MAX(disconnected) < %s';
1214  $rset = $ilDB->queryF(
1215  $query,
1216  array('integer'),
1217  array(time() + 60 * 5)
1218  );
1219 
1220  $rooms = array();
1221 
1222  while ($row = $ilDB->fetchAssoc($rset)) {
1223  $rooms[$row['id']] = $row['id'];
1224  }
1225 
1226  $query = 'SELECT DISTINCT proom_id, room_id, object_id FROM ' . self::$privateRoomsTable
1227  . ' INNER JOIN ' . self::$settingsTable . ' ON parent_id = room_id '
1228  . ' WHERE ' . $ilDB->in('proom_id', $rooms, false, 'integer');
1229 
1230  $rset = $ilDB->query($query);
1231  $rooms = array();
1232  while($row = $ilDB->fetchAssoc($rset)) {
1233  $rooms[] = array(
1234  'proom_id' => $row['proom_id'],
1235  'room_id' => $row['room_id'],
1236  'object_id' => $row['object_id']
1237  );
1238  }
1239 
1240  return $rooms;
1241  }
global $ilDB
+ Here is the caller graph for this function:

◆ getActivePrivateRooms()

ilChatroom::getActivePrivateRooms (   $userid)

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

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

Referenced by ilChatroomViewTask\cancelJoin().

1057  {
1058  global $ilDB;
1059 
1060  $query = '
1061  SELECT roomtable.title, roomtable.proom_id, accesstable.user_id id, roomtable.owner rowner
1062  FROM ' . self::$privateRoomsTable . ' roomtable
1063  LEFT JOIN '.self::$privateRoomsAccessTable.' accesstable
1064  ON roomtable.proom_id = accesstable.proom_id
1065  AND accesstable.user_id = %s
1066  WHERE parent_id = %s
1067  AND (closed = 0 OR closed IS NULL)
1068  AND (accesstable.user_id IS NOT NULL OR roomtable.owner = %s)';
1069  $types = array('integer', 'integer', 'integer');
1070  $values = array($userid, $this->roomId, $userid);
1071  $rset = $ilDB->queryF( $query, $types, $values );
1072  $rooms = array();
1073 
1074  while( $row = $ilDB->fetchAssoc( $rset ) )
1075  {
1076  $row['active_users'] = $this->listUsersInPrivateRoom($row['id']);
1077  $row['owner'] = $row['rowner'];
1078  $rooms[$row['proom_id']] = $row;
1079  }
1080 
1081  return $rooms;
1082  }
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 763 of file class.ilChatroom.php.

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

764  {
765  global $ilDB;
766 
767  $query = 'SELECT chb.* FROM ' . self::$banTable . ' chb INNER JOIN usr_data ud ON chb.user_id = ud.usr_id WHERE chb.room_id = %s ';
768  $types = array('integer');
769  $values = array($this->getRoomId());
770  $rset = $ilDB->queryF( $query, $types, $values );
771  $result = array();
772 
773  if( $rset )
774  {
775  while( $row = $ilDB->fetchAssoc( $rset ) )
776  {
777  if( $row['user_id'] > 0 )
778  {
779  $user = new ilObjUser( $row['user_id'] );
780  $userdata = array(
781  'user_id' => $user->getId(),
782  'firstname' => $user->getFirstname(),
783  'lastname' => $user->getLastname(),
784  'login' => $user->getLogin(),
785  'remark' => $row['remark']
786  );
787 
788  $result[] = $userdata;
789  }
790  else
791  {
792  //@todo anonymous user
793  }
794  }
795  }
796 
797  return $result;
798  }
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 933 of file class.ilChatroom.php.

References $lng, $url, ilLink\_getStaticLink(), ilNotificationConfig\DEFAULT_TTS, ilObjectFactory\getInstanceByObjId(), getTitle(), and ilNotificationConfig\TTL_LONG.

934  {
935  include_once 'Services/Link/classes/class.ilLink.php';
936 
937  $url = '';
938 
939  if(is_object($gui))
940  {
941  if($scope_id)
942  {
943  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType(), true, '_'.$scope_id);
944  }
945  else
946  {
947  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType());
948  }
949  }
950 
951  return $url;
952  }
$url
Definition: shib_logout.php:72
+ 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 257 of file class.ilChatroom.php.

References $ilDB, $query, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

258  {
259  global $ilDB;
260 
261  $query = 'SELECT userdata FROM ' . self::$userTable . ' WHERE room_id = %s';
262  $types = array('integer');
263  $values = array($this->roomId);
264  $rset = $ilDB->queryF( $query, $types, $values );
265  $users = array();
266 
267  while( $row = $ilDB->fetchAssoc( $rset ) )
268  {
269  $users[] = json_decode( $row['userdata'] );
270  }
271 
272  return $users;
273  }
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 584 of file class.ilChatroom.php.

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

585  {
586  global $ilDB, $ilUser;
587 
588  $join = '';
589 
590  if ($proom_id) {
591  $join .=
592  'INNER JOIN ' . self::$privateSessionsTable . ' pSessionTable ' .
593  'ON pSessionTable.user_id = ' .$ilDB->quote( $restricted_session_userid, 'integer' ) . ' ' .
594  'AND pSessionTable.proom_id = historyTable.sub_room ' .
595  'AND timestamp >= pSessionTable.connected '.
596  'AND timestamp <= pSessionTable.disconnected ';
597  }
598 
599  $query =
600  'SELECT historyTable.* ' .
601  'FROM ' . self::$historyTable . ' historyTable ' . $join . ' ' .
602  'WHERE historyTable.room_id = ' . $this->getRoomId();
603 
604  $filter = array();
605 
606  if( $from != null )
607  {
608  $filter[] = 'timestamp >= ' . $ilDB->quote( $from->getUnixTime(), 'integer' );
609  }
610 
611  if( $to != null )
612  {
613  $filter[] = 'timestamp <= ' . $ilDB->quote( $to->getUnixTime(), 'integer' );
614  }
615 
616  if( $filter )
617  $query .= ' AND ' . join( ' AND ', $filter );
618  $query .= ' ORDER BY timestamp ASC';
619 
620  $rset = $ilDB->query( $query );
621  $result = array();
622 
623  while( $row = $ilDB->fetchAssoc( $rset ) )
624  {
625  $row['message'] = json_decode( $row['message'] );
626  $row['message']->timestamp = $row['timestamp'];
627  if ($row['message']->public !== null && !$row['message']->public && !in_array($ilUser->getId(), explode(',', $row['recipients']))) {
628  continue;
629  }
630 
631  $result[] = $row;
632  }
633  return $result;
634  }
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 1351 of file class.ilChatroom.php.

References $ilDB, $results, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

1351  {
1352  global $ilDB;
1353 
1354  // There is currently no way to check if a message is private or not
1355  // by sql. So we fetch twice as much as we need and hope that there
1356  // are not more than $number private messages.
1357  $ilDB->setLimit($number * 2);
1358  $rset = $ilDB->queryF('SELECT * FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = 0 ORDER BY timestamp DESC', array('integer'), array($this->roomId));
1359 
1360  $result_count = 0;
1361  $results = array();
1362  while(($row = $ilDB->fetchAssoc($rset)) && $result_count < $number) {
1363  $tmp = json_decode($row['message']);
1364  if ($chatuser !== null && $tmp->public == 0 && $tmp->recipients) {
1365  if (in_array($chatuser->getUserId(), explode(',',$tmp->recipients))) {
1366  $results[] = $tmp;
1367  ++$result_count;
1368  }
1369  }
1370  else if ($tmp->public == 1) {
1371  $results[] = $tmp;
1372  ++$result_count;
1373  }
1374 
1375  }
1376  return $results;
1377  }
$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 810 of file class.ilChatroom.php.

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

811  {
812  global $ilDB;
813 
814  $query = 'SELECT * FROM ' . self::$sessionTable . ' WHERE user_id = ' .
815  $ilDB->quote( $user->getUserId(), 'integer' ) .
816  ' ORDER BY connected DESC';
817 
818  $ilDB->setLimit( 1 );
819  $rset = $ilDB->query( $query );
820 
821  if( $row = $ilDB->fetchAssoc( $rset ) )
822  {
823  return $row;
824  }
825  }
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 636 of file class.ilChatroom.php.

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

636  {
637  global $ilDB;
638 
639  $query = 'SELECT proom_id, title FROM ' . self::$privateRoomsTable . ' WHERE proom_id IN (
640  SELECT proom_id FROM '.self::$privateSessionsTable.' WHERE connected >= %s AND disconnected <= %s AND user_id = %s
641 
642  ) AND parent_id = %s';
643 
644  $rset = $ilDB->queryF($query, array('integer','integer','integer','integer'), array($from->getUnixTime(), $to->getUnixTime(), $user_id, $room_id));
645  $result = array();
646  while( $row = $ilDB->fetchAssoc( $rset ) )
647  {
648  $result[] = $row;
649  }
650  return $result;
651  }
$result
getUnixTime()
get unix time
global $ilDB

◆ getPrivateSubRooms()

ilChatroom::getPrivateSubRooms (   $parent_room,
  $user_id 
)

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

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

1290  {
1291  global $ilDB;
1292 
1293  $query = "
1294  SELECT proom_id, parent_id
1295  FROM chatroom_prooms
1296  WHERE parent_id = %s
1297  AND owner = %s
1298  AND closed = 0
1299  ";
1300 
1301  $types = array( 'integer', 'integer' );
1302  $values = array( $parent_room, $user_id );
1303 
1304  $res = $ilDB->queryF( $query, $types, $values );
1305 
1306  $priv_rooms = array();
1307 
1308  while( $row = $ilDB->fetchAssoc( $res ) )
1309  {
1310  $proom_id = $row['proom_id'];
1311  $priv_rooms[$proom_id] = $row['parent_id'];
1312  }
1313 
1314  return $priv_rooms;
1315  }
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 1324 of file class.ilChatroom.php.

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

1325  {
1326  global $ilDB;
1327 
1328  $query = "
1329  SELECT objr.ref_id
1330  FROM object_reference objr
1331 
1332  INNER JOIN chatroom_settings cs
1333  ON cs.object_id = objr.obj_id
1334 
1335  INNER JOIN object_data od
1336  ON od.obj_id = cs.object_id
1337 
1338  WHERE cs.room_id = %s
1339  ";
1340 
1341  $types = array( 'integer' );
1342  $values = array( $room_id );
1343 
1344  $res = $ilDB->queryF( $query, $types, $values );
1345 
1346  $row = $ilDB->fetchAssoc( $res );
1347 
1348  return $row['ref_id'];
1349  }
global $ilDB

◆ getRoomId()

ilChatroom::getRoomId ( )

Returns roomID from $this->roomId.

Returns
integer

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

References $roomId.

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

501  {
502  return $this->roomId;
503  }
+ 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 837 of file class.ilChatroom.php.

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

838  {
839  global $ilDB;
840 
841  $query = 'SELECT * FROM ' . self::$sessionTable
842  . ' WHERE room_id = '.
843  $ilDB->quote( $this->getRoomId(), 'integer' ) .
844  ' ORDER BY connected DESC';
845 
846  $rset = $ilDB->query( $query );
847 
848  $result = array();
849 
850  while( $row = $ilDB->fetchAssoc( $rset ) )
851  {
852  $result[] = $row;
853  }
854 
855  return $result;
856  }
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 416 of file class.ilChatroom.php.

References $settings.

417  {
418  return $this->settings;
419  }

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

References $ilDB, $query, and $row.

1175  {
1176  global $ilDB;
1177 
1178  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s and closed = 0';
1179  $rset = $ilDB->queryF($query, array('integer'), array($this->roomId));
1180 
1181  $titles = array();
1182 
1183  while($row = $ilDB->fetchAssoc($rset)) {
1184  $titles[] = $row['title'];
1185  }
1186 
1187  $suffix = '';
1188  $i = 0;
1189  do {
1190  if(!in_array($title . $suffix, $titles)) {
1191  $title .= $suffix;
1192  break;
1193  }
1194 
1195  ++$i;
1196 
1197  $suffix = ' (' . $i . ')';
1198  } while(true);
1199 
1200  return $title;
1201  }
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 481 of file class.ilChatroom.php.

References setSetting().

482  {
483  $this->roomId = $rowdata['room_id'];
484 
485  foreach( $this->availableSettings as $setting => $type )
486  {
487  if( isset($rowdata[$setting]) )
488  {
489  settype($rowdata[$setting], $this->availableSettings[$setting]);
490  $this->setSetting( $setting, $rowdata[$setting] );
491  }
492  }
493  }
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 1034 of file class.ilChatroom.php.

References $ilDB, and ilObjUser\_lookupId().

1034  {
1035  global $ilDB;
1036  $user_id = ilObjUser::_lookupId($login);
1037  $this->inviteUserToPrivateRoom($user_id, $proom_id);
1038  }
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 530 of file class.ilChatroom.php.

References $ilDB, $query, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

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

◆ isOwnerOfPrivateRoom()

ilChatroom::isOwnerOfPrivateRoom (   $user_id,
  $proom_id 
)

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

References $ilDB, and $query.

889  {
890  global $ilDB;
891 
892  $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s AND owner = %s';
893  $types = array('integer', 'integer');
894  $values = array($proom_id, $user_id);
895 
896  $rset = $ilDB->queryF($query, $types, $values);
897 
898  if ($rset && $ilDB->fetchAssoc($rset)) {
899  return true;
900  }
901  return false;
902  }
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 513 of file class.ilChatroom.php.

References $ilDB, $query, and $row.

Referenced by ilChatroomViewTask\cancelJoin().

514  {
515  global $ilDB;
516 
517  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
518  ' WHERE room_id = %s AND user_id = %s';
519 
520  $types = array('integer', 'integer');
521  $values = array($this->roomId, $chat_userid);
522  $rset = $ilDB->queryF( $query, $types, $values );
523 
524  if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
525  return true;
526 
527  return false;
528  }
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 737 of file class.ilChatroom.php.

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

Referenced by ilChatroomViewTask\cancelJoin().

738  {
739  global $ilDB;
740 
741  $query = 'SELECT COUNT(user_id) cnt FROM ' . self::$banTable . ' WHERE user_id = %s AND room_id = %s';
742 
743  $types = array('integer', 'integer');
744  $values = array($user_id, $this->getRoomId());
745 
746  $rset = $ilDB->queryF($query, $types, $values);
747 
748  if($rset && ($row = $ilDB->fetchAssoc($rset)) && $row['cnt'])
749  {
750  return true;
751  }
752 
753  return false;
754  }
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 1084 of file class.ilChatroom.php.

References $ilDB, $query, and $row.

Referenced by getActivePrivateRooms().

1084  {
1085  global $ilDB;
1086 
1087  $query = '
1088  SELECT chatroom_users.user_id FROM ' . self::$privateSessionsTable . '
1089  INNER JOIN chatroom_users ON chatroom_users.user_id = ' . self::$privateSessionsTable . '.user_id WHERE proom_id = %s AND disconnected = 0
1090  ';
1091  $types = array('integer');
1092  $values = array($private_room_id);
1093  $rset = $ilDB->queryF( $query, $types, $values );
1094 
1095  $users = array();
1096 
1097  while ($row = $ilDB->fetchAssoc($rset)) {
1098  $users[$row['user_id']] = $row['user_id'];
1099  }
1100 
1101  return array_values($users);
1102  }
global $ilDB
+ Here is the caller graph for this function:

◆ lookupPrivateRoomTitle()

static ilChatroom::lookupPrivateRoomTitle (   $proom_id)
static

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

References $ilDB, $query, and $row.

Referenced by ilContactGUI\activateTab(), and ilChatroomServerConnector\inviteToPrivateRoom().

1040  {
1041  global $ilDB;
1042 
1043  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s';
1044  $types = array('integer');
1045  $values = array($proom_id);
1046 
1047  $rset = $ilDB->queryF($query, $types, $values);
1048 
1049  if ($row = $ilDB->fetchAssoc($rset)) {
1050  return $row['title'];
1051  }
1052 
1053  return 'unkown';
1054  }
global $ilDB
+ Here is the caller graph for this function:

◆ phpTypeToMDBType()

ilChatroom::phpTypeToMDBType (   $type)
private

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

Referenced by saveSettings().

355  {
356  switch($type) {
357  case 'string':
358  return 'text';
359  default:
360  return $type;
361  }
362 
363  }
+ 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 661 of file class.ilChatroom.php.

References $filename, and $ilDB.

662  {
663  global $ilDB;
664 
665  $upload_id = $ilDB->nextId( self::$uploadTable );
666 
667  $ilDB->insert(
668  self::$uploadTable,
669  array(
670  'upload_id' => array('integer', $upload_id),
671  'room_id' => array('integer', $this->roomId),
672  'user_id' => array('integer', $user_id),
673  'filename' => array('text', $filename),
674  'filetype' => array('text', $type),
675  'timestamp' => array('integer', time())
676  )
677  );
678  }
$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 371 of file class.ilChatroom.php.

References $ilDB, and phpTypeToMDBType().

Referenced by save().

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

References $ilDB, and userIsInPrivateRoom().

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

1118  {
1119  global $ilDB;
1120 
1121  if(!$this->userIsInPrivateRoom($room_id, $user_id))
1122  {
1123  $id = $ilDB->nextId(self::$privateSessionsTable);
1124  $ilDB->insert(
1125  self::$privateSessionsTable,
1126  array(
1127  'psess_id' => array('integer', $id),
1128  'proom_id' => array('integer', $room_id),
1129  'user_id' => array('integer', $user_id),
1130  'connected' => array('integer', time()),
1131  'disconnected' => array('integer', 0),
1132  )
1133  );
1134  }
1135  }
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 712 of file class.ilChatroom.php.

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

713  {
714  global $ilDB;
715 
716  if(!is_array($user_id))
717  {
718  $user_id = array($user_id);
719  }
720 
721  $query = 'DELETE FROM ' . self::$banTable . ' WHERE room_id = %s AND ' . $ilDB->in('user_id', $user_id, false, 'integer');
722 
723  $types = array('integer');
724  $values = array($this->getRoomId());
725 
726  return $ilDB->manipulateF($query, $types, $values);
727  }
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 1143 of file class.ilChatroom.php.

References $ilDB.

1144  {
1145  global $ilDB;
1146 
1147  $ilDB->update(
1148  self::$privateSessionsTable,
1149  array(
1150  'disconnected' => array('integer', time())
1151  ),
1152  array(
1153  'proom_id' => array('integer', $room_id),
1154  'user_id' => array('integer', $user_id)
1155  )
1156  );
1157  }
global $ilDB

◆ userIsInPrivateRoom()

ilChatroom::userIsInPrivateRoom (   $room_id,
  $user_id 
)

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

References $ilDB, and $query.

Referenced by subscribeUserToPrivateRoom().

1105  {
1106  global $ilDB;
1107 
1108  $query = 'SELECT proom_id id FROM ' . self::$privateSessionsTable . ' WHERE user_id = %s AND proom_id = %s AND disconnected = 0';
1109  $types = array('integer', 'integer');
1110  $values = array($user_id, $room_id);
1111  $rset = $ilDB->queryF( $query, $types, $values );
1112  if ($ilDB->fetchAssoc($rset))
1113  return true;
1114  return false;
1115  }
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: