ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatRoom Class Reference

Class ilChatUser. More...

+ Collaboration diagram for ilChatRoom:

Public Member Functions

 __construct ($a_id)
 Constructor public.
 getErrorMessage ()
 setRoomId ($a_id)
 getRoomId ()
 getObjId ()
 setOwnerId ($a_id)
 getOwnerId ()
 getName ()
 setTitle ($a_title)
 getTitle ()
 getGuests ()
 setUserId ($a_id)
 getUserId ()
 invite ($a_id)
 drop ($a_id)
 visited ($a_id)
 checkAccess ()
 isInvited ($a_id)
 isOwner ()
 appendMessageToDb ($message)
 getAllMessages ($min_timestamp=0)
 getNewMessages ($last_known_id, &$new_last_known_id=-1, $max_age=0)
 deleteAllMessages ()
 updateLastVisit ()
 setKicked ($a_usr_id)
 setUnkicked ($a_usr_id)
 isKicked ($a_usr_id)
 getCountActiveUser ($chat_id, $room_id)
 getActiveUsers ()
 getOnlineUsers ()
 validate ()
 deleteRooms ($a_ids)
 delete ($a_id, $a_owner=0)
 rename ()
 lookupRoomId ()
 add ()
 getInternalName ()
 getRooms ()
 getRoomsOfObject ($chat_id=0, $owner_id=0)
 getAllRoomsOfObject ($chat_id=0)
 getAllRooms ()
 checkWriteAccess ()

Static Public Member Functions

static _getOwnerId ($room_id)
static _checkAccess ($obj_id, $room_id, $ref_id, $user_id, $owner_id)
static _isInvited ($obj_id, $room_id, $owner_id, $a_id)
static _isKicked ($a_usr_id, $chat_id)
static _getCountActiveUsers ($chat_id, $room_id=0)
static _isActive ($usr_id)
static _checkWriteAccess ($ref_id, $room_id, $user_id)
static _unkick ($a_usr_id)

Data Fields

 $ilias
 $lng
 $error_msg
 $ref_id
 $owner_id
 $room_id
 $guests
 $title
 $user_id

Private Member Functions

 getCountLines ()
 deleteFirstLine ()
 addLine ($message)
 read ()

Detailed Description

Class ilChatUser.

Author
Stefan Meyer
Version
Id:
class.ilChatRoom.php 20772 2009-07-28 07:42:14Z jposselt

Definition at line 32 of file class.ilChatRoom.php.

Constructor & Destructor Documentation

ilChatRoom::__construct (   $a_id)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 53 of file class.ilChatRoom.php.

References $_SESSION, $ilias, and $lng.

{
global $ilias,$lng,$ilUser;
define(MAX_LINES,1000);
$this->ilias =& $ilias;
$this->lng =& $lng;
$this->obj_id = $a_id;
$this->owner_id = $ilUser->getId();
$this->user_id = $_SESSION["AccountId"];
}

Member Function Documentation

static ilChatRoom::_checkAccess (   $obj_id,
  $room_id,
  $ref_id,
  $user_id,
  $owner_id 
)
static

Definition at line 243 of file class.ilChatRoom.php.

References $owner_id, $ref_id, $room_id, and $user_id.

{
global $rbacsystem;
if ($obj_id || $room_id)
{
if(!self::_isInvited($user_id) &&
!$rbacsystem->checkAccess('moderate', $ref_id))
{
return false;
}
}
return true;
}
static ilChatRoom::_checkWriteAccess (   $ref_id,
  $room_id,
  $user_id 
)
static

Definition at line 846 of file class.ilChatRoom.php.

References $ref_id, $room_id, and $user_id.

Referenced by ilMailAddressbookGUI\inviteToChat().

{
global $rbacsystem;
if($rbacsystem->checkAccess('moderate', $ref_id))
{
return true;
}
if(self::_isKicked($user_id, $ref_id))
{
return false;
}
if(!$room_id)
{
return true;
}
if($user_id == self::_getOwnerId($room_id))
{
return true;
}
if(self::_isInvited($user_id))
{
return true;
}
return false;
}

+ Here is the caller graph for this function:

