ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 setSetting ($name, $value)
 Sets given name and value as setting into $this->settings array.
 save ()
 Saves settings using $this->settings.
 addHistoryEntry ($message, $recipient=null, $publicMessage=true)
 Inserts entry into historyTable.
 getConnectedUsers ()
 Returns an array of connected users.
 disconnectUser ($user_id)
 Creates userId array by given $user object and calls disconnectUsers method.
 disconnectUsers (array $userIds)
 Disconnects users by deleting userdata from userTable using given userId array.
 saveSettings (array $settings)
 Saves settings into settingsTable using given settings array.
 getSettings ()
 Returns $this->settings array.
 initialize (array $rowdata)
 Sets $this->roomId by given array $rowdata and calls setSetting method foreach available setting in $this->availableSettings.
 getRoomId ()
 Returns roomID from $this->roomId.
 isSubscribed ($chat_userid)
 Returns true if entry exists in userTable matching given $chat_userid and $this->roomId.
 isAllowedToEnterPrivateRoom ($chat_userid, $proom_id)
 disconnectAllUsersFromAllRooms ()
 Deletes all entrys from userTable.
 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.
 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.
 banUser ($user_id, $comment= '')
 Inserts user into banTable, using given $user_id.
 unbanUser ($user_id)
 Deletes entry from banTable matching roomId and given $user_id and returns true if sucessful.
 isUserBanned ($user_id)
 Returns true if there's an entry in banTable matching roomId and given $user_id.
 getBannedUsers ()
 Returns an multidimensional array containing userdata from users having an entry in banTable with matching roomId.
 getLastSession (ilChatroomUser $user)
 Returns last session from user.
 getSessions (ilChatroomUser $user)
 Returns all session from user.
 addPrivateRoom ($title, ilChatroomUser $owner, $settings)
 closePrivateRoom ($id)
 isOwnerOfPrivateRoom ($user_id, $proom_id)
 getChatURL ($gui, $scope_id=0)
 ilCtrl $ilCtrl
 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
 countActiveUsers ()
 getUniquePrivateRoomTitle ($title)
 getPrivateSubRooms ($parent_room, $user_id)
 getRefIdByRoomId ($room_id)
 Returns ref_id of given room_id.
 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.
static checkPermissionsOfUser ($usr_id, $permissions, $ref_id)
 Checks user permissions in question for a given user id in relation to a given ref_id.
static byObjectId ($object_id)
 Returns ilChatroom object by given $object_id.
static byRoomId ($room_id, $initObject=false)
 Returns ilChatroom by given $room_id.
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

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.

{
global $ilDB;
$subRoom = 0;
if (is_array($message)) {
$subRoom = (int) $message['sub'];
}
else if (is_object($message)) {
$subRoom = (int) $message->sub;
}
$ilDB->insert(
self::$historyTable,
array(
'room_id' => array('integer', $this->roomId),
'sub_room' => array('integer', $subRoom),
'message' => array('text', json_encode($message)),
'timestamp' => array('integer', time()),
)
);
}
ilChatroom::addPrivateRoom (   $title,
ilChatroomUser  $owner,
  $settings 
)

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

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

Referenced by ilChatroomServerConnector\createPrivateRoom().

