Public Member Functions | |
ilChatRoom ($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) | |
checkAccess () | |
isInvited ($a_id) | |
isOwner () | |
appendMessageToDb ($message) | |
getAllMessages () | |
deleteAllMessages () | |
updateLastVisit () | |
setKicked ($a_usr_id) | |
setUnkicked ($a_usr_id) | |
isKicked ($a_usr_id) | |
getCountActiveUser ($chat_id, $room_id) | |
_getCountActiveUsers ($chat_id, $room_id=0) | |
getActiveUsers () | |
_isActive ($usr_id) | |
getOnlineUsers () | |
validate () | |
deleteRooms ($a_ids) | |
delete ($a_id, $a_owner=0) | |
rename () | |
lookupRoomId () | |
add () | |
getInternalName () | |
getRooms () | |
getRoomsOfObject () | |
getAllRoomsOfObject () | |
getAllRooms () | |
checkWriteAccess () | |
__getCountLines () | |
__deleteFirstLine () | |
__addLine ($message) | |
__read () | |
_unkick ($a_usr_id) | |
Data Fields | |
$ilias | |
$lng | |
$error_msg | |
$ref_id | |
$owner_id | |
$room_id | |
$guests | |
$title | |
$user_id |
Definition at line 33 of file class.ilChatRoom.php.
ilChatRoom::__addLine | ( | $ | message | ) |
Definition at line 589 of file class.ilChatRoom.php.
References $query, $res, getObjId(), and getRoomId().
Referenced by appendMessageToDb().
{ $query = "INSERT INTO chat_room_messages ". "VALUES('0','".$this->getObjId()."','".$this->getRoomId()."','".addslashes($message)."',now())"; $res = $this->ilias->db->query($query); $this->chat_record = new ilChatRecording($this->getObjId()); $this->chat_record->setRoomId($this->getRoomId()); if ($this->chat_record->isRecording()) { $query = "INSERT INTO chat_record_data VALUES ( '0', '" . $this->chat_record->getRecordId() . "', '" . ilUtil::addslashes($message) . "', '" . time() . "')"; $res = $this->ilias->db->query($query); } return true; }
ilChatRoom::__deleteFirstLine | ( | ) |
Definition at line 568 of file class.ilChatRoom.php.
References $query, $res, and $row.
Referenced by appendMessageToDb().
{ $query = "SELECT entry_id, MIN(commit_timestamp) as last_comm FROM chat_room_messages ". "WHERE chat_id = '".$this->getObjId()."' ". "AND room_id = '".$this->getRoomId()."' ". "GROUP BY null"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $entry_id = $row->entry_id; } if($entry_id) { $query = "DELETE FROM chat_room_messages ". "WHERE entry_id = '".$entry_id."'"; $res = $this->ilias->db->query($query); } return true; }
ilChatRoom::__getCountLines | ( | ) |
Definition at line 555 of file class.ilChatRoom.php.
References $query, $res, and $row.
Referenced by appendMessageToDb().
{ $query = "SELECT COUNT(entry_id) as number_lines FROM chat_room_messages ". "WHERE chat_id = '".$this->getObjId()."' ". "AND room_id = '".$this->getRoomId()."'"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { return $row->number_lines; } return 0; }
ilChatRoom::__read | ( | ) |
Definition at line 613 of file class.ilChatRoom.php.
References $query, $res, $row, setOwnerId(), and setTitle().
Referenced by setRoomId().
{ $this->guests = array(); $query = "SELECT * FROM chat_rooms ". "WHERE room_id = '".$this->getRoomId()."'"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->setTitle($row->title); $this->setOwnerId($row->owner); } $query = "SELECT * FROM chat_invitations ". "WHERE room_id = '".$this->getRoomId()."'"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->guests[] = $row->guest_id; } return true; }
ilChatRoom::_getCountActiveUsers | ( | $ | chat_id, | |
$ | room_id = 0 | |||
) |
Definition at line 277 of file class.ilChatRoom.php.
Referenced by ilObjChatListGUI::getProperties(), and ilObjChatGUI::viewObject().
{ global $ilDB; $query = "SELECT * FROM chat_user ". "WHERE chat_id = '".$chat_id."' ". "AND room_id = '".$room_id."' ". "AND last_conn_timestamp > ".time()." - 40"; $res = $ilDB->query($query); return $res->numRows(); }
ilChatRoom::_isActive | ( | $ | usr_id | ) |
Definition at line 306 of file class.ilChatRoom.php.
References $query, $res, and $row.
Referenced by ilPersonalDesktopGUI::__showActiveChatsOfUser().
{ global $ilDB; $query = "SELECT * FROM chat_user ". "WHERE room_id = 0 ". "AND usr_id = '".(int) $usr_id."' ". "AND last_conn_timestamp > ".time()." - 40"; $res = $ilDB->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { return $row->chat_id; } return false; }
ilChatRoom::_unkick | ( | $ | a_usr_id | ) |
Definition at line 638 of file class.ilChatRoom.php.
Referenced by ilStartUpGUI::showLogin().
{ global $ilDB; $ilDB->query("UPDATE chat_user SET kicked = 0 WHERE usr_id = '".$a_usr_id."'"); return true; }
ilChatRoom::add | ( | ) |
Definition at line 433 of file class.ilChatRoom.php.
References $id, $query, $res, and getTitle().
{ $query = "INSERT INTO chat_rooms ". "SET title = '".ilUtil::prepareDBString($this->getTitle())."', ". "chat_id = '".$this->getObjId()."', ". "owner = '".$this->getOwnerId()."'"; $res = $this->ilias->db->query($query); return ($id = $this->ilias->db->getLastInsertId()) ? $id : false; }
ilChatRoom::appendMessageToDb | ( | $ | message | ) |
Definition at line 178 of file class.ilChatRoom.php.
References __addLine(), __deleteFirstLine(), and __getCountLines().
{ if($this->__getCountLines() >= MAX_LINES) { $this->__deleteFirstLine(); } $this->__addLine($message); return true; }
ilChatRoom::checkAccess | ( | ) |
Definition at line 147 of file class.ilChatRoom.php.
References getRoomId(), getUserId(), isInvited(), isOwner(), and setRoomId().
{ if($this->getRoomId()) { if(!$this->isInvited($this->getUserId()) and !$this->isOwner()) { $this->setRoomId(0); return false; } } return true; }
ilChatRoom::checkWriteAccess | ( | ) |
Definition at line 533 of file class.ilChatRoom.php.
References getOwnerId(), getRoomId(), getUserId(), isInvited(), and isKicked().
{ 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; }
ilChatRoom::delete | ( | $ | a_id, | |
$ | a_owner = 0 | |||
) |
Definition at line 356 of file class.ilChatRoom.php.
References $data, $query, and $res.
{ // DELETE ROOM $query = "DELETE FROM chat_rooms WHERE ". "room_id = '".$a_id."'"; if ($a_owner > 0) { " AND owner = '".$a_owner."'"; } $res = $this->ilias->db->query($query); // DELETE INVITATIONS $query = "DELETE FROM chat_invitations WHERE ". "room_id = '".$a_id."'"; $res = $this->ilias->db->query($query); // DELETE MESSAGES $query = "DELETE FROM chat_room_messages WHERE ". "room_id = '".$a_id."'"; $res = $this->ilias->db->query($query); // DELETE USER_DATA $query = "DELETE FROM chat_user WHERE ". "room_id = '".$a_id."'"; if ($a_owner > 0) { " AND owner = '".$a_owner."'"; } $res = $this->ilias->db->query($query); // AND ALL RECORDINGS $query = "SELECT record_id FROM chat_records WHERE room_id = '".$a_id."'"; $res = $this->ilias->db->query($query); if (DB::isError($res)) die("ilObjChat::delete(): " . $res->getMessage() . "<br>SQL-Statement: ".$q); if (($num = $res->numRows()) > 0) { for ($i = 0; $i < $num; $i++) { $data = $res->fetchRow(DB_FETCHMODE_ASSOC); $this->ilias->db->query("DELETE FROM chat_record_data WHERE record_id = '" . $data["record_id"] . "'"); } } $query = "DELETE FROM chat_records WHERE room_id = '".$a_id."'"; $res = $this->ilias->db->query($query); return true; }
ilChatRoom::deleteAllMessages | ( | ) |
ilChatRoom::deleteRooms | ( | $ | a_ids | ) |
Definition at line 343 of file class.ilChatRoom.php.
References $id.
{ 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 | ) |
ilChatRoom::getActiveUsers | ( | ) |
Definition at line 291 of file class.ilChatRoom.php.
References $query, $res, and $row.
{ $query = "SELECT * FROM chat_user ". "WHERE chat_id = '".$this->getObjId()."' ". "AND room_id = '".$this->room_id."' ". "AND last_conn_timestamp > ".time()." - 40"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $usr_ids[] = $row->usr_id; } return $usr_ids ? $usr_ids : array(); }
ilChatRoom::getAllMessages | ( | ) |
Definition at line 188 of file class.ilChatRoom.php.
References $data, $query, $res, and $row.
{ $query = "SELECT message FROM chat_room_messages ". "WHERE chat_id = '".$this->getObjId()."' ". "AND room_id = '".$this->getRoomId()."' ". "ORDER BY commit_timestamp "; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $data[] = $row->message; } return is_array($data) ? implode("<br />",$data) : ""; }
ilChatRoom::getAllRooms | ( | ) |
Definition at line 510 of file class.ilChatRoom.php.
References $chat_id, $obj_id, and ilUtil::_getObjectsByOperations().
{ global $ilObjDataCache,$ilUser; $obj_ids = array(); $unique_chats = array(); 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(); }
ilChatRoom::getAllRoomsOfObject | ( | ) |
Definition at line 494 of file class.ilChatRoom.php.
References $data, $query, $res, and $row.
{ $query = "SELECT * FROM chat_rooms ". "WHERE chat_id = '".$this->getObjId()."'"; $res = $this->ilias->db->query($query); 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(); }
ilChatRoom::getCountActiveUser | ( | $ | chat_id, | |
$ | room_id | |||
) |
ilChatRoom::getErrorMessage | ( | ) |
Definition at line 69 of file class.ilChatRoom.php.
{
return $this->error_msg;
}
ilChatRoom::getGuests | ( | ) |
Definition at line 117 of file class.ilChatRoom.php.
{
return $this->guests ? $this->guests : array();
}
ilChatRoom::getInternalName | ( | ) |
Definition at line 446 of file class.ilChatRoom.php.
References getObjId(), and getRoomId().
{ if(!$this->getRoomId()) { return $this->getObjId(); } else { return $this->getObjId()."_".$this->getRoomId(); } }
ilChatRoom::getName | ( | ) |
Definition at line 98 of file class.ilChatRoom.php.
References getObjId(), and getRoomId().
ilChatRoom::getObjId | ( | ) |
Definition at line 85 of file class.ilChatRoom.php.
Referenced by __addLine(), getInternalName(), and getName().
{
return $this->obj_id;
}
ilChatRoom::getOnlineUsers | ( | ) |
Definition at line 323 of file class.ilChatRoom.php.
References ilUtil::getUsersOnline().
{ // TODO: CHECK INVITABLE AND ALLOW MESSAGES return ilUtil::getUsersOnline(); }
ilChatRoom::getOwnerId | ( | ) |
Definition at line 93 of file class.ilChatRoom.php.
Referenced by checkWriteAccess(), isOwner(), and validate().
{
return $this->owner_id;
}
ilChatRoom::getRoomId | ( | ) |
Definition at line 81 of file class.ilChatRoom.php.
Referenced by __addLine(), checkAccess(), checkWriteAccess(), getInternalName(), and getName().
{
return $this->room_id;
}
ilChatRoom::getRooms | ( | ) |
Definition at line 457 of file class.ilChatRoom.php.
References $data, $query, $res, $row, and $tree.
{ global $tree; $query = "SELECT DISTINCT(cr.room_id) as room_id,owner,title,chat_id FROM chat_rooms AS cr NATURAL LEFT JOIN chat_invitations ". "WHERE (owner = '".$this->getUserId()."') ". "OR (guest_id = '".$this->getUserId()."')"; $res = $this->ilias->db->query($query); 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(); }
ilChatRoom::getRoomsOfObject | ( | ) |
Definition at line 478 of file class.ilChatRoom.php.
References $data, $query, $res, and $row.
{ $query = "SELECT * FROM chat_rooms ". "WHERE chat_id = '".$this->getObjId()."' ". "AND owner = '".$this->getUserId()."'"; $res = $this->ilias->db->query($query); 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(); }
ilChatRoom::getTitle | ( | ) |
Definition at line 113 of file class.ilChatRoom.php.
Referenced by add(), lookupRoomId(), rename(), and validate().
{
return $this->title;
}
ilChatRoom::getUserId | ( | ) |
Definition at line 125 of file class.ilChatRoom.php.
Referenced by checkAccess(), checkWriteAccess(), and isOwner().
{
return $this->user_id;
}
ilChatRoom::ilChatRoom | ( | $ | a_id | ) |
Constructor public.
integer | reference_id or object_id | |
boolean | treat the id as reference_id (true) or object_id (false) |
Definition at line 54 of file class.ilChatRoom.php.
ilChatRoom::invite | ( | $ | a_id | ) |
ilChatRoom::isInvited | ( | $ | a_id | ) |
Definition at line 160 of file class.ilChatRoom.php.
Referenced by checkAccess(), and checkWriteAccess().
{ $query = "SELECT * FROM chat_invitations AS ci JOIN chat_rooms AS ca ". "WHERE ci.room_id = ca.room_id ". "AND ci.room_id = '".$this->getRoomId()."' ". "AND owner = '".$this->getOwnerId()."' ". "AND ci.guest_id = '".$a_id."'"; $res = $this->ilias->db->query($query); return $res->numRows() ? true : false; }
ilChatRoom::isKicked | ( | $ | a_usr_id | ) |
Definition at line 253 of file class.ilChatRoom.php.
Referenced by checkWriteAccess().
{ $query = "SELECT * FROM chat_user ". "WHERE kicked = 1 ". "AND usr_id = '".$a_usr_id."' ". "AND chat_id = '".$this->getObjId()."'"; $res = $this->ilias->db->query($query); return $res->numRows() ? true : false; }
ilChatRoom::isOwner | ( | ) |
Definition at line 172 of file class.ilChatRoom.php.
References getOwnerId(), and getUserId().
Referenced by checkAccess().
{ return $this->getOwnerId() == $this->getUserId(); }
ilChatRoom::lookupRoomId | ( | ) |
Definition at line 418 of file class.ilChatRoom.php.
References $query, $res, $row, and getTitle().
{ $query = "SELECT * FROM chat_rooms ". "WHERE title = '".ilUtil::prepareDBString($this->getTitle())."' ". "AND chat_id = '".$this->getObjId()."' ". "AND owner = '".$this->getOwnerId()."'"; $res = $this->ilias->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { return $row->room_id; } return false; }
ilChatRoom::rename | ( | ) |
Definition at line 407 of file class.ilChatRoom.php.
References $query, $res, and getTitle().
{ $query = "UPDATE chat_rooms ". "SET title = '".ilUtil::prepareDBString($this->getTitle())."' ". "WHERE room_id = '".$this->getRoomId()."'"; $res = $this->ilias->db->query($query); return true; }
ilChatRoom::setKicked | ( | $ | a_usr_id | ) |
Definition at line 229 of file class.ilChatRoom.php.
References $query.
ilChatRoom::setOwnerId | ( | $ | a_id | ) |
Definition at line 89 of file class.ilChatRoom.php.
Referenced by __read().
{ $this->owner_id = $a_id; }
ilChatRoom::setRoomId | ( | $ | a_id | ) |
Definition at line 74 of file class.ilChatRoom.php.
References __read().
Referenced by checkAccess().
{ $this->room_id = $a_id; // READ DATA OF ROOM $this->__read(); }
ilChatRoom::setTitle | ( | $ | a_title | ) |
Definition at line 109 of file class.ilChatRoom.php.
Referenced by __read().
{ $this->title = $a_title; }
ilChatRoom::setUnkicked | ( | $ | a_usr_id | ) |
Definition at line 241 of file class.ilChatRoom.php.
References $query.
ilChatRoom::setUserId | ( | $ | a_id | ) |
Definition at line 121 of file class.ilChatRoom.php.
{ $this->user_id = $a_id; }
ilChatRoom::updateLastVisit | ( | ) |
Definition at line 213 of file class.ilChatRoom.php.
{ // CHECK IF OLD DATA EXISTS $query = "DELETE FROM chat_user ". "WHERE usr_id = '".$this->getUserId()."'"; $res = $this->ilias->db->query($query); $query = "INSERT INTO chat_user ". "SET usr_id = '".$this->getUserId()."', ". "room_id = '".$this->getRoomId()."', ". "chat_id = '".$this->getObjId()."', ". "last_conn_timestamp = '".time()."'"; $res = $this->ilias->db->query($query); return true; }
ilChatRoom::validate | ( | ) |
Definition at line 329 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; }
ilChatRoom::$error_msg |
Definition at line 38 of file class.ilChatRoom.php.
ilChatRoom::$guests |
Definition at line 43 of file class.ilChatRoom.php.
ilChatRoom::$ilias |
Definition at line 35 of file class.ilChatRoom.php.
Referenced by ilChatRoom().
ilChatRoom::$lng |
Definition at line 36 of file class.ilChatRoom.php.
Referenced by ilChatRoom().
ilChatRoom::$owner_id |
Definition at line 41 of file class.ilChatRoom.php.
ilChatRoom::$ref_id |
Definition at line 40 of file class.ilChatRoom.php.
ilChatRoom::$room_id |
Definition at line 42 of file class.ilChatRoom.php.
ilChatRoom::$title |
Definition at line 44 of file class.ilChatRoom.php.
ilChatRoom::$user_id |
Definition at line 46 of file class.ilChatRoom.php.