akeeba / fof

Rapid Application Development framework for Joomla!™ 3 and 4
0 stars 0 forks source link

Add support for User Actions Log #677

Closed tampe125 closed 5 years ago

tampe125 commented 5 years ago

This PR implements a trait for the models to add support to Joomla! user logging. The component will be responsible to enable logging and add logs during sensible operations.

Skullbock commented 5 years ago

@nikosdion what if we deal with this using events?

Let's provide a utility that intercepts standard model events (save / create, etc) ad lets the user log the activity using that event, maybe through a listener class that can be configured, but must be manually written by the developer

nikosdion commented 5 years ago

There's an inherent disparity between what constitutes a Model event and what constitutes an action worth logging.

For example, I would argue that a user associating their account with a social media account (like you could do with SocialLogin) is an event worth logging because it has security implications, even though it's technically raised from a plugin. On the other hand, taking a backup is a model action but you cannot log it uness it's a back-end backup (meaning that frontend, remote and CLI backups cannot be logged due to the lack of a logged in user).

The most flexible solution is having a platform abstraction method. If in your use case you know that all/some model events result in loggable actions you can write a plugin which hooks into the events[1] automatically created by FOF and logs them. This is a very valid use case for a plugin; if the user does not wish logging to take place they can unpublish the plugin. Bonus points for being able to do also capture Controller events in the same way through a plugin (hint for @tampe125).

[1] "events" is a misnomer in Joomla! 3 but let's not be overly pedantic.

Skullbock commented 5 years ago

Yes, that's what i meant. Instead of logging by default, just provide a platform method to ease the logging procedure. This way, a dev with a plugin or whatever other piece of code that listens to a FOF event, could easily log the actions he wants.

tampe125 commented 5 years ago

Closed as we should use a completely different approach. Stay tuned for attempt n°2