OK, so I've been working on a 'recent activity' component recently, and while there's a few ways to aggregate all the relevant data across a site, I keep coming back to a custom event with a plugin to handle the logging of actions into a new db table.
I post my thoughts and vague plans here in the hope of some external opinion and critique before i dedicate myself to building the component properly. Please let me know your thoughts, suggestions or ridicule...
The Event
@name OnUserAction
@service 6
@groupname Users
In order to handle aggregation of input from various (futureproofed) sources, the event accepts an array of predefined yet flexible parameters:
@param string action - Name of action (past-tense, lowercase, english) [required]
@param string object - Name of object action was performed on [optional]
@param int user - ID of user committing the action [optional - defaults to session user id]
@param string f1..f5 - 5 free text fields that can be used to store other data around the action to allow better filtering of records on output
The main Plugin
Bound to the new event is the main workhorse plugin. It will take the parameters supplied to the event and create an object describing the action
class modUserAction extends xPDOSimpleObject
var int user - The id of the user who commited the action
var string action - Verb describing the action
var string object - Object action was performed on
var int timestamp - Time action occurred
var str f1..f5 - Free text fields storing extra data. Will vary by action type.
The core trigger Plugin
A secondary plugin bound to various system events to invoke an OnUserAction event when resources are published or updated, when users register or update their profile etc.
The extensible bit
The idea behind setting things up this way is that future 3rd party components would have the option to include a call to the event, participating in the tracking process.
So yeah... that took far longer to articulate in a vaguely coherent manner than i expected, but I think it has the potential to be a valuable addition to the core process. Any thoughts?
[ed. note: alanpich last edited this post 13 years, 11 months ago.]