mirror of
https://github.com/Mibew/i18n.git
synced 2025-01-22 21:40:28 +03:00
Create 'usersUpdateVisitorsLoad' and 'usersUpdateVisitorsAlter' events
This commit is contained in:
parent
a6006211f2
commit
758c727c45
@ -25,6 +25,10 @@
|
||||
* - usersCallError
|
||||
* - usersFunctionCall
|
||||
*
|
||||
* Also triggers follow events (see description of apiUpdateVisitors method):
|
||||
* - usersUpdateVisitorsLoad
|
||||
* - usersUpdateVisitorsAlter
|
||||
*
|
||||
* WARNING:
|
||||
* usersResponseReceived registered but never called because of asynchronous
|
||||
* nature of Core-to-Window interaction
|
||||
@ -331,7 +335,21 @@ class UsersProcessor extends ClientSideProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return updated visitors list. API function
|
||||
* Return updated visitors list. API function.
|
||||
*
|
||||
* Triggers following events:
|
||||
* 1. 'usersUpdateVisitorsLoad': provide the ability to plugins to load,
|
||||
* sort and limiting visitors list. Associative array pass to event
|
||||
* lister have following keys:
|
||||
* - 'visitors': array of visitors arrays. Each visitor array must
|
||||
* contain at least following keys: 'id', 'userName', 'userAgent',
|
||||
* 'userIp', 'remote', 'firstTime', 'lastTime', 'invitations',
|
||||
* 'chats', 'invitationInfo'. If there are no visitors an empty array
|
||||
* should be used.
|
||||
*
|
||||
* 2. 'usersUpdateVisitorsAlter': provide the ability to alter visitors
|
||||
* list. Associative array pass to event lister have following keys:
|
||||
* - 'visitors': array of visitors arrays.
|
||||
*
|
||||
* @param array $args Associative array of arguments. It must contains
|
||||
* following keys:
|
||||
@ -350,12 +368,23 @@ class UsersProcessor extends ClientSideProcessor {
|
||||
track_remove_old_visitors();
|
||||
track_remove_old_tracks();
|
||||
|
||||
$db = Database::getInstance();
|
||||
// Get instance of event dispatcher
|
||||
$dispatcher = EventDispatcher::getInstance();
|
||||
|
||||
// Trigger load event
|
||||
$arguments = array(
|
||||
'visitors' => false
|
||||
);
|
||||
$dispatcher->triggerEvent('usersUpdateVisitorsLoad', $arguments);
|
||||
|
||||
// Check if visiors list loaded by plugins
|
||||
if (! is_array($arguments['visitors'])) {
|
||||
// Load visitors list
|
||||
$db = Database::getInstance();
|
||||
// Load visitors
|
||||
$query = "SELECT visitorid, userid, username, firsttime, lasttime, " .
|
||||
"entry, details, invited, invitationtime, invitedby, " .
|
||||
"invitations, chats " .
|
||||
$query = "SELECT visitorid, userid, username, firsttime, " .
|
||||
"lasttime,entry, details, invited, invitationtime, " .
|
||||
"invitedby, invitations, chats " .
|
||||
"FROM {chatsitevisitor} " .
|
||||
"WHERE threadid IS NULL " .
|
||||
"ORDER BY invited, lasttime DESC, invitations";
|
||||
@ -412,9 +441,18 @@ class UsersProcessor extends ClientSideProcessor {
|
||||
'invitationInfo' => $invitation_info
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$visitors = $arguments['visitors'];
|
||||
}
|
||||
|
||||
// Provide ability to alter visitors list
|
||||
$arguments = array(
|
||||
'visitors' => $visitors
|
||||
);
|
||||
$dispatcher->triggerEvent('usersUpdateVisitorsAlter', $arguments);
|
||||
|
||||
return array(
|
||||
'visitors' => $visitors
|
||||
'visitors' => $arguments['visitors']
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user