1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Adding lastActivity

This commit is contained in:
Tim Düsterhus 2012-04-15 21:37:20 +02:00
parent 6351a72fd0
commit c1b2fe0dfd
3 changed files with 47 additions and 2 deletions

View File

@ -32,6 +32,9 @@ public function readData() {
$this->users = $this->room->getUsers();
}
/**
* Fetches the new messages
*/
public function readMessages() {
$this->messages = chat\message\ChatMessageList::getMessagesSince($this->room, \wcf\util\ChatUtil::readUserData('lastSeen'));
@ -43,9 +46,16 @@ public function readMessages() {
$stmt = WCF::getDB()->prepareStatement($sql);
$stmt->execute();
$row = $stmt->fetchArray();
\wcf\util\ChatUtil::writeUserData(array('lastSeen' => $row['messageID']));
\wcf\util\ChatUtil::writeUserData(array(
'lastSeen' => $row['messageID'],
'lastActivity' => TIME_NOW
));
}
/**
* Initializes the room databaseobject.
*/
public function readRoom() {
$this->roomID = \wcf\util\ChatUtil::readUserData('roomID');

View File

@ -65,7 +65,11 @@ public function readData() {
$this->readRoom();
$this->userData['color'] = \wcf\util\ChatUtil::readUserData('color');
\wcf\util\ChatUtil::writeUserData(array('roomID' => $this->room->roomID, 'away' => null));
\wcf\util\ChatUtil::writeUserData(array(
'roomID' => $this->room->roomID,
'away' => null,
'lastActivity' => TIME_NOW
));
if (CHAT_DISPLAY_JOIN_LEAVE) {
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(

View File

@ -38,6 +38,37 @@ final class ChatUtil {
*/
private static $packageID = null;
/**
* Fetches the userIDs of died users.
*
* @return array
*/
public static function getDiedUsers() {
$packageID = \wcf\util\ChatUtil::getPackageID();
$sql = "SELECT
r.userID, r.fieldValue AS roomID
FROM
wcf".WCF_N."_user_storage r
LEFT JOIN
wcf".WCF_N."_user_storage a
ON a.userID = r.userID
AND a.field = ?
AND a.packageID = ?
WHERE
r.field = ?
AND r.packageID = ?
AND a.fieldValue IS NOT NULL
AND (
a.fieldValue < ?
OR a.fieldValue IS NULL
)";
$stmt = WCF::getDB()->prepareStatement($sql);
$stmt->execute(array('lastActivity', $packageID, 'roomID', $packageID, TIME_NOW - 30));
$users = array();
while ($users[] = $stmt->fetchArray());
return $users;
}
/**
* Returns the packageID of Tims Chat.
*/