static ilChatRoom::_getCountActiveUsers (   $chat_id,
  $room_id = 0 
)
static

Definition at line 473 of file class.ilChatRoom.php.

References $ilDB, $res, and $room_id.

Referenced by ilObjChatListGUI\getProperties(), and ilObjChatGUI\viewObject().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_user
WHERE chat_id = %s
AND room_id = %s
AND last_conn_timestamp > %s',
array('integer', 'integer', 'integer'),
array($chat_id, $room_id, time() - 40));
//return $ilDB->numRows($res);
return $res->numRows();
}

+ Here is the caller graph for this function:

static ilChatRoom::_getOwnerId (   $room_id)
static

Definition at line 99 of file class.ilChatRoom.php.

References $ilDB, $res, $room_id, $row, and DB_FETCHMODE_OBJECT.

{
global $ilDB;
//$this->guests = array();
$res = $ilDB->queryf('
SELECT owner FROM chat_rooms WHERE room_id = %s',
array('integer'),
array($room_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->owner;
}
return 0;
}
static ilChatRoom::_isActive (   $usr_id)
static

Definition at line 509 of file class.ilChatRoom.php.

References $ilDB, $res, $row, $usr_id, and DB_FETCHMODE_OBJECT.

Referenced by ilUsersOnlineBlockGUI\__showActiveChatsOfUser().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_user
WHERE room_id = %s
AND usr_id = %s
AND last_conn_timestamp > %s',
array('integer', 'integer', 'integer'),
array('0', $usr_id, time() - 40));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->chat_id;
}
return false;
}

+ Here is the caller graph for this function:

static ilChatRoom::_isInvited (   $obj_id,
  $room_id,
  $owner_id,
  $a_id 
)
static

Definition at line 277 of file class.ilChatRoom.php.

References $ilDB, $owner_id, $res, and $room_id.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_invitations ci, chat_rooms ca
WHERE ci.room_id = ca.room_id
AND ci.chat_id = %s
AND ci.room_id = %s
AND owner = %s
AND ci.guest_id = %s',
array('integer', 'integer', 'integer','integer'),
array($obj_id, $room_id, $owner_id, $a_id));
return $res->numRows() ? true : false;
}
static ilChatRoom::_isKicked (   $a_usr_id,
  $chat_id 
)
static

Definition at line 441 of file class.ilChatRoom.php.

References $ilDB, and $res.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_user
WHERE kicked = %s
AND usr_id = %s
AND chat_id = %s',
array('integer', 'integer', 'integer'),
array('1', $a_usr_id, $chat_id));
//return $ilDB->numRows($res) ? true : false;
return $res->numRows() ? true : false;
}
static ilChatRoom::_unkick (   $a_usr_id)
static

Definition at line 993 of file class.ilChatRoom.php.

References $ilDB.

Referenced by ilStartUpGUI\showLogin().

{
global $ilDB;
$statement = $ilDB->manipulateF('
UPDATE chat_user SET kicked = %s
WHERE usr_id = %s',
array('integer', 'integer'),
array('0', $a_usr_id));
return true;
}

+ Here is the caller graph for this function:

ilChatRoom::add ( )

Definition at line 668 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), getOwnerId(), and getTitle().

{
global $ilDB;
$next_id = $ilDB->nextId('chat_rooms');
$res = $ilDB->manipulateF('
INSERT INTO chat_rooms
( room_id,
title,
chat_id,
owner)
VALUES(%s, %s, %s, %s)',
array('integer', 'text', 'integer', 'integer'),
array($next_id, $this->getTitle(), $this->getObjId(), $this->getOwnerId()));
//return ($id = $ilDB->getLastInsertId()) ? $id : false;
return $next_id;
}

+ Here is the call graph for this function:

ilChatRoom::addLine (   $message)
private

Definition at line 925 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), and getRoomId().

Referenced by appendMessageToDb().

{
global $ilDB;
$next_id = $ilDB->nextId('chat_room_messages');
$res = $ilDB->manipulateF('
INSERT INTO chat_room_messages
( entry_id,
chat_id,
room_id,
message,
commit_timestamp)
VALUES(%s, %s, %s, %s, %s)',
array('integer','integer', 'integer', 'text', 'integer'),
array($next_id, $this->getObjId(), $this->getRoomId(), $message, time()));
$id = $ilDB->getLastInsertId();
$this->chat_record = new ilChatRecording($this->getObjId());
$this->chat_record->setRoomId($this->getRoomId());
if ($this->chat_record->isRecording())
{
$next_id = $ilDB->nextId('chat_record_data');
$res = $ilDB->manipulateF('
INSERT INTO chat_record_data
( record_data_id,
record_id,
message,
msg_time)
VALUES(%s, %s, %s, %s)',
array('integer','integer', 'text', 'integer'),
array($next_id, $this->chat_record->getRecordId(), $message, time()));
}
return $next_id;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::appendMessageToDb (   $message)

Definition at line 300 of file class.ilChatRoom.php.

References addLine().

{
//if($this->getCountLines() >= MAX_LINES)
//{
// $this->deleteFirstLine();
//}
$id = $this->addLine($message);
return $id;
}

+ Here is the call graph for this function:

ilChatRoom::checkAccess ( )

Definition at line 224 of file class.ilChatRoom.php.

References $_GET, getObjId(), getRoomId(), getUserId(), isInvited(), isOwner(), setRoomId(), and visited().

{
global $rbacsystem;
if ($this->getObjId() ||
$this->getRoomId())
{
if(!$this->isInvited($this->getUserId()) &&
!$this->isOwner() &&
!$rbacsystem->checkAccess('moderate', $_GET['ref_id']))
{
$this->setRoomId(0);
return false;
}
$this->visited($this->getUserId());
}
return true;
}

+ Here is the call graph for this function:

ilChatRoom::checkWriteAccess ( )

Definition at line 818 of file class.ilChatRoom.php.

References $_GET, getOwnerId(), getRoomId(), getUserId(), isInvited(), and isKicked().

{
global $rbacsystem;
if($rbacsystem->checkAccess('moderate', $_GET['ref_id']))
{
return true;
}
if($this->isKicked($this->getUserId()))
{
return false;
}
if(!$this->getRoomId())
{
return true;
}
if($this->getUserId() == $this->getOwnerId())
{
return true;
}
if($this->isInvited($this->getUserId()))
{
return true;
}
return false;
}

+ Here is the call graph for this function:

ilChatRoom::delete (   $a_id,
  $a_owner = 0 
)

Definition at line 562 of file class.ilChatRoom.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_ASSOC, and ilDB\isDbError().

{
// DELETE ROOM
global $ilDB;
$data_values = array();
$data_types = array();
$query = 'DELETE FROM chat_rooms WHERE room_id = %s';
array_push($data_types, 'integer');
array_push($data_values, $a_id);
if ($a_owner > 0)
{
$query .=' AND owner = %s';
array_push($data_types, 'integer');
array_push($data_values,$a_owner);
}
$res = $ilDB->manipulateF($query, $data_types, $data_values);
// DELETE INVITATIONS
$res = $ilDB->manipulateF('
DELETE FROM chat_invitations WHERE room_id = %s',
array('integer'), array($a_id));
// DELETE MESSAGES
$res = $ilDB->manipulateF('
DELETE FROM chat_room_messages WHERE room_id = %s',
array('integer'),array($a_id));
// DELETE USER_DATA
$data_types = array();
$data_values = array();
$query = 'DELETE FROM chat_user WHERE room_id = %s';
array_push($data_types, 'integer');
array_push($data_values,$a_id);
if ($a_owner > 0)
{
$query .= ' AND owner = %s';
array_push($data_types, 'integer');
array_push($data_values,$a_owner);
}
$res = $ilDB->manipulateF($query, $data_types, $data_values);
// AND ALL RECORDINGS
$res = $ilDB->queryf('
SELECT record_id FROM chat_records WHERE room_id = %s',
array('integer'), array($a_id));
if (ilDB::isDbError($res)) die("ilObjChat::delete(): " . $res->getMessage() . "<br>SQL-Statement: ".$res);
//if (($num = $ilDB->numRows($res)) > 0)
if (($num = $res->numRows()) > 0)
{
for ($i = 0; $i < $num; $i++)
{
$statement_2 = $ilDB->manipulateF('
DELETE FROM chat_record_data WHERE record_id = %s',
array('integer'), array($row['record_id']));
}
}
$statement = $ilDB->manipulateF('
DELETE FROM chat_records WHERE room_id = %s',
array('integer'), array($a_id));
return true;
}

+ Here is the call graph for this function:

ilChatRoom::deleteAllMessages ( )

Definition at line 356 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), and getRoomId().

