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:
parent
6351a72fd0
commit
c1b2fe0dfd
@ -32,6 +32,9 @@ public function readData() {
|
|||||||
$this->users = $this->room->getUsers();
|
$this->users = $this->room->getUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the new messages
|
||||||
|
*/
|
||||||
public function readMessages() {
|
public function readMessages() {
|
||||||
$this->messages = chat\message\ChatMessageList::getMessagesSince($this->room, \wcf\util\ChatUtil::readUserData('lastSeen'));
|
$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 = WCF::getDB()->prepareStatement($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$row = $stmt->fetchArray();
|
$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() {
|
public function readRoom() {
|
||||||
$this->roomID = \wcf\util\ChatUtil::readUserData('roomID');
|
$this->roomID = \wcf\util\ChatUtil::readUserData('roomID');
|
||||||
|
|
||||||
|
@ -65,7 +65,11 @@ public function readData() {
|
|||||||
|
|
||||||
$this->readRoom();
|
$this->readRoom();
|
||||||
$this->userData['color'] = \wcf\util\ChatUtil::readUserData('color');
|
$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) {
|
if (CHAT_DISPLAY_JOIN_LEAVE) {
|
||||||
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
|
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
|
||||||
|
@ -38,6 +38,37 @@ final class ChatUtil {
|
|||||||
*/
|
*/
|
||||||
private static $packageID = null;
|
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.
|
* Returns the packageID of Tims Chat.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user