An alternative format that I use that puts the date in front (more easily sorted by date visually):$LastUserActionLineFmt = ' %Y-%m-%d %H:%M:%S * {$AuthId} * ACTION [[TARGET]] from REMOTE_ADDR';

where:

REMOTE_ADDR

is the address of the user.

ACTION

is the interaction he had with...

TARGET

the page concerned.

<time variables>

as documented by php's strftime routine

Recommended Use

Since it is easier to just the (:include Profiles.<user>-LastAction:) markup, I didn't add custom markup to return the last action for a particular user.

The way I wanted to use this was to be able to generate a pagelist of user profile pages (on my wiki, every user is forced to have a profile page), and then next to each user, show their last action. Since the line recorded (at least with the default format) is a single line, the page can be included to show the last action string. I created a pagelist custom format to do this on my Site.LocalTemplates page. To learn more about pagelist custom formats, see PageLists.

I have the following pagelist template in Site.LocalTemplates (note the (:include :) command which pulls in the string from the -LastAction page):

Notes

This recipe was originally intended to be a way to record the last login of each account, but it looked easier to just record the last action for each account which would achieve the same purpose (detect stale accounts).

Also, this is my first recipe, so go easy on me and feel free to customize, add, subtract, whatever.

Release Notes

2007-03-25: Updated to fix shutdown function dir weirdness that sometimes occues with apache. Now, the script is able to cope with "register_shutdown_function" sometimes changing directories beneath our feet. Also added a check to immediately return if user is not logged in.

2007-03-20: First release.

Comments

It would be nice if this recipe also added a page variable with the date alone in it. That way, the page variable could be accessed and things could be sorted (such as the pagelist above) on the date. Lordmundi

I found a way to do this by using the new page text variables stuff in 2.2. Simply change your format string to include a hidden page text variable and then whatever you want after it... like this:

forceflow: I had some problems with this cookbook script since it kept interfering with pagelist cache. The disabling of file mod tracking in the current implementation does not work (presumably because you forgot to import $LastModFile as a global. See user_last_action_lastmodfix.phpΔ