{
global $ilDB;
$res = $ilDB->manipulateF('
DELETE FROM chat_room_messages
WHERE chat_id = %s
AND room_id = %s',
array('integer', 'integer'),
array($this->getObjId(), $this->getRoomId()));
return true;
}

+ Here is the call graph for this function:

ilChatRoom::deleteFirstLine ( )
private

Definition at line 892 of file class.ilChatRoom.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, getObjId(), and getRoomId().

{
global $ilDB;
/* $res = $ilDB->queryf('
SELECT entry_id, MIN(commit_timestamp) last_comm FROM chat_room_messages
WHERE chat_id = %s
AND room_id = %s
GROUP BY null',
array('integer', 'integer'),
array($this->getObjId(), $this->getRoomId()));
*/
$res = $ilDB->queryf('
SELECT entry_id, MIN(commit_timestamp) last_comm FROM chat_room_messages
WHERE chat_id = %s
AND room_id = %s
GROUP BY entry_id',
array('integer', 'integer'),
array($this->getObjId(), $this->getRoomId()));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$entry_id = $row->entry_id;
}
if($entry_id)
{
$res = $ilDB->manipulateF('
DELETE FROM chat_room_messages WHERE entry_id = %s',
array('integer'), array($entry_id));
}
return true;
}

+ Here is the call graph for this function:

ilChatRoom::deleteRooms (   $a_ids)

Definition at line 549 of file class.ilChatRoom.php.

{
if(!is_array($a_ids))
{
$this->ilias->raiseError("ARRAY REQUIRED",$this->ilias->error_obj->FATAL);
}
foreach($a_ids as $id)
{
$this->delete($id);
}
return true;
}
ilChatRoom::drop (   $a_id)

Definition at line 195 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), and getRoomId().

{
global $ilDB;
$res = $ilDB->manipulateF('
DELETE FROM chat_invitations
WHERE chat_id = %s
AND room_id = %s
AND guest_id = %s',
array('integer', 'integer', 'integer'),
array($this->getObjId(), $this->getRoomId(), $a_id));
}

+ Here is the call graph for this function:

ilChatRoom::getActiveUsers ( )

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

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, and getObjId().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_user
WHERE chat_id = %s
AND room_id = %s
AND last_conn_timestamp > %s',
array('integer', 'integer', 'integer'),
array($this->getObjId(), $this->room_id, time() - 40));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$usr_ids[] = $row->usr_id;
}
return $usr_ids ? $usr_ids : array();
}

+ Here is the call graph for this function:

ilChatRoom::getAllMessages (   $min_timestamp = 0)

Definition at line 310 of file class.ilChatRoom.php.

References $data, $ilDB, $res, $row, DB_FETCHMODE_OBJECT, getObjId(), and getRoomId().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT message FROM chat_room_messages
WHERE chat_id = %s
AND room_id = %s
AND commit_timestamp > %s
ORDER BY commit_timestamp',
array('integer', 'integer', 'integer'),
array($this->getObjId(), $this->getRoomId(), $min_timestamp)
);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$data[] = $row->message;
}
return is_array($data) ? implode("<br />",$data) : "";
}

+ Here is the call graph for this function:

ilChatRoom::getAllRooms ( )

Definition at line 778 of file class.ilChatRoom.php.

References ilUtil\_getObjectsByOperations(), and ilObjChat\_getPublicChatRefId().

Referenced by ilChatBlock\getReadableAreas(), and ilMailAddressbookGUI\inviteToChat().

{
global $ilObjDataCache,$ilUser,$rbacsystem;
$obj_ids = array();
$unique_chats = array();
if($rbacsystem->checkAccess('read',$pub_chat_id))
{
$obj_id = $ilObjDataCache->lookupObjId($pub_chat_id);
if(!in_array($obj_id,$obj_ids))
{
$unique_data['child'] = $pub_chat_id;
$unique_data['title'] = $ilObjDataCache->lookupTitle($obj_id);
$unique_data['obj_id'] = $obj_id;
$unique_data['ref_id'] = $pub_chat_id;
$unique_chats[] = $unique_data;
$obj_ids[] = $obj_id;
}
}
foreach(ilUtil::_getObjectsByOperations("chat","read",$ilUser->getId(),-1) as $chat_id)
{
$obj_id = $ilObjDataCache->lookupObjId($chat_id);
if(!in_array($obj_id,$obj_ids))
{
$unique_data['child'] = $chat_id;
$unique_data['title'] = $ilObjDataCache->lookupTitle($obj_id);
$unique_data['obj_id'] = $obj_id;
$unique_data['ref_id'] = $chat_id;
$unique_chats[] = $unique_data;
$obj_ids[] = $obj_id;
}
}
return $unique_chats ? $unique_chats : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::getAllRoomsOfObject (   $chat_id = 0)

Definition at line 756 of file class.ilChatRoom.php.

References $data, $ilDB, $res, $row, DB_FETCHMODE_OBJECT, and getObjId().

{
global $ilDB;
if (!$chat_id)
$chat_id = $this->getObjId();
$res = $ilDB->queryf('
SELECT * FROM chat_rooms
WHERE chat_id = %s',
array('integer'),
array($chat_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$data[$row->room_id]["room_id"] = $row->room_id;
$data[$row->room_id]["owner"] = $row->owner;
$data[$row->room_id]["title"] = $row->title;
}
return $data ? $data : array();
}

+ Here is the call graph for this function:

ilChatRoom::getCountActiveUser (   $chat_id,
  $room_id 
)

Definition at line 457 of file class.ilChatRoom.php.

References $ilDB, $res, and $room_id.

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_user
WHERE chat_id = %s
AND room_id = %s
AND last_conn_timestamp > %s',
array('integer', 'integer', 'integer'),
array($chat_id, $room_id, time() - 40));
//return $ilDB->numRows($res);
return $res->numRows();
}
ilChatRoom::getCountLines ( )
private

Definition at line 874 of file class.ilChatRoom.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, getObjId(), and getRoomId().

{
global $ilDB;
$res =$ilDB->queryf('
SELECT COUNT(entry_id) number_lines FROM chat_room_messages
WHERE chat_id = %s
AND room_id = %s',
array('integer', 'integer'),
array($this->getObjId(), $this->getRoomId()));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->number_lines;
}
return 0;
}

+ Here is the call graph for this function:

ilChatRoom::getErrorMessage ( )

Definition at line 68 of file class.ilChatRoom.php.

References $error_msg.

{
}
ilChatRoom::getGuests ( )

Definition at line 139 of file class.ilChatRoom.php.

{
return $this->guests ? $this->guests : array();
}
ilChatRoom::getInternalName ( )

Definition at line 687 of file class.ilChatRoom.php.

References getObjId(), and getRoomId().

{
if(!$this->getRoomId())
{
return $this->getObjId();
}
else
{
return $this->getObjId()."_".$this->getRoomId();
}
}

+ Here is the call graph for this function:

ilChatRoom::getName ( )

Definition at line 117 of file class.ilChatRoom.php.

References getObjId(), and getRoomId().

{
if(!$this->getRoomId())
{
return $this->getObjId();
}
else
{
// GET NAME OF PRIVATE CHATROOM
}
}

+ Here is the call graph for this function:

ilChatRoom::getNewMessages (   $last_known_id,
$new_last_known_id = -1,
  $max_age = 0 
)

Definition at line 330 of file class.ilChatRoom.php.