{
global $ilDB;
$nextId = $ilDB->nextId('chatroom_prooms');
$ilDB->insert(
self::$privateRoomsTable,
array(
'proom_id' => array('integer', $nextId),
'parent_id' => array('integer', $this->roomId),
'title' => array('text', $title),
'owner' => array('integer', $owner->getUserId()),
'created' => array('integer', time()),
'is_public' => array('integer', $settings['public']),
)
);
return $nextId;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Inserts user into banTable, using given $user_id.

ilDBMySQL $ilDB

Parameters
integer$user_id
string$comment

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

References $comment.

{
global $ilDB;
$ilDB->insert(
self::$banTable,
array(
'room_id' => array('integer', $this->roomId),
'user_id' => array('integer', $user_id),
'timestamp' => array('integer', time()),
'remark' => array('text', $comment),
)
);
}
static ilChatroom::byObjectId (   $object_id)
static

Returns ilChatroom object by given $object_id.

ilDBMySQL $ilDB

Parameters
integer$object_id
Returns
ilChatroom

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

References $row.

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

{
global $ilDB;
$query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE object_id = %s';
$types = array('integer');
$values = array($object_id);
$rset = $ilDB->queryF( $query, $types, $values );
if( $row = $ilDB->fetchAssoc( $rset ) )
{
$room = new self();
$room->initialize( $row );
return $room;
}
}

+ Here is the caller graph for this function:

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

References $row, and ilObjectFactory\getInstanceByObjId().

Referenced by ilChatroomServerHandler\disconnectedUsers().

{
global $ilDB;
$query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE room_id = %s';
$types = array('integer');
$values = array($room_id);
$rset = $ilDB->queryF( $query, $types, $values );
if( $row = $ilDB->fetchAssoc( $rset ) )
{
$room = new self();
$room->initialize( $row );
if ($initObject) {
$room->object = ilObjectFactory::getInstanceByObjId($row['object_id']);
}
return $room;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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, $ref_id, and $usr_id.

Referenced by ilChatroomKickTask\sub().

{
global $rbacsystem, $lng;
if( !is_array($permissions) )
{
$permissions = array( $permissions );
}
foreach( $permissions as $permission )
{
if( !$rbacsystem->checkAccessOfUser($usr_id, $permission, $ref_id ) )
{
return false;
}
}
return true;
}

+ Here is the caller graph for this function:

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 ilChatroomBanTask\active(), ilChatroomPrivateRoomTask\create(), ilChatroomPrivateRoomTask\enter(), ilChatroomClearTask\executeDefault(), ilChatroomPostMessageTask\executeDefault(), ilChatroomBanTask\show(), ilChatroomHistoryTask\showMessages(), ilChatroomUploadFileTask\uploadFile(), and ilChatroomSmileyTask\view().

{
global $rbacsystem, $lng;
if( !is_array($permissions) )
{
$permissions = array( $permissions );
}
foreach( $permissions as $permission )
{
if( !$rbacsystem->checkAccess( $permission, $ref_id ) )
{
if ($send_info) {
ilUtil::sendFailure( $lng->txt("permission_denied"), true );
}
return false;
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroom::clearMessages (   $sub_room)

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

{
global $ilDB;
$ilDB->queryF(
'DELETE FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = %s',
array('integer', 'integer'),
array($this->roomId, (int)$sub_room)
);
if ($sub_room) {
$ilDB->queryF(
'DELETE FROM ' . self::$sessionTable . ' WHERE proom_id = %s AND disconnected < %s',
array('integer', 'integer'),
array($sub_room, time())
);
}
else {
$ilDB->queryF(
'DELETE FROM ' . self::$sessionTable . ' WHERE room_id = %s AND disconnected < %s',
array('integer', 'integer'),
array($this->roomId, time())
);
}
}
ilChatroom::closePrivateRoom (   $id)

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

{
global $ilDB;
$ilDB->manipulateF(
'UPDATE ' . self::$privateRoomsTable . ' SET closed = %s WHERE proom_id = %s',
array('integer', 'integer'),
array(time(), $id)
);
}
ilChatroom::countActiveUsers ( )

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

References $row.

{
global $ilDB;
$query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
' WHERE room_id = %s';
$types = array('integer');
$values = array($this->roomId);
$rset = $ilDB->queryF( $query, $types, $values );
if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
return $row['cnt'];
return 0;
}
ilChatroom::disconnectAllUsersFromAllRooms ( )

Deletes all entrys from userTable.

ilDBMySQL $ilDB

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

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

Referenced by ilChatroomServerHandler\serverStarted().

{
global $ilDB;
$ilDB->manipulate( 'DELETE FROM ' . self::$userTable );
$ilDB->manipulate( 'UPDATE ' . self::$privateRoomsTable . ' SET closed = ' . $ilDB->quote( time() ,'integer') . ' WHERE closed = 0 OR closed IS NULL');
$ilDB->manipulate( 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = ' . $ilDB->quote( time() ,'integer') . ' WHERE disconnected = 0 OR disconnected IS NULL');
}

+ Here is the caller graph for this function:

ilChatroom::disconnectUser (   $user_id)

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

Parameters
int$user_id

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

References disconnectUsers().

{
$this->disconnectUsers( array($user_id) );
}

+ Here is the call graph for this function:

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

References $row, and getSetting().

Referenced by disconnectUser().

{
global $ilDB;
$query = 'SELECT * FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
$ilDB->in( 'user_id', $userIds, false, 'integer' );
$types = array('integer');
$values = array($this->roomId);
$rset = $ilDB->queryF( $query, $types, $values );
if( $row = $ilDB->fetchAssoc( $rset ) )
{
$query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s';
$rset_prooms = $ilDB->queryF($query, array('integer'), array($this->roomId));
$prooms = array();
while($row_prooms = $ilDB->fetchAssoc($rset_prooms)) {
$prooms[] = $row_prooms['proom_id'];
}
if (true || $this->getSetting( 'enable_history' )) {
$query = 'UPDATE ' . self::$privateSessionsTable . ' SET disconnected = %s WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
$ilDB->manipulateF($query, array('integer'), array(time()));
}
else {
$query = 'DELETE FROM ' . self::$privateSessionsTable . ' WHERE ' . $ilDB->in('user_id', $userIds, false, 'integer') . ' AND ' . $ilDB->in('proom_id', $prooms, false, 'integer');
$ilDB->manipulate($query);
}
$query = 'DELETE FROM ' . self::$userTable . ' WHERE room_id = %s AND ' .
$ilDB->in( 'user_id', $userIds, false, 'integer' );
$types = array('integer');
$values = array($this->roomId);
$ilDB->manipulateF( $query, $types, $values );
do
{
if ($this->getSetting( 'enable_history' )) {
$ilDB->insert(
self::$sessionTable,
array(
'room_id' => array('integer', $this->roomId),
'user_id' => array('integer', $row['user_id']),
'userdata' => array('text', $row['userdata']),
'connected' => array('integer', $row['connected']),
'disconnected' => array('integer', time()),
)
);
}
}
while( $row = $ilDB->fetchAssoc( $rset ) );
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroom::findDeletablePrivateRooms ( )
static

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

References $row.

Referenced by ilChatroomServerHandler\cleanupPrivateRooms().

{
global $ilDB;
$query = 'SELECT private_rooms.proom_id id, MIN(disconnected) min_disconnected, MAX(disconnected) max_disconnected FROM ' . self::$privateSessionsTable . ' private_sessions INNER JOIN '.self::$privateRoomsTable.' private_rooms ON private_sessions.proom_id = private_rooms.proom_id WHERE closed = 0 GROUP BY private_rooms.proom_id HAVING min_disconnected > 0 AND max_disconnected < %s';
$rset = $ilDB->queryF(
array('integer'),
array(time() + 60 * 5)
);
$rooms = array();
while ($row = $ilDB->fetchAssoc($rset)) {
$rooms[] = $row['id'];
}
$query = 'SELECT DISTINCT proom_id, room_id, object_id FROM ' . self::$privateRoomsTable
. ' INNER JOIN ' . self::$settingsTable . ' ON parent_id = room_id '
. ' WHERE ' . $ilDB->in('proom_id', $rooms, false, 'integer');
$rset = $ilDB->query($query);
$rooms = array();
while($row = $ilDB->fetchAssoc($rset)) {
$rooms[] = array(
'proom_id' => $row['proom_id'],
'room_id' => $row['room_id'],
'object_id' => $row['object_id']
);
}
return $rooms;
}

+ Here is the caller graph for this function:

ilChatroom::getActivePrivateRooms (   $userid)

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

References $row, and listUsersInPrivateRoom().

{
global $ilDB;
$query = '
SELECT roomtable.title, roomtable.proom_id, accesstable.user_id id, roomtable.owner owner FROM ' . self::$privateRoomsTable . ' roomtable
LEFT JOIN '.self::$privateRoomsAccessTable.' accesstable ON roomtable.proom_id = accesstable.proom_id AND accesstable.user_id = %s
WHERE parent_id = %s AND (closed = 0 OR closed IS NULL) AND (accesstable.user_id IS NOT NULL OR roomtable.owner = %s)';
$types = array('integer', 'integer', 'integer');
$values = array($userid, $this->roomId, $userid);
$rset = $ilDB->queryF( $query, $types, $values );
$rooms = array();
while( $row = $ilDB->fetchAssoc( $rset ) )
{
$row['active_users'] = $this->listUsersInPrivateRoom($row['id']);
$row['owner'] = $row['owner'];
$rooms[$row['proom_id']] = $row;
}
return $rooms;
}

+ Here is the call graph for this function:

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

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

{
global $ilDB;
$query = 'SELECT * FROM ' . self::$banTable . ' WHERE room_id = %s ';
$types = array('integer');
$values = array($this->getRoomId());
$rset = $ilDB->queryF( $query, $types, $values );
$result = array();
if( $rset )
{
while( $row = $ilDB->fetchAssoc( $rset ) )
{
if( $row['user_id'] > 0 )
{
$user = new ilObjUser( $row['user_id'] );
$userdata = array(
'user_id' => $user->getId(),
'firstname' => $user->getFirstname(),
'lastname' => $user->getLastname(),
'login' => $user->getLogin(),
'remark' => $row['remark']
);
$result[] = $userdata;
}
else
{
//@todo anonymous user
}
}
}
return $result;
}

+ Here is the call graph for this function:

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

ilCtrl $ilCtrl

Parameters
<type>$gui
<type>$scope_id

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

References ilLink\_getStaticLink().

{
include_once 'Services/Link/classes/class.ilLink.php';
$url = '';
if(is_object($gui))
{
if($scope_id)
{
$url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType(), true, '_'.$scope_id);
}
else
{
$url = ilLink::_getStaticLink($gui->object->getRefId(), $gui->object->getType());
}
}
return $url;
}

+ Here is the call graph for this function:

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

References $row.

{
global $ilDB;
$query = 'SELECT userdata FROM ' . self::$userTable . ' WHERE room_id = %s';
$types = array('integer');
$values = array($this->roomId);
$rset = $ilDB->queryF( $query, $types, $values );
$users = array();
while( $row = $ilDB->fetchAssoc( $rset ) )
{
$users[] = json_decode( $row['userdata'] );
}
return $users;
}
ilChatroom::getDescription ( )

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

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

{
if (!$this->object)
{
$this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
}
return $this->object->getDescription();
}

+ Here is the call graph for this function:

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

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

{
global $ilDB, $ilUser;
$join = '';
if ($proom_id) {
$join .= ' INNER JOIN ' . self::$privateSessionsTable .
' pSessionTable ON pSessionTable.user_id = ' .
$ilDB->quote( $restricted_session_userid, 'integer' ) .
' AND historyTable.sub_room = pSessionTable.proom_id AND timestamp >= pSessionTable.connected AND timestamp <= pSessionTable.disconnected ';
}
$query = 'SELECT historyTable.* FROM ' . self::$historyTable . ' historyTable ' .
$join . ' WHERE historyTable.room_id = ' . $this->getRoomId();
$filter = array();
if( $from != null )
{
$filter[] = 'timestamp >= ' . $ilDB->quote( $from->getUnixTime(), 'integer' );
}
if( $to != null )
{
$filter[] = 'timestamp <= ' . $ilDB->quote( $to->getUnixTime(), 'integer' );
}
if( $filter )
$query .= ' AND ' . join( ' AND ', $filter );
$query .= ' ORDER BY timestamp ASC';
$rset = $ilDB->query( $query );
$result = array();
while( $row = $ilDB->fetchAssoc( $rset ) )
{
$row['message'] = json_decode( $row['message'] );
$row['message']->timestamp = $row['timestamp'];
if ($row['message']->public !== null && !$row['message']->public && !in_array($ilUser->getId(), explode(',', $row['recipients']))) {
continue;
}
}
return $result;
}

+ Here is the call graph for this function:

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

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

References $results, and $row.

{
global $ilDB;
// There is currently no way to check if a message is private or not
// by sql. So we fetch twice as much as we need and hope that there
// are not more than $number private messages.
$ilDB->setLimit($number * 2);
$rset = $ilDB->queryF('SELECT * FROM ' . self::$historyTable . ' WHERE room_id = %s AND sub_room = 0 ORDER BY timestamp DESC', array('integer'), array($this->roomId));
$result_count = 0;
$results = array();
while(($row = $ilDB->fetchAssoc($rset)) && $result_count < $number) {
$tmp = json_decode($row['message']);
if ($chatuser !== null && $tmp->public == 0 && $tmp->recipients) {
if (in_array($chatuser->getUserId(), explode(',',$tmp->recipients))) {
$results[] = $tmp;
++$result_count;
}
}
else if ($tmp->public == 1) {
$results[] = $tmp;
++$result_count;
}
}
return $results;
}
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 792 of file class.ilChatroom.php.

References $row, and ilChatroomUser\getUserId().

{
global $ilDB;
$query = 'SELECT * FROM ' . self::$sessionTable . ' WHERE user_id = ' .
$ilDB->quote( $user->getUserId(), 'integer' ) .
' ORDER BY connected DESC';
$ilDB->setLimit( 1 );
$rset = $ilDB->query( $query );
if( $row = $ilDB->fetchAssoc( $rset ) )
{
return $row;
}
}

+ Here is the call graph for this function:

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

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

References $result, and $row.

{
global $ilDB;
$query = 'SELECT proom_id, title FROM ' . self::$privateRoomsTable . ' WHERE proom_id IN (
SELECT proom_id FROM '.self::$privateSessionsTable.' WHERE connected >= %s AND disconnected <= %s AND user_id = %s
) AND parent_id = %s';
$rset = $ilDB->queryF($query, array('integer','integer','integer','integer'), array($from->getUnixTime(), $to->getUnixTime(), $user_id, $room_id));
$result = array();
while( $row = $ilDB->fetchAssoc( $rset ) )
{
}
return $result;
}
ilChatroom::getPrivateSubRooms (   $parent_room,
  $user_id 
)

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

References $res, and $row.

{
global $ilDB;
$query = "
SELECT proom_id, parent_id
FROM chatroom_prooms
WHERE parent_id = %s
AND owner = %s
AND closed = 0
";
$types = array( 'integer', 'integer' );
$values = array( $parent_room, $user_id );
$res = $ilDB->queryF( $query, $types, $values );
$priv_rooms = array();
while( $row = $ilDB->fetchAssoc( $res ) )
{
$proom_id = $row['proom_id'];
$priv_rooms[$proom_id] = $row['parent_id'];
}
return $priv_rooms;
}
ilChatroom::getRefIdByRoomId (   $room_id)

Returns ref_id of given room_id.

ilDBMySQL $ilDB

Parameters
integer$room_id
Returns
integer

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

References $res, and $row.

{
global $ilDB;
$query = "
SELECT objr.ref_id
FROM object_reference objr
INNER JOIN chatroom_settings cs
ON cs.object_id = objr.obj_id
INNER JOIN object_data od
ON od.obj_id = cs.object_id
WHERE cs.room_id = %s
";
$types = array( 'integer' );
$values = array( $room_id );
$res = $ilDB->queryF( $query, $types, $values );
$row = $ilDB->fetchAssoc( $res );
return $row['ref_id'];
}
ilChatroom::getRoomId ( )

Returns roomID from $this->roomId.

Returns
integer

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

References $roomId.

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

{
return $this->roomId;
}

+ Here is the caller graph for this function:

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

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

{
global $ilDB;
$query = 'SELECT * FROM ' . self::$sessionTable
. ' WHERE room_id = '.
$ilDB->quote( $this->getRoomId(), 'integer' ) .
' ORDER BY connected DESC';
$rset = $ilDB->query( $query );
$result = array();
while( $row = $ilDB->fetchAssoc( $rset ) )
{
}
return $result;
}

+ Here is the call graph for this function:

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 disconnectUsers(), getDescription(), and getTitle().

{
return $this->settings[$name];
}

+ Here is the caller graph for this function:

ilChatroom::getSettings ( )

Returns $this->settings array.

Returns
array

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

References $settings.

{
}
ilChatroom::getTitle ( )

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

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

{
if( !$this->object )
{
$this->object = ilObjectFactory::getInstanceByObjId($this->getSetting('object_id'));
}
return $this->object->getTitle();
}

+ Here is the call graph for this function:

ilChatroom::getUniquePrivateRoomTitle (   $title)

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

References $row, and $title.

{
global $ilDB;
$query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE parent_id = %s and closed = 0';
$rset = $ilDB->queryF($query, array('integer'), array($this->roomId));
$titles = array();
while($row = $ilDB->fetchAssoc($rset)) {
$titles[] = $row['title'];
}
$suffix = '';
$i = 0;
do {
if(!in_array($title . $suffix, $titles)) {
$title .= $suffix;
break;
}
++$i;
$suffix = ' (' . $i . ')';
} while(true);
return $title;
}
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 471 of file class.ilChatroom.php.

References setSetting().

{
$this->roomId = $rowdata['room_id'];
foreach( $this->availableSettings as $setting => $type )
{
if( isset($rowdata[$setting]) )
{
settype($rowdata[$setting], $this->availableSettings[$setting]);
$this->setSetting( $setting, $rowdata[$setting] );
}
}
}

+ Here is the call graph for this function:

ilChatroom::inviteUserToPrivateRoomByLogin (   $login,
  $proom_id 
)

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

References ilObjUser\_lookupId().

{
global $ilDB;
$user_id = ilObjUser::_lookupId($login);
$this->inviteUserToPrivateRoom($user_id, $proom_id);
}

+ Here is the call graph for this function:

ilChatroom::isAllowedToEnterPrivateRoom (   $chat_userid,
  $proom_id 
)

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

References $row.

{
//echo call_user_func_array('sprintf', array_merge(array($query), $values));
global $ilDB;
$query = 'SELECT count(user_id) cnt FROM ' . self::$privateRoomsAccessTable .
' WHERE proom_id = %s AND user_id = %s';
$types = array('integer', 'integer');
$values = array($proom_id, $chat_userid);
$rset = $ilDB->queryF( $query, $types, $values );
if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
return true;
$query = 'SELECT count(*) cnt FROM ' . self::$privateRoomsTable .
' WHERE proom_id = %s AND owner = %s';
$types = array('integer', 'integer');
$values = array($proom_id, $chat_userid);
$rset = $ilDB->queryF( $query, $types, $values );
if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
return true;
return false;
}
ilChatroom::isOwnerOfPrivateRoom (   $user_id,
  $proom_id 
)

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

{
global $ilDB;
$query = 'SELECT proom_id FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s AND owner = %s';
$types = array('integer', 'integer');
$values = array($proom_id, $user_id);
$rset = $ilDB->queryF($query, $types, $values);
if ($rset && $ilDB->fetchAssoc($rset)) {
return true;
}
return false;
}
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 503 of file class.ilChatroom.php.

References $row.

{
global $ilDB;
$query = 'SELECT count(user_id) as cnt FROM ' . self::$userTable .
' WHERE room_id = %s AND user_id = %s';
$types = array('integer', 'integer');
$values = array($this->roomId, $chat_userid);
$rset = $ilDB->queryF( $query, $types, $values );
if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] == 1 )
return true;
return false;
}
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 720 of file class.ilChatroom.php.

References $row, and getRoomId().

{
global $ilDB;
$query = 'SELECT count(user_id) cnt FROM ' . self::$banTable .
' WHERE user_id = %s AND room_id = %s';
$types = array('integer', 'integer');
$values = array($user_id, $this->getRoomId());
$rset = $ilDB->queryF( $query, $types, $values );
if( $rset && ($row = $ilDB->fetchAssoc( $rset )) && $row['cnt'] )
return true;
return false;
}

+ Here is the call graph for this function:

ilChatroom::listUsersInPrivateRoom (   $private_room_id)

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

References $row.

Referenced by getActivePrivateRooms().

{
global $ilDB;
$query = 'SELECT user_id FROM ' . self::$privateSessionsTable . ' WHERE proom_id = %s AND disconnected = 0 OR disconnected IS NULL';
$types = array('integer');
$values = array($private_room_id);
$rset = $ilDB->queryF( $query, $types, $values );
$users = array();
while ($row = $ilDB->fetchAssoc($rset)) {
$users[] = $row['user_id'];
}
return $users;
}

+ Here is the caller graph for this function:

static ilChatroom::lookupPrivateRoomTitle (   $proom_id)
static

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

References $row.

Referenced by ilChatroomServerConnector\inviteToPrivateRoom().

{
global $ilDB;
$query = 'SELECT title FROM ' . self::$privateRoomsTable . ' WHERE proom_id = %s';
$types = array('integer');
$values = array($proom_id);
$rset = $ilDB->queryF($query, $types, $values);
if ($row = $ilDB->fetchAssoc($rset)) {
return $row['title'];
}
return 'unkown';
}

+ Here is the caller graph for this function:

ilChatroom::phpTypeToMDBType (   $type)
private

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

Referenced by saveSettings().

{
switch($type) {
case 'string':
return 'text';
default:
return $type;
}
}

+ Here is the caller graph for this function:

ilChatroom::save ( )

Saves settings using $this->settings.

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

References saveSettings().

{
$this->saveSettings( $this->settings );
}

+ Here is the call graph for this function:

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

References $filename.

{
global $ilDB;
$upload_id = $ilDB->nextId( self::$uploadTable );
$ilDB->insert(
self::$uploadTable,
array(
'upload_id' => array('integer', $upload_id),
'room_id' => array('integer', $this->roomId),
'user_id' => array('integer', $user_id),
'filename' => array('text', $filename),
'filetype' => array('text', $type),
'timestamp' => array('integer', time())
)
);
}
ilChatroom::saveSettings ( array  $settings)

Saves settings into settingsTable using given settings array.

ilDBMySQL $ilDB

Parameters
array$settings

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

References phpTypeToMDBType().

Referenced by save().

{
global $ilDB;
$localSettings = array();
foreach( $this->availableSettings as $setting => $type )
{
if( isset( $settings[$setting] ) ) {
if ($type == 'boolean') {
$settings[$setting] = (boolean)$settings[$setting];
}
$localSettings[$setting] = array($this->phpTypeToMDBType($type), $settings[$setting]);
}
}
if (!$localSettings['room_type'][1]) {
$localSettings['room_type'][1] = 'repository';
}
if( $this->roomId )
{
$ilDB->update(
self::$settingsTable,
$localSettings,
array( 'room_id' => array('integer', $this->roomId) )
);
}
else
{
$this->roomId = $ilDB->nextId( self::$settingsTable );
$localSettings['room_id'] = array(
$this->availableSettings['room_id'], $this->roomId
);
$ilDB->insert( self::$settingsTable, $localSettings );
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

{
$this->settings[$name] = $value;
}

+ Here is the caller graph for this function:

ilChatroom::subscribeUserToPrivateRoom (   $room_id,
  $user_id 
)

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

References userIsInPrivateRoom().

Referenced by ilChatroomServerConnector\createPrivateRoom().

{
global $ilDB;
if (!$this->userIsInPrivateRoom($room_id, $user_id)) {
$ilDB->insert(
self::$privateSessionsTable,
array(
'proom_id' => array('integer', $room_id),
'user_id' => array('integer', $user_id),
'connected' => array('integer', time()),
'disconnected' => array('integer', 0),
)
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References getRoomId().

{
global $ilDB;
if( !is_array( $user_id ) )
$user_id = array($user_id);
$query = 'DELETE FROM ' . self::$banTable . ' WHERE room_id = %s AND ' .
$ilDB->in( 'user_id', $user_id, false, 'integer' );
$types = array('integer');
$values = array($this->getRoomId());
return $ilDB->manipulateF( $query, $types, $values );
}

+ Here is the call graph for this function:

ilChatroom::unsubscribeUserFromPrivateRoom (   $room_id,
  $user_id 
)

ilDB $ilDB

Parameters
integer$room_id
integer$user_id

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

{
global $ilDB;
$ilDB->update(
self::$privateSessionsTable,
array(
'disconnected' => array('integer', time())
),
array(
'proom_id' => array('integer', $room_id),
'user_id' => array('integer', $user_id),
)
);
}
ilChatroom::userIsInPrivateRoom (   $room_id,
  $user_id 
)

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

Referenced by subscribeUserToPrivateRoom().

{
global $ilDB;
$query = 'SELECT proom_id id FROM ' . self::$privateSessionsTable . ' WHERE user_id = %s AND proom_id = %s AND disconnected = 0 OR disconnected IS NULL';
$types = array('integer', 'integer');
$values = array($user_id, $room_id);
$rset = $ilDB->queryF( $query, $types, $values );
if ($ilDB->fetchAssoc($rset))
return true;
return false;
}

+ Here is the caller graph for this function:

Field Documentation

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.

ilChatroom::$banTable = 'chatroom_bans'
staticprivate

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

ilChatroom::$historyTable = 'chatroom_history'
staticprivate

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

ilChatroom::$object
private

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

ilChatroom::$privateRoomsAccessTable = 'chatroom_proomaccess'
staticprivate

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

ilChatroom::$privateRoomsTable = 'chatroom_prooms'
staticprivate

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

ilChatroom::$privateSessionsTable = 'chatroom_psessions'
staticprivate

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

ilChatroom::$roomId
private

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

Referenced by getRoomId().

ilChatroom::$sessionTable = 'chatroom_sessions'
staticprivate

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

ilChatroom::$settings = array()
private

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

Referenced by addPrivateRoom(), and getSettings().

ilChatroom::$settingsTable = 'chatroom_settings'
staticprivate

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

ilChatroom::$uploadTable = 'chatroom_uploads'
staticprivate

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

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: