ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilChatroom Class Reference

Class ilChatroom. More...

+ Collaboration diagram for ilChatroom:

Public Member Functions

 initialize (array $rowdata)
 Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $this->availableSettings. More...
 
 setSetting ($name, $value)
 Sets given name and value as setting into $this->settings array. More...
 
 getDescription ()
 
 getSetting ($name)
 Returns setting from $this->settings array by given name. More...
 
 save ()
 Saves settings using $this->settings. More...
 
 saveSettings (array $settings)
 Saves settings into settingsTable using given settings array. More...
 
 addHistoryEntry ($message, $recipient=null, $publicMessage=true)
 Inserts entry into historyTable. More...
 
 connectUser (ilChatroomUser $user)
 Connects user by inserting userdata into userTable. More...
 
 getConnectedUsers ($only_data=true)
 Returns an array of connected users. More...
 
 disconnectUser ($user_id)
 Creates userId array by given $user object and calls disconnectUsers method. More...
 
 disconnectUsers (array $userIds)
 Disconnects users by deleting userdata from userTable using given userId array. More...
 
 getSettings ()
 Returns $this->settings array. More...
 
 isSubscribed ($chat_userid)
 Returns true if entry exists in userTable matching given $chat_userid and $this->roomId. More...
 
 isAllowedToEnterPrivateRoom ($chat_userid, $proom_id)
 
 getHistory (ilDateTime $from=null, ilDateTime $to=null, $restricted_session_userid=null, $proom_id=0, $respect_target=true)
 Returns array containing history data selected from historyTable by given ilDateTime, $restricted_session_userid and matching roomId. More...
 
 getRoomId ()
 Returns roomID from $this->roomId. More...
 
 getPrivateRoomSessions (ilDateTime $from=null, ilDateTime $to=null, $user_id=0, $room_id=0)
 
 saveFileUploadToDb ($user_id, $filename, $type)
 Saves information about file uploads in DB. More...
 
 banUser ($user_id, $actor_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 Returns all from sessionTable where user_id matches userId from given $user object. More...
 
 addPrivateRoom ($title, ilChatroomUser $owner, $settings)
 
 closePrivateRoom ($id)
 
 isOwnerOfPrivateRoom ($user_id, $proom_id)
 
 getChatURL ($gui, $scope_id=0)
 
 getTitle ()
 
 inviteUserToPrivateRoomByLogin ($login, $proom_id)
 
 inviteUserToPrivateRoom ($user_id, $proom_id)
 
 getActivePrivateRooms ($userid)
 
 listUsersInPrivateRoom ($private_room_id)
 
 subscribeUserToPrivateRoom ($room_id, $user_id)
 
 userIsInPrivateRoom ($room_id, $user_id)
 
 unsubscribeUserFromPrivateRoom ($room_id, $user_id)
 
 countActiveUsers ()
 
 getPrivateRooms ()
 
 getPrivilegedUsersForPrivateRoom ($subRoomId)
 
 getUniquePrivateRoomTitle ($title)
 
 getAllRooms ($user_id)
 Fetches and returns the object ids of all rooms accessible by the user with $user_id. More...
 
 getPrivateSubRooms ($parent_room, $user_id)
 
 getRefIdByRoomId ($room_id)
 Returns ref_id of given room_id. More...
 
 getLastMessagesForChatViewer ($number, $chatuser=null)
 
 getLastMessages ($number, $chatuser=null)
 
 clearMessages ($sub_room)
 

Static Public Member Functions

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

Static Protected Member Functions

static checkPermissions ($usrId, $refId, array $permissions)
 

Private Member Functions

 phpTypeToMDBType ($type)
 

Private Attributes

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

Static Private Attributes

static $settingsTable = 'chatroom_settings'
 
static $historyTable = 'chatroom_history'
 
static $userTable = 'chatroom_users'
 
static $sessionTable = 'chatroom_sessions'
 
static $banTable = 'chatroom_bans'
 
static $privateRoomsTable = 'chatroom_prooms'
 
static $privateSessionsTable = 'chatroom_psessions'
 
static $uploadTable = 'chatroom_uploads'
 
static $privateRoomsAccessTable = 'chatroom_proomaccess'
 

Detailed Description

Class ilChatroom.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ addHistoryEntry()

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

Inserts entry into historyTable.

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

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

References $DIC, $id, $message, $timestamp, array, and time.

402  {
403  global $DIC;
404 
405  $subRoom = 0;
406  $timestamp = 0;
407  if (is_array($message)) {
408  $subRoom = (int) $message['sub'];
409  $timestamp = (int) $message['timestamp'];
410  } elseif (is_object($message)) {
411  $subRoom = (int) $message->sub;
412  $timestamp = (int) $message->timestamp;
413  }
414 
415  $id = $DIC->database()->nextId(self::$historyTable);
416  $DIC->database()->insert(
417  self::$historyTable,
418  array(
419  'hist_id' => array('integer', $id),
420  'room_id' => array('integer', $this->roomId),
421  'sub_room' => array('integer', $subRoom),
422  'message' => array('text', json_encode($message)),
423  'timestamp' => array('integer', ($timestamp > 0 ? $timestamp : time())),
424  )
425  );
426  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
catch(Exception $e) $message
Create styles array
The data for the language used.
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ addPrivateRoom()

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

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

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

Referenced by ilChatroomViewGUI\renderFileUploadForm().

910  {
911  global $DIC;
912 
913  $nextId = $DIC->database()->nextId(self::$privateRoomsTable);
914  $DIC->database()->insert(
915  self::$privateRoomsTable,
916  array(
917  'proom_id' => array('integer', $nextId),
918  'parent_id' => array('integer', $this->roomId),
919  'title' => array('text', $title),
920  'owner' => array('integer', $owner->getUserId()),
921  'closed' => array('integer', (isset($settings['closed']) ? $settings['closed'] : 0)),
922  'created' => array('integer', (isset($settings['created']) ? $settings['created'] : time())),
923  'is_public' => array('integer', $settings['public']),
924  )
925  );
926 
927  return $nextId;
928  }
getUserId()
Returns Ilias User ID.
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ banUser()

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

Inserts user into banTable, using given $user_id.

Parameters
integer$user_id
integer$actor_id
string$comment

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

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

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

◆ byObjectId()

static ilChatroom::byObjectId (   $object_id)
static

Returns ilChatroom object by given $object_id.

Parameters
integer$object_id
Returns
ilChatroom

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

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

Referenced by ilChatroomHistoryGUI\__construct(), ilChatroomXMLWriter\__construct(), ilChatroomXMLParser\__construct(), ilChatroomBanGUI\active(), ilChatroomServerHandler\cleanupPrivateRooms(), ilObjChatroom\cloneObject(), ilChatroomPrivateRoomGUI\create(), ilChatroomBanGUI\delete(), ilChatroomPrivateRoomGUI\delete(), ilChatroomPrivateRoomGUI\enter(), ilChatroomPostMessageGUI\executeDefault(), ilChatroomInitialGUI\executeDefault(), ilChatroomKickGUI\executeDefault(), ilChatroomBlockGUI\getChatroomSelectionList(), ilObjChatroomListGUI\getProperties(), ilChatroomBlock\getReadableAreas(), ilChatroomGUIHandler\getRoomByObjectId(), ilChatroomTabGUIFactory\getTabsForCommand(), ilChatroomInviteUsersToPrivateRoomGUI\inviteById(), ilChatroomPrivateRoomGUI\leave(), ilChatroomPrivateRoomGUI\listUsers(), ilChatroomKickGUI\main(), ilChatroomViewGUI\renderFileUploadForm(), ilChatroomCreateGUI\save(), ilChatroomBanGUI\show(), ilChatroomKickGUI\sub(), and ilChatroomUploadFileGUI\uploadFile().

150  {
151  global $DIC;
152 
153  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE object_id = %s';
154  $types = array('integer');
155  $values = array($object_id);
156  $rset = $DIC->database()->queryF($query, $types, $values);
157 
158  if ($row = $DIC->database()->fetchAssoc($rset)) {
159  $room = new self();
160  $room->initialize($row);
161  return $room;
162  }
163  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ byRoomId()

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

Returns ilChatroom by given $room_id.

Parameters
integer$room_id
Returns
ilChatroom

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

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

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

198  {
199  global $DIC;
200 
201  $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE room_id = %s';
202 
203  $types = array('integer');
204  $values = array($room_id);
205 
206  $rset = $DIC->database()->queryF($query, $types, $values);
207 
208  if ($row = $DIC->database()->fetchAssoc($rset)) {
209  $room = new self();
210  $room->initialize($row);
211 
212  if ($initObject) {
213  $room->object = ilObjectFactory::getInstanceByObjId($row['object_id']);
214  }
215 
216  return $room;
217  }
218  }
global $DIC
Definition: saml.php:7
$query
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkPermissions()

static ilChatroom::checkPermissions (   $usrId,
  $refId,
array  $permissions 
)
staticprotected
Parameters
int$usrId
int$refId
array$permissions
Returns
bool

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

References $DIC, $GLOBALS, ilObjChatroom\_getPublicRefId(), ilObject\_lookupObjId(), IL_NO_OBJECT_ACCESS, and ilObjChatroomAccess\isActivated().

94  {
95  global $DIC;
96 
97  require_once 'Modules/Chatroom/classes/class.ilObjChatroom.php';
98  $pub_ref_id = ilObjChatroom::_getPublicRefId();
99 
100  foreach ($permissions as $permission) {
101  if ($pub_ref_id == $refId) {
102  $hasAccess = $DIC->rbac()->system()->checkAccessOfUser($usrId, $permission, $refId);
103  if ($hasAccess) {
104  $hasWritePermission = $DIC->rbac()->system()->checkAccessOfUser($usrId, 'write', $refId);
105  if ($hasWritePermission) {
106  continue;
107  }
108 
109  $visible = null;
110  $a_obj_id = ilObject::_lookupObjId($refId);
111  $active = ilObjChatroomAccess::isActivated($refId, $a_obj_id, $visible);
112 
113  switch ($permission) {
114  case 'visible':
115  if (!$active) {
116  $GLOBALS['DIC']->access()->addInfoItem(IL_NO_OBJECT_ACCESS, $GLOBALS['DIC']->language()->txt('offline'));
117  }
118 
119  if (!$active && !$visible) {
120  return false;
121  }
122  break;
123 
124  case 'read':
125  if (!$active) {
126  $GLOBALS['DIC']->access()->addInfoItem(IL_NO_OBJECT_ACCESS, $GLOBALS['DIC']->language()->txt('offline'));
127  return false;
128  }
129  break;
130  }
131  }
132  } else {
133  $hasAccess = $DIC->access()->checkAccessOfUser($usrId, $permission, '', $refId);
134  }
135 
136  if (!$hasAccess) {
137  return false;
138  }
139  }
140 
141  return true;
142  }
global $DIC
Definition: saml.php:7
const IL_NO_OBJECT_ACCESS
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _lookupObjId($a_id)
static isActivated($refId, $objId, &$a_visible_flag=null)
+ Here is the call 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.

Parameters
integer$usr_id
array | string$permissions
integer$ref_id
Returns
bool

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

References array.

Referenced by ilContactGUI\submitInvitation().

79  {
80  if (!is_array($permissions)) {
81  $permissions = array($permissions);
82  }
83 
84  return self::checkPermissions($usr_id, $ref_id, $permissions);
85  }
Create styles array
The data for the language used.
+ 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.

Parameters
string | array$permissions
integer$ref_id
bool$send_info
Returns
bool

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

References $DIC, array, and ilUtil\sendFailure().

Referenced by ilChatroomInfoGUI\__construct(), ilChatroomSettingsGUI\__construct(), ilObjChatroomGUI\_goto(), ilChatroomTabGUIFactory\buildTabs(), ilChatroomAdminViewGUI\clientsettings(), ilChatroomInitialGUI\executeDefault(), ilChatroomBlockGUI\getChatroomSelectionList(), ilChatroomBlock\getReadableAreas(), ilChatroomGUIHandler\hasPermission(), ilChatroomGUIHandler\redirectIfNoPermission(), ilChatroomAdminViewGUI\serversettings(), ilChatroomKickGUI\sub(), and ilChatroomAdminSmileyGUI\view().

53  {
54  global $DIC;
55 
56  if (!is_array($permissions)) {
57  $permissions = array($permissions);
58  }
59 
60  $hasPermissions = self::checkPermissions($DIC->user()->getId(), $ref_id, $permissions);
61  if (!$hasPermissions && $send_info) {
62  ilUtil::sendFailure($DIC->language()->txt('permission_denied'), true);
63 
64  return false;
65  }
66 
67  return $hasPermissions;
68  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearMessages()

ilChatroom::clearMessages (   $sub_room)

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

References $DIC, array, and time.

1440  {
1441  global $DIC;
1442 
1443  $DIC->database()->queryF(
1444  'DELETE FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = %s',
1445  array('integer', 'integer'),
1446  array($this->roomId, (int) $sub_room)
1447  );
1448 
1449  if ($sub_room) {
1450  $DIC->database()->queryF(
1451  'DELETE FROM ' . self::$privateSessionsTable . ' WHERE proom_id = %s AND disconnected < %s',
1452  array('integer', 'integer'),
1453  array($sub_room, time())
1454  );
1455  } else {
1456  $DIC->database()->queryF(
1457  'DELETE FROM ' . self::$sessionTable . ' WHERE room_id = %s AND disconnected < %s',
1458  array('integer', 'integer'),
1459  array($this->roomId, time())
1460  );
1461  }
1462  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ closePrivateRoom()

ilChatroom::closePrivateRoom (   $id)

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

References $DIC, $id, array, and time.

931  {
932  global $DIC;
933 
934  $DIC->database()->manipulateF(
935  'UPDATE ' . self::$privateRoomsTable . ' SET closed = %s WHERE proom_id = %s',
936  array('integer', 'integer'),
937  array(time(), $id)
938  );
939  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ connectUser()

ilChatroom::connectUser ( ilChatroomUser  $user)

Connects user by inserting userdata into userTable.

Checks if user is already connected by using the given $user object for selecting the userId from userTable. If no entry is found, matching userId and roomId, the userdata is inserted into the userTable to connect the user.

Parameters
ilChatroomUser$user
Returns
boolean

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

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

438  {
439  global $DIC;
440 
441  $userdata = array(
442  'login' => $user->getUsername(),
443  'id' => $user->getUserId()
444  );
445 
446  $query = 'SELECT user_id FROM ' . self::$userTable . ' WHERE room_id = %s AND user_id = %s';
447  $types = array('integer', 'integer');
448  $values = array($this->roomId, $user->getUserId());
449 
450  if (!$DIC->database()->fetchAssoc($DIC->database()->queryF($query, $types, $values))) {
451  // Notice: Using replace instead of insert looks strange, because we actually know whether the selected data exists or not
452  // But we occasionally found some duplicate key errors although the data set should not exist when the following code is reached
453  $DIC->database()->replace(
454  self::$userTable,
455  array(
456  'room_id' => array('integer', $this->roomId),
457  'user_id' => array('integer', $user->getUserId())
458  ),
459  array(
460  'userdata' => array('text', json_encode($userdata)),
461  'connected' => array('integer', time()),
462  )
463  );
464 
465  return true;
466  }
467 
468  return false;
469  }
getUserId()
Returns Ilias User ID.
global $DIC
Definition: saml.php:7
$userdata
Definition: demo.php:48
$query
Create styles array
The data for the language used.
getUsername()
Returns username from Object or SESSION.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ countActiveUsers()

ilChatroom::countActiveUsers ( )

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

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

1193  {
1194  global $DIC;
1195 
1196  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
1197  ' WHERE room_id = %s';
1198 
1199  $types = array('integer');
1200  $values = array($this->roomId);
1201  $rset = $DIC->database()->queryF($query, $types, $values);
1202 
1203  if ($rset && ($row = $DIC->database()->fetchAssoc($rset)) && $row['cnt'] == 1) {
1204  return $row['cnt'];
1205  }
1206 
1207  return 0;
1208  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.

◆ disconnectAllUsersFromAllRooms()

static ilChatroom::disconnectAllUsersFromAllRooms ( )
static

Deletes all entrys from userTable.

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

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

References $DIC, and time.

Referenced by ilChatroomServerHandler\serverStarted().

224  {
225  global $DIC;
226 
227  $DIC->database()->manipulate('DELETE FROM ' . self::$userTable);
228  $DIC->database()->manipulate('UPDATE ' . self::$privateRoomsTable . ' SET closed = ' . $DIC->database()->quote(time(), 'integer') . ' WHERE closed = 0 OR closed IS NULL');
229  $DIC->database()->manipulate('UPDATE ' . self::$privateSessionsTable . ' SET disconnected = ' . $DIC->database()->quote(time(), 'integer') . ' WHERE disconnected = 0');
233  }
global $DIC
Definition: saml.php:7
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ disconnectUser()

ilChatroom::disconnectUser (   $user_id)

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

Parameters
int$user_id

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

References array, and disconnectUsers().

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

◆ disconnectUsers()

ilChatroom::disconnectUsers ( array  $userIds)

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

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

Parameters
array$userIds

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

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

Referenced by disconnectUser().

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

◆ findDeletablePrivateRooms()

static ilChatroom::findDeletablePrivateRooms ( )
static

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

References $DIC, $query, $row, array, and time.

Referenced by ilChatroomServerHandler\cleanupPrivateRooms().

236  {
237  global $DIC;
238 
239  $query = '
240  SELECT private_rooms.proom_id id, MIN(disconnected) min_disconnected, MAX(disconnected) max_disconnected
241  FROM ' . self::$privateSessionsTable . ' private_sessions
242  INNER JOIN ' . self::$privateRoomsTable . ' private_rooms
243  ON private_sessions.proom_id = private_rooms.proom_id
244  WHERE closed = 0
245  GROUP BY private_rooms.proom_id
246  HAVING MIN(disconnected) > 0 AND MAX(disconnected) < %s';
247  $rset = $DIC->database()->queryF(
248  $query,
249  array('integer'),
250  array(time() + 60 * 5)
251  );
252 
253  $rooms = array();
254 
255  while ($row = $DIC->database()->fetchAssoc($rset)) {
256  $rooms[$row['id']] = $row['id'];
257  }
258 
259  $query = 'SELECT DISTINCT proom_id, room_id, object_id FROM ' . self::$privateRoomsTable
260  . ' INNER JOIN ' . self::$settingsTable . ' ON parent_id = room_id '
261  . ' WHERE ' . $DIC->database()->in('proom_id', $rooms, false, 'integer');
262 
263  $rset = $DIC->database()->query($query);
264  $rooms = array();
265  while ($row = $DIC->database()->fetchAssoc($rset)) {
266  $rooms[] = array(
267  'proom_id' => $row['proom_id'],
268  'room_id' => $row['room_id'],
269  'object_id' => $row['object_id']
270  );
271  }
272 
273  return $rooms;
274  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ getActivePrivateRooms()

ilChatroom::getActivePrivateRooms (   $userid)

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

References $DIC, $query, $row, $userid, array, and listUsersInPrivateRoom().

1092  {
1093  global $DIC;
1094 
1095  $query = '
1096  SELECT roomtable.title, roomtable.proom_id, accesstable.user_id id, roomtable.owner rowner
1097  FROM ' . self::$privateRoomsTable . ' roomtable
1098  LEFT JOIN ' . self::$privateRoomsAccessTable . ' accesstable
1099  ON roomtable.proom_id = accesstable.proom_id
1100  AND accesstable.user_id = %s
1101  WHERE parent_id = %s
1102  AND (closed = 0 OR closed IS NULL)
1103  AND (accesstable.user_id IS NOT NULL OR roomtable.owner = %s)';
1104  $types = array('integer', 'integer', 'integer');
1105  $values = array($userid, $this->roomId, $userid);
1106  $rset = $DIC->database()->queryF($query, $types, $values);
1107  $rooms = array();
1108 
1109  while ($row = $DIC->database()->fetchAssoc($rset)) {
1110  $row['active_users'] = $this->listUsersInPrivateRoom($row['id']);
1111  $row['owner'] = $row['rowner'];
1112  $rooms[$row['proom_id']] = $row;
1113  }
1114 
1115  return $rooms;
1116  }
global $DIC
Definition: saml.php:7
if(empty($userids)) $userid
listUsersInPrivateRoom($private_room_id)
$query
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getAllRooms()

ilChatroom::getAllRooms (   $user_id)

Fetches and returns the object ids of all rooms accessible by the user with $user_id.

Parameters
integer$user_id
Returns
array

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

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

1282  {
1283  global $DIC;
1284 
1285  $query = "
1286  SELECT room_id, od.title
1287  FROM object_data od
1288 
1289  INNER JOIN " . self::$settingsTable . "
1290  ON object_id = od.obj_id
1291 
1292  INNER JOIN " . self::$privateRoomsTable . " prt
1293  ON prt.owner = %s
1294 
1295  WHERE od.type = 'chtr'
1296  ";
1297 
1298  $types = array('integer');
1299  $values = array($user_id);
1300 
1301  $res = $DIC->database()->queryF($query, $types, $values);
1302 
1303  $rooms = array();
1304 
1305  while ($row = $DIC->database()->fetchAssoc($res)) {
1306  $room_id = $row['room_id'];
1307  $rooms[$room_id] = $row['title'];
1308  }
1309 
1310  return $rooms;
1311  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.

◆ getBannedUsers()

ilChatroom::getBannedUsers ( )

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

Returns
array

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

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

828  {
829  global $DIC;
830 
831  $query = 'SELECT chb.* FROM ' . self::$banTable . ' chb INNER JOIN usr_data ud ON chb.user_id = ud.usr_id WHERE chb.room_id = %s ';
832  $types = array('integer');
833  $values = array($this->getRoomId());
834  $rset = $DIC->database()->queryF($query, $types, $values);
835  $result = array();
836 
837  if ($rset) {
838  while ($row = $DIC->database()->fetchAssoc($rset)) {
839  if ($row['user_id'] > 0) {
840  $user = new ilObjUser($row['user_id']);
841  $userdata = array(
842  'user_id' => $user->getId(),
843  'firstname' => $user->getFirstname(),
844  'lastname' => $user->getLastname(),
845  'login' => $user->getLogin(),
846  'timestamp' => $row['timestamp'],
847  'actor_id' => $row['actor_id'],
848  'remark' => $row['remark']
849  );
850 
851  $result[] = $userdata;
852  }
853  }
854  }
855 
856  return $result;
857  }
getRoomId()
Returns roomID from $this->roomId.
$result
global $DIC
Definition: saml.php:7
$userdata
Definition: demo.php:48
$query
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getChatURL()

ilChatroom::getChatURL (   $gui,
  $scope_id = 0 
)
Parameters
$gui
integer$scope_id
Returns
string

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

References $url, and ilLink\_getStaticLink().

Referenced by isOwnerOfPrivateRoom().

1029  {
1030  include_once 'Services/Link/classes/class.ilLink.php';
1031 
1032  $url = '';
1033 
1034  if (is_object($gui)) {
1035  if ($scope_id) {
1036  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType(), true, '_' . $scope_id);
1037  } else {
1038  $url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType());
1039  }
1040  }
1041 
1042  return $url;
1043  }
$url
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConnectedUsers()

ilChatroom::getConnectedUsers (   $only_data = true)

Returns an array of connected users.

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

Parameters
bool$only_data
Returns
array

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

References $DIC, $query, $row, $users, and array.

479  {
480  global $DIC;
481 
482  $query = 'SELECT ' . ($only_data ? 'userdata' : '*') . ' FROM ' . self::$userTable . ' WHERE room_id = %s';
483  $types = array('integer');
484  $values = array($this->roomId);
485  $rset = $DIC->database()->queryF($query, $types, $values);
486  $users = array();
487 
488  while ($row = $DIC->database()->fetchAssoc($rset)) {
489  $users[] = $only_data ? json_decode($row['userdata']) : $row;
490  }
491 
492  return $users;
493  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
$users
Definition: authpage.php:44

◆ getDescription()

ilChatroom::getDescription ( )

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

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

318  {
319  if (!$this->object) {
320  $this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
321  }
322 
323  return $this->object->getDescription();
324  }
getSetting($name)
Returns setting from $this->settings array by given name.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ getHistory()

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

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

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

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

References $DIC, $from, $message, $query, $result, $row, array, and getRoomId().

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

◆ getLastMessages()

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

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

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

Referenced by getLastMessagesForChatViewer().

1378  {
1379  global $DIC;
1380 
1381  // There is currently no way to check if a message is private or not
1382  // by sql. So we fetch twice as much as we need and hope that there
1383  // are not more than $number private messages.
1384  $DIC->database()->setLimit($number);
1385  $rset = $DIC->database()->query(
1386  'SELECT *
1387  FROM ' . self::$historyTable . '
1388  WHERE room_id = ' . $DIC->database()->quote($this->roomId, 'integer') . '
1389  AND sub_room = 0
1390  AND (
1391  (' . $DIC->database()->like('message', 'text', '%"type":"message"%') . ' AND NOT ' . $DIC->database()->like('message', 'text', '%"public":0%') . ')
1392  OR ' . $DIC->database()->like('message', 'text', '%"target":{%"id":"' . $chatuser->getUserId() . '"%') . '
1393  OR ' . $DIC->database()->like('message', 'text', '%"from":{"id":' . $chatuser->getUserId() . '%') . '
1394  )
1395  ORDER BY timestamp DESC'
1396  );
1397 
1398  $result_count = 0;
1399  $results = array();
1400  while (($row = $DIC->database()->fetchAssoc($rset)) && $result_count < $number) {
1401  $tmp = json_decode($row['message']);
1402  if ($chatuser !== null && $tmp->target != null && $tmp->target->public == 0) {
1403  if ($chatuser->getUserId() == $tmp->target->id || $chatuser->getUserId() == $tmp->from->id) {
1404  $results[] = $tmp;
1405  ++$result_count;
1406  }
1407  } else {
1408  $results[] = $tmp;
1409  ++$result_count;
1410  }
1411  }
1412 
1413  $rset = $DIC->database()->query(
1414  'SELECT *
1415  FROM ' . self::$historyTable . '
1416  WHERE room_id = ' . $DIC->database()->quote($this->roomId, 'integer') . '
1417  AND sub_room = 0
1418  AND ' . $DIC->database()->like('message', 'text', '%"type":"notice"%') . '
1419  AND timestamp <= ' . $DIC->database()->quote($results[0]->timestamp, 'integer') . ' AND timestamp >= ' . $DIC->database()->quote($results[$result_count - 1]->timestamp, 'integer') . '
1420 
1421  ORDER BY timestamp DESC'
1422  );
1423 
1424  while (($row = $DIC->database()->fetchAssoc($rset))) {
1425  $tmp = json_decode($row['message']);
1426  $results[] = $tmp;
1427  }
1428 
1429  \usort($results, function ($a, $b) {
1430  $a_timestamp = strlen($a->timestamp) == 13 ? substr($a->timestamp, 0, -3) : $a->timestamp;
1431  $b_timestamp = strlen($b->timestamp) == 13 ? substr($b->timestamp, 0, -3) : $b->timestamp;
1432 
1433  return $b_timestamp - $a_timestamp;
1434  });
1435 
1436  return $results;
1437  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
$results
Definition: svg-scanner.php:47
+ Here is the caller graph for this function:

◆ getLastMessagesForChatViewer()

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

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

References getLastMessages().

Referenced by ilChatroomBlock\getMessages().

1373  {
1374  return $this->getLastMessages($number, $chatuser);
1375  }
getLastMessages($number, $chatuser=null)
+ Here is the call graph for this function:
+ 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.

Parameters
ilChatroomUser$user
Returns
array

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

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

867  {
868  global $DIC;
869 
870  $query = 'SELECT * FROM ' . self::$sessionTable . ' WHERE user_id = ' .
871  $DIC->database()->quote($user->getUserId(), 'integer') .
872  ' ORDER BY connected DESC';
873 
874  $DIC->database()->setLimit(1);
875  $rset = $DIC->database()->query($query);
876 
877  if ($row = $DIC->database()->fetchAssoc($rset)) {
878  return $row;
879  }
880  }
getUserId()
Returns Ilias User ID.
global $DIC
Definition: saml.php:7
$query
+ Here is the call graph for this function:

◆ getPrivateRooms()

ilChatroom::getPrivateRooms ( )

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

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

1211  {
1212  global $DIC;
1213 
1214  $query = 'SELECT * FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s';
1215  $rset = $DIC->database()->queryF($query, array('integer'), array($this->roomId));
1216 
1217  $rooms = array();
1218 
1219  while ($row = $DIC->database()->fetchAssoc($rset)) {
1220  $rooms[] = $row;
1221  }
1222 
1223  return $rooms;
1224  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.

◆ getPrivateRoomSessions()

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

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

References $DIC, $from, $query, $result, $row, and array.

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

◆ getPrivateSubRooms()

ilChatroom::getPrivateSubRooms (   $parent_room,
  $user_id 
)

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

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

1314  {
1315  global $DIC;
1316 
1317  $query = "
1318  SELECT proom_id, parent_id
1319  FROM chatroom_prooms
1320  WHERE parent_id = %s
1321  AND owner = %s
1322  AND closed = 0
1323  ";
1324 
1325  $types = array('integer', 'integer');
1326  $values = array($parent_room, $user_id);
1327 
1328  $res = $DIC->database()->queryF($query, $types, $values);
1329 
1330  $priv_rooms = array();
1331 
1332  while ($row = $DIC->database()->fetchAssoc($res)) {
1333  $proom_id = $row['proom_id'];
1334  $priv_rooms[$proom_id] = $row['parent_id'];
1335  }
1336 
1337  return $priv_rooms;
1338  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.

◆ getPrivilegedUsersForPrivateRoom()

ilChatroom::getPrivilegedUsersForPrivateRoom (   $subRoomId)
Parameters
int$subRoomId
Returns
int[]

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

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

1231  {
1232  global $DIC;
1233 
1234  $query = 'SELECT user_id FROM ' . self::$privateRoomsAccessTable . ' WHERE proom_id = %s';
1235  $rset = $DIC->database()->queryF($query, array('integer'), array($subRoomId));
1236 
1237  $userIds = array();
1238 
1239  while ($row = $DIC->database()->fetchAssoc($rset)) {
1240  $userIds[] = $row['user_id'];
1241  }
1242 
1243  return $userIds;
1244  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.

◆ getRefIdByRoomId()

ilChatroom::getRefIdByRoomId (   $room_id)

Returns ref_id of given room_id.

Parameters
integer$room_id
Returns
integer

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

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

1346  {
1347  global $DIC;
1348 
1349  $query = "
1350  SELECT objr.ref_id
1351  FROM object_reference objr
1352 
1353  INNER JOIN chatroom_settings cs
1354  ON cs.object_id = objr.obj_id
1355 
1356  INNER JOIN object_data od
1357  ON od.obj_id = cs.object_id
1358 
1359  WHERE cs.room_id = %s
1360  ";
1361 
1362  $types = array('integer');
1363  $values = array($room_id);
1364 
1365  $res = $DIC->database()->queryF($query, $types, $values);
1366 
1367  $row = $DIC->database()->fetchAssoc($res);
1368 
1369  return $row['ref_id'];
1370  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.

◆ getRoomId()

ilChatroom::getRoomId ( )

Returns roomID from $this->roomId.

Returns
integer

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

References $roomId.

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

706  {
707  return $this->roomId;
708  }
+ 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.

Parameters
ilChatroomUser$user
Returns
array

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

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

890  {
891  global $DIC;
892 
893  $query = 'SELECT * FROM ' . self::$sessionTable
894  . ' WHERE room_id = ' .
895  $DIC->database()->quote($this->getRoomId(), 'integer') .
896  ' ORDER BY connected DESC';
897 
898  $rset = $DIC->database()->query($query);
899 
900  $result = array();
901 
902  while ($row = $DIC->database()->fetchAssoc($rset)) {
903  $result[] = $row;
904  }
905 
906  return $result;
907  }
getRoomId()
Returns roomID from $this->roomId.
$result
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
+ 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 331 of file class.ilChatroom.php.

References $name, and settings().

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

332  {
333  return $this->settings[$name];
334  }
if($format !==null) $name
Definition: metadata.php:146
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

ilChatroom::getSettings ( )

Returns $this->settings array.

Returns
array

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

References $settings.

571  {
572  return $this->settings;
573  }

◆ getTitle()

ilChatroom::getTitle ( )

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

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

Referenced by isOwnerOfPrivateRoom().

1046  {
1047  if (!$this->object) {
1048  $this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
1049  }
1050 
1051  return $this->object->getTitle();
1052  }
getSetting($name)
Returns setting from $this->settings array by given name.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUniquePrivateRoomTitle()

ilChatroom::getUniquePrivateRoomTitle (   $title)

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

References $DIC, $i, $query, $row, $title, and array.

Referenced by ilChatroomViewGUI\renderFileUploadForm().

1247  {
1248  global $DIC;
1249 
1250  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s and closed = 0';
1251  $rset = $DIC->database()->queryF($query, array('integer'), array($this->roomId));
1252 
1253  $titles = array();
1254 
1255  while ($row = $DIC->database()->fetchAssoc($rset)) {
1256  $titles[] = $row['title'];
1257  }
1258 
1259  $suffix = '';
1260  $i = 0;
1261  do {
1262  if (!in_array($title . $suffix, $titles)) {
1263  $title .= $suffix;
1264  break;
1265  }
1266 
1267  ++$i;
1268 
1269  $suffix = ' (' . $i . ')';
1270  } while (true);
1271 
1272  return $title;
1273  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ getUntrashedChatReferences()

static ilChatroom::getUntrashedChatReferences (   $filter = array())
static

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

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

Referenced by ilChatroomBlock\getReadableAreas().

277  {
278  global $DIC;
279 
280  // Check for parent because of an invalid parent node for the old public chat (thx @ jposselt ;-)).
281  // We cannot find this old public chat and clean this automatically
282  $query = '
283  SELECT od.obj_id, od.title, ore.ref_id, od.type, odp.title parent_title
284  FROM object_data od
285  INNER JOIN object_reference ore ON ore.obj_id = od.obj_id
286  INNER JOIN tree t ON t.child = ore.ref_id
287  INNER JOIN tree p ON p.child = t.parent
288  INNER JOIN object_reference orep ON orep.ref_id = p.child
289  INNER JOIN object_data odp ON odp.obj_id = orep.obj_id
290  INNER JOIN object_reference pre ON pre.ref_id = t.parent
291  INNER JOIN object_data pod ON pod.obj_id = pre.obj_id
292  ';
293 
294  if (isset($filter['last_activity'])) {
295  $threshold = $DIC->database()->quote($filter['last_activity'], 'integer');
296  $query .= "
297  INNER JOIN chatroom_settings ON chatroom_settings.object_id = od.obj_id
298  INNER JOIN chatroom_history ON chatroom_history.room_id = chatroom_settings.room_id AND chatroom_history.timestamp > $threshold
299  ";
300  }
301 
302  $query .= '
303  WHERE od.type = %s AND t.tree > 0 AND ore.deleted IS NULL
304  GROUP BY od.obj_id, od.title, ore.ref_id, od.type, odp.title
305  ORDER BY od.title
306  ';
307  $res = $DIC->database()->queryF($query, array('text'), array('chtr'));
308 
309  $chats = array();
310  while ($row = $DIC->database()->fetchAssoc($res)) {
311  $chats[] = $row;
312  }
313 
314  return $chats;
315  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ initialize()

ilChatroom::initialize ( array  $rowdata)

Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $this->availableSettings.

Parameters
array$rowdata

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

References $type, and setSetting().

171  {
172  $this->roomId = $rowdata['room_id'];
173 
174  foreach ($this->availableSettings as $setting => $type) {
175  if (isset($rowdata[$setting])) {
176  settype($rowdata[$setting], $this->availableSettings[$setting]);
177  $this->setSetting($setting, $rowdata[$setting]);
178  }
179  }
180  }
setSetting($name, $value)
Sets given name and value as setting into $this->settings array.
$type
+ Here is the call graph for this function:

◆ inviteUserToPrivateRoom()

ilChatroom::inviteUserToPrivateRoom (   $user_id,
  $proom_id 
)
Parameters
int$user_id
int$proom_id

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

References $DIC, and array.

Referenced by inviteUserToPrivateRoomByLogin(), and ilChatroomViewGUI\renderFileUploadForm().

1082  {
1083  global $DIC;
1084 
1085  $DIC->database()->replace(self::$privateRoomsAccessTable, array(
1086  'user_id' => array('integer', $user_id),
1087  'proom_id' => array('integer', $proom_id)
1088  ), array());
1089  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ inviteUserToPrivateRoomByLogin()

ilChatroom::inviteUserToPrivateRoomByLogin (   $login,
  $proom_id 
)

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

References ilObjUser\_lookupId(), and inviteUserToPrivateRoom().

1072  {
1073  $user_id = ilObjUser::_lookupId($login);
1074  $this->inviteUserToPrivateRoom($user_id, $proom_id);
1075  }
inviteUserToPrivateRoom($user_id, $proom_id)
static _lookupId($a_user_str)
Lookup id by login.
+ Here is the call graph for this function:

◆ isAllowedToEnterPrivateRoom()

ilChatroom::isAllowedToEnterPrivateRoom (   $chat_userid,
  $proom_id 
)

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

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

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

◆ isOwnerOfPrivateRoom()

ilChatroom::isOwnerOfPrivateRoom (   $user_id,
  $proom_id 
)

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

References $DIC, $query, ilLanguageFactory\_getLanguageOfUser(), array, ilNotificationConfig\DEFAULT_TTS, getChatURL(), ilObjectFactory\getInstanceByObjId(), ilMail\getSalutation(), getTitle(), and ilNotificationConfig\TTL_LONG.

942  {
943  global $DIC;
944 
945  $query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s AND owner = %s';
946  $types = array('integer', 'integer');
947  $values = array($proom_id, $user_id);
948 
949  $rset = $DIC->database()->queryF($query, $types, $values);
950 
951  if ($rset && $DIC->database()->fetchAssoc($rset)) {
952  return true;
953  }
954  return false;
955  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ isSubscribed()

ilChatroom::isSubscribed (   $chat_userid)

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

Parameters
integer$chat_userid
Returns
boolean

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

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

Referenced by ilChatroomViewGUI\renderFileUploadForm().

582  {
583  global $DIC;
584 
585  $query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
586  ' WHERE room_id = %s AND user_id = %s';
587 
588  $types = array('integer', 'integer');
589  $values = array($this->roomId, $chat_userid);
590  $rset = $DIC->database()->queryF($query, $types, $values);
591 
592  if ($rset && ($row = $DIC->database()->fetchAssoc($rset)) && $row['cnt'] == 1) {
593  return true;
594  }
595 
596  return false;
597  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
+ 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.

Parameters
integer$user_id
Returns
boolean

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

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

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

◆ listUsersInPrivateRoom()

ilChatroom::listUsersInPrivateRoom (   $private_room_id)

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

References $DIC, $query, $row, $users, and array.

Referenced by getActivePrivateRooms().

1119  {
1120  global $DIC;
1121 
1122  $query = '
1123  SELECT chatroom_users.user_id FROM ' . self::$privateSessionsTable . '
1124  INNER JOIN chatroom_users ON chatroom_users.user_id = ' . self::$privateSessionsTable . '.user_id WHERE proom_id = %s AND disconnected = 0
1125  ';
1126  $types = array('integer');
1127  $values = array($private_room_id);
1128  $rset = $DIC->database()->queryF($query, $types, $values);
1129 
1130  $users = array();
1131 
1132  while ($row = $DIC->database()->fetchAssoc($rset)) {
1133  $users[$row['user_id']] = $row['user_id'];
1134  }
1135 
1136  return array_values($users);
1137  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
+ Here is the caller graph for this function:

◆ lookupPrivateRoomTitle()

static ilChatroom::lookupPrivateRoomTitle (   $proom_id)
static

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

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

Referenced by ilContactGUI\inviteToChat().

1055  {
1056  global $DIC;
1057 
1058  $query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s';
1059  $types = array('integer');
1060  $values = array($proom_id);
1061 
1062  $rset = $DIC->database()->queryF($query, $types, $values);
1063 
1064  if ($row = $DIC->database()->fetchAssoc($rset)) {
1065  return $row['title'];
1066  }
1067 
1068  return 'unkown';
1069  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ phpTypeToMDBType()

ilChatroom::phpTypeToMDBType (   $type)
private

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

References $type.

Referenced by saveSettings().

385  {
386  switch ($type) {
387  case 'string':
388  return 'text';
389  default:
390  return $type;
391  }
392  }
$type
+ Here is the caller graph for this function:

◆ save()

ilChatroom::save ( )

Saves settings using $this->settings.

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

References saveSettings(), and settings().

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

◆ saveFileUploadToDb()

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

Saves information about file uploads in DB.

Parameters
integer$user_id
string$filename
string$type

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

References $DIC, $filename, $type, array, and time.

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

◆ saveSettings()

ilChatroom::saveSettings ( array  $settings)

Saves settings into settingsTable using given settings array.

Parameters
array$settings

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

References $DIC, $type, array, and phpTypeToMDBType().

Referenced by save().

349  {
350  global $DIC;
351 
352  $localSettings = array();
353 
354  foreach ($this->availableSettings as $setting => $type) {
355  if (isset($settings[$setting])) {
356  if ($type == 'boolean') {
357  $settings[$setting] = (boolean) $settings[$setting];
358  }
359  $localSettings[$setting] = array($this->phpTypeToMDBType($type), $settings[$setting]);
360  }
361  }
362 
363  if (!$localSettings['room_type'][1]) {
364  $localSettings['room_type'][1] = 'repository';
365  }
366 
367  if ($this->roomId) {
368  $DIC->database()->update(
369  self::$settingsTable,
370  $localSettings,
371  array('room_id' => array('integer', $this->roomId))
372  );
373  } else {
374  $this->roomId = $DIC->database()->nextId(self::$settingsTable);
375 
376  $localSettings['room_id'] = array(
377  $this->availableSettings['room_id'], $this->roomId
378  );
379 
380  $DIC->database()->insert(self::$settingsTable, $localSettings);
381  }
382  }
$type
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
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 187 of file class.ilChatroom.php.

References $name, and settings().

Referenced by initialize().

188  {
189  $this->settings[$name] = $value;
190  }
if($format !==null) $name
Definition: metadata.php:146
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subscribeUserToPrivateRoom()

ilChatroom::subscribeUserToPrivateRoom (   $room_id,
  $user_id 
)

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

References $DIC, $id, array, time, and userIsInPrivateRoom().

1140  {
1141  global $DIC;
1142 
1143  if (!$this->userIsInPrivateRoom($room_id, $user_id)) {
1144  $id = $DIC->database()->nextId(self::$privateSessionsTable);
1145  $DIC->database()->insert(
1146  self::$privateSessionsTable,
1147  array(
1148  'psess_id' => array('integer', $id),
1149  'proom_id' => array('integer', $room_id),
1150  'user_id' => array('integer', $user_id),
1151  'connected' => array('integer', time()),
1152  'disconnected' => array('integer', 0),
1153  )
1154  );
1155  }
1156  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
userIsInPrivateRoom($room_id, $user_id)
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ unbanUser()

ilChatroom::unbanUser (   $user_id)

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

Parameters
mixed$user_id
Returns
boolean

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

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

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

◆ unsubscribeUserFromPrivateRoom()

ilChatroom::unsubscribeUserFromPrivateRoom (   $room_id,
  $user_id 
)
Parameters
integer$room_id
integer$user_id

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

References $DIC, array, and time.

1177  {
1178  global $DIC;
1179 
1180  $DIC->database()->update(
1181  self::$privateSessionsTable,
1182  array(
1183  'disconnected' => array('integer', time())
1184  ),
1185  array(
1186  'proom_id' => array('integer', $room_id),
1187  'user_id' => array('integer', $user_id)
1188  )
1189  );
1190  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ userIsInPrivateRoom()

ilChatroom::userIsInPrivateRoom (   $room_id,
  $user_id 
)

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

References $DIC, $query, and array.

Referenced by subscribeUserToPrivateRoom().

1159  {
1160  global $DIC;
1161 
1162  $query = 'SELECT proom_id id FROM ' . self::$privateSessionsTable . ' WHERE user_id = %s AND proom_id = %s AND disconnected = 0';
1163  $types = array('integer', 'integer');
1164  $values = array($user_id, $room_id);
1165  $rset = $DIC->database()->queryF($query, $types, $values);
1166  if ($DIC->database()->fetchAssoc($rset)) {
1167  return true;
1168  }
1169  return false;
1170  }
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

Field Documentation

◆ $availableSettings

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

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

◆ $banTable

ilChatroom::$banTable = 'chatroom_bans'
staticprivate

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

◆ $historyTable

ilChatroom::$historyTable = 'chatroom_history'
staticprivate

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

◆ $object

ilChatroom::$object
private

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

◆ $privateRoomsAccessTable

ilChatroom::$privateRoomsAccessTable = 'chatroom_proomaccess'
staticprivate

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

◆ $privateRoomsTable

ilChatroom::$privateRoomsTable = 'chatroom_prooms'
staticprivate

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

◆ $privateSessionsTable

ilChatroom::$privateSessionsTable = 'chatroom_psessions'
staticprivate

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

◆ $roomId

ilChatroom::$roomId
private

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

Referenced by getRoomId().

◆ $sessionTable

ilChatroom::$sessionTable = 'chatroom_sessions'
staticprivate

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

◆ $settings

ilChatroom::$settings = array()
private

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

Referenced by addPrivateRoom(), and getSettings().

◆ $settingsTable

ilChatroom::$settingsTable = 'chatroom_settings'
staticprivate

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

◆ $uploadTable

ilChatroom::$uploadTable = 'chatroom_uploads'
staticprivate

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

◆ $userTable

ilChatroom::$userTable = 'chatroom_users'
staticprivate

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


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