References $data, $ilDB, $res, $row, DB_FETCHMODE_OBJECT, getObjId(), and getRoomId().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT message, entry_id FROM chat_room_messages
WHERE chat_id = %s
AND room_id = %s
AND entry_id > %s
AND commit_timestamp > %s
ORDER BY commit_timestamp',
array('integer', 'integer', 'integer', 'integer'),
array($this->getObjId(), $this->getRoomId(), $last_known_id, $max_age));
$max_id = 0;
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$data[] = $row->message;
$max_id = max($max_id, $row->entry_id);
}
if ($new_last_known_id !== -1) {
$new_last_known_id = $max_id;
}
return $data;
}

+ Here is the call graph for this function:

ilChatRoom::getOnlineUsers ( )

Definition at line 528 of file class.ilChatRoom.php.

References ilUtil\getUsersOnline().

{
// TODO: CHECK INVITABLE AND ALLOW MESSAGES
}

+ Here is the call graph for this function:

ilChatRoom::getOwnerId ( )

Definition at line 94 of file class.ilChatRoom.php.

References $owner_id.

Referenced by add(), checkWriteAccess(), isInvited(), isOwner(), lookupRoomId(), and validate().

{
}

+ Here is the caller graph for this function:

ilChatRoom::getRoomId ( )
ilChatRoom::getRooms ( )

Definition at line 699 of file class.ilChatRoom.php.

References $_GET, $data, $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and getUserId().

{
global $tree, $ilDB, $rbacsystem;
$data_types = array();
$data_values = array();
$query = 'SELECT DISTINCT(cr.room_id) room_id, owner, title, cr.chat_id chat_id
FROM chat_rooms cr LEFT JOIN chat_invitations ON cr.room_id = chat_invitations.room_id
WHERE (owner = %s) OR (guest_id = %s)';
array_push($data_types, 'integer', 'integer');
array_push($data_values, $this->getUserId(), $this->getUserId());
if($rbacsystem->checkAccess('moderate', $_GET['ref_id']))
{
$query .= ' OR 1=1';
//array_push($data_types, 'integer');
//array_push($data_values, '1');
}
$res = $ilDB->queryf($query, $data_types, $data_values);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$data[$row->room_id]["room_id"] = $row->room_id;
$data[$row->room_id]["chat_id"] = $row->chat_id;
$data[$row->room_id]["owner"] = $row->owner;
$data[$row->room_id]["title"] = $row->title;
}
return $data ? $data : array();
}

+ Here is the call graph for this function:

ilChatRoom::getRoomsOfObject (   $chat_id = 0,
  $owner_id = 0 
)

Definition at line 730 of file class.ilChatRoom.php.

References $data, $ilDB, $owner_id, $res, $row, DB_FETCHMODE_OBJECT, getObjId(), and getUserId().

Referenced by ilMailAddressbookGUI\inviteToChat().

{
global $ilDB;
if (!$chat_id)
$chat_id = $this->getObjId();
if (!$owner_id)
$owner_id = $this->getUserId();
$res = $ilDB->queryf('
SELECT * FROM chat_rooms
WHERE chat_id = %s
AND owner = %s',
array('integer', 'integer'),
array($chat_id, $owner_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$data[$row->room_id]["room_id"] = $row->room_id;
$data[$row->room_id]["owner"] = $row->owner;
$data[$row->room_id]["title"] = $row->title;
$data[$row->room_id]["owner"] = $row->owner;
}
return $data ? $data : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::getTitle ( )

Definition at line 134 of file class.ilChatRoom.php.

References $title.

Referenced by add(), lookupRoomId(), rename(), and validate().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilChatRoom::getUserId ( )

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

References $user_id.

Referenced by checkAccess(), checkWriteAccess(), getRooms(), getRoomsOfObject(), isOwner(), and updateLastVisit().

{
}

+ Here is the caller graph for this function:

ilChatRoom::invite (   $a_id)

Definition at line 154 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), and getRoomId().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_invitations
WHERE chat_id = %s
AND room_id = %s
AND guest_id = %s',
array('integer', 'integer', 'integer'),
array($this->getObjId(), $this->getRoomId(), $a_id));
//if ($ilDB->numRows($res) > 0)
if($res->numRows() > 0)
{
$res = $ilDB->manipulateF('
UPDATE chat_invitations
SET invitation_time = %s,
guest_informed = %s
WHERE chat_id = %s
AND room_id = %s
AND guest_id = %s',
array('integer', 'integer', 'integer', 'integer', 'integer'),
array(time(), 0, $this->getObjId(), $this->getRoomId(), $a_id));
}
else
{
$res = $ilDB->manipulateF(
'INSERT INTO chat_invitations
( chat_id,
room_id,
guest_id,
invitation_time
)
VALUES (%s, %s, %s, %s)',
array('integer', 'integer', 'integer', 'integer'),
array($this->getObjId(), $this->getRoomId(), $a_id, time()));
}
}

