implement user activity log in cakePHP
Which is the best method to implement user activity log in cakePHP?
I already gone through these tutorials- logable behavior
- http://www.cakephp.co.uk/user_activity_cakephp_tutorial.html
My aim is to log these 开发者_如何转开发activities
- Login
- Logout
- Update Profile
- Change Password
- placing an order
- review order
- cancel order
where should i write the code for log, in App_controller or App_model or afterSave of each model.
I Guess, that using logable behaviour is a good idea (although get the newest version (see comments in the bakery)). That would be a very "convention-like" way to go.
The second link also provides a nice way to do this, a small amount of neat code (needs some refreshments though).
I think the best place to call this recordActivity function are models callback methods, here's a list of them.
I didn't use the behavior, I built my own. I put it on the afterSave (in app_model). You'll want to add a trigger to catch the login actions, though, as they don't do a save.
精彩评论