+ Here is the call graph for this function:

ilChatRoom::isInvited (   $a_id)

Definition at line 259 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), getOwnerId(), and getRoomId().

Referenced by checkAccess(), and checkWriteAccess().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_invitations ci, chat_rooms ca
WHERE ci.room_id = ca.room_id
AND ci.chat_id = %s
AND ci.room_id = %s
AND owner = %s
AND ci.guest_id = %s',
array('integer', 'integer', 'integer','integer'),
array($this->getObjId(), $this->getRoomId(), $this->getOwnerId(), $a_id));
return $res->numRows() ? true : false;
//return $ilDB->numRows($res) ? true : false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::isKicked (   $a_usr_id)

Definition at line 425 of file class.ilChatRoom.php.

References $ilDB, $res, and getObjId().

Referenced by checkWriteAccess(), and updateLastVisit().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_user
WHERE kicked = %s
AND usr_id = %s
AND chat_id = %s',
array('integer', 'integer', 'integer'),
array('1', $a_usr_id, $this->getObjId()));
//return $ilDB->numRows($res) ? true : false;
return $res->numRows() ? true : false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::isOwner ( )

Definition at line 294 of file class.ilChatRoom.php.

References getOwnerId(), and getUserId().

Referenced by checkAccess().

{
return $this->getOwnerId() == $this->getUserId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::lookupRoomId ( )

Definition at line 649 of file class.ilChatRoom.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, getObjId(), getOwnerId(), and getTitle().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM chat_rooms
WHERE title = %s
AND chat_id = %s
AND owner = %s',
array('text', 'integer', 'integer'),
array($this->getTitle(), $this->getObjId(), $this->getOwnerId()));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->room_id;
}
return false;
}

+ Here is the call graph for this function:

ilChatRoom::read ( )
private

Definition at line 962 of file class.ilChatRoom.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, getObjId(), getRoomId(), setOwnerId(), and setTitle().

Referenced by setRoomId().

{
global $ilDB;
$this->guests = array();
$res = $ilDB->queryf('
SELECT * FROM chat_rooms WHERE room_id = %s',
array('integer'),
array($this->getRoomId()));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setTitle($row->title);
$this->setOwnerId($row->owner);
}
$res = $ilDB->queryf('
SELECT * FROM chat_invitations
WHERE chat_id = %s
AND room_id = %s',
array('integer', 'integer'),
array($this->getObjId(), $this->getRoomId()));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->guests[] = $row->guest_id;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::rename ( )

Definition at line 635 of file class.ilChatRoom.php.

References $ilDB, $res, getRoomId(), and getTitle().

{
global $ilDB;
$res = $ilDB->manipulateF('
UPDATE chat_rooms
SET title = %s
WHERE room_id = %s',
array('text', 'integer'),
array($this->getTitle(), $this->getRoomId()));
return true;
}

+ Here is the call graph for this function:

ilChatRoom::setKicked (   $a_usr_id)

Definition at line 394 of file class.ilChatRoom.php.

References $ilDB, $res, and getObjId().

{
global $ilDB;
$res = $ilDB->manipulateF('
UPDATE chat_user
SET kicked = %s
WHERE usr_id = %s
AND chat_id = %s
AND room_id = %s',
array('integer', 'integer', 'integer', 'integer'),
array('1', $a_usr_id, $this->getObjId(), '0'));
return true;
}

+ Here is the call graph for this function:

ilChatRoom::setOwnerId (   $a_id)

Definition at line 89 of file class.ilChatRoom.php.

Referenced by read().

{
$this->owner_id = $a_id;
}

+ Here is the caller graph for this function:

ilChatRoom::setRoomId (   $a_id)

Definition at line 73 of file class.ilChatRoom.php.

References read().

Referenced by ilObjChatGUI\adminRoomsObject(), checkAccess(), ilObjChatGUI\deleteRoomObject(), ilObjChatGUI\renameObject(), and ilObjChatGUI\renameRoomObject().

{
$this->room_id = $a_id;
$this->read(); // READ DATA OF ROOM
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatRoom::setTitle (   $a_title)

Definition at line 129 of file class.ilChatRoom.php.

Referenced by ilObjChatGUI\addPrivateRoomAsyncObject(), ilObjChatGUI\addRoomObject(), and read().

{
$this->title = $a_title;
}

+ Here is the caller graph for this function:

ilChatRoom::setUnkicked (   $a_usr_id)

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

References $ilDB, $res, and getObjId().

{
global $ilDB;
$res = $ilDB->manipulateF('
UPDATE chat_user SET kicked = %s
WHERE usr_id = %s
AND chat_id = %s
AND room_id = %s',
array('integer', 'integer', 'integer', 'integer'),
array('0', $a_usr_id, $this->getObjId(), '0'));
return true;
}

+ Here is the call graph for this function:

ilChatRoom::setUserId (   $a_id)

Definition at line 144 of file class.ilChatRoom.php.

{
$this->user_id = $a_id;
}
ilChatRoom::updateLastVisit ( )

Definition at line 370 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), getRoomId(), getUserId(), and isKicked().

{
// CHECK IF OLD DATA EXISTS
global $ilDB;
$kicked = $this->isKicked($this->getUserId());
$res = $ilDB->manipulateF('
DELETE FROM chat_user WHERE usr_id = %s',
array('integer'),
array($this->getUserId()));
$res = $ilDB->manipulateF('
INSERT INTO chat_user
( usr_id,
room_id,
chat_id,
kicked,
last_conn_timestamp
)
VALUES(%s, %s, %s, %s, %s)',
array('integer', 'integer', 'integer', 'integer', 'integer'),
array($this->getUserId(), $this->getRoomId(), $this->getObjId(), $kicked, time()));
return true;
}

+ Here is the call graph for this function:

ilChatRoom::validate ( )

Definition at line 534 of file class.ilChatRoom.php.

References getOwnerId(), and getTitle().

{
$this->error_msg = "";
if(!$this->getTitle())
{
$this->error_msg .= $this->lng->txt("chat_title_missing");
}
if(!$this->getOwnerId())
{
$this->ilias->raiseError("MISSING OWNER ID",$this->ilias->error_obj->FATAL);
}
return $this->error_msg ? false : true;
}

+ Here is the call graph for this function:

ilChatRoom::visited (   $a_id)

Definition at line 209 of file class.ilChatRoom.php.

References $ilDB, $res, getObjId(), and getRoomId().

Referenced by checkAccess().

{
global $ilDB;
$res = $ilDB->manipulateF('
UPDATE chat_invitations
SET guest_informed = %s
WHERE chat_id = %s
AND room_id = %s
AND guest_id = %s',
array('integer', 'integer', 'integer', 'integer'),
array('1', $this->getObjId(), $this->getRoomId(), $a_id));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilChatRoom::$error_msg

Definition at line 37 of file class.ilChatRoom.php.

Referenced by getErrorMessage().

ilChatRoom::$guests

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

ilChatRoom::$ilias

Definition at line 34 of file class.ilChatRoom.php.

Referenced by __construct().

ilChatRoom::$lng

Definition at line 35 of file class.ilChatRoom.php.

Referenced by __construct().

ilChatRoom::$owner_id

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

Referenced by _checkAccess(), _isInvited(), getOwnerId(), and getRoomsOfObject().

ilChatRoom::$ref_id

Definition at line 39 of file class.ilChatRoom.php.

Referenced by _checkAccess(), and _checkWriteAccess().

ilChatRoom::$title

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

Referenced by getTitle().

ilChatRoom::$user_id

Definition at line 45 of file class.ilChatRoom.php.

Referenced by _checkAccess(), _checkWriteAccess(), and getUserId().


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