User:Andrewds1021/UserLastActivity

Note: This script is still in the testing phase.

This solution was created in response to Thread:1621411.

The purpose of this script is to retrieve and display the timestamp of the last logged action committed by the specified registered user on the local wiki. The script uses MediaWiki's api.php to retrieve this information. If it is able to retrieve the information, it inserts the date and time as the entire contents of the specified HTML element (removing all other content). In the event that the user has no logged actions on the local wiki, an appropriate message will be inserted instead. If there was an issue with retrieving the information (ex. specified user is not in the database), the contents of the specified HTML element are left untouched.

Use/Configuration
To have this script insert the timestamp of a user's most recent logged activity on the local wiki, start by specifying an HTML element for which the content will be replaced with the timestamp. For the selected element, assign the class  as well as one (or both) of the HTML attributes   and. The former attribute should be assigned the user's username while the latter should be assigned the user's user id. Using the user's user id prevents the need to change the assigned value in the event that the user changes their username via the UserRenameTool.

By default, the script searches both a user's contributions (i.e. edits) and log activity (ex. avatar uploads and page deletions) and uses the most recent of the two timestamps. This behavior can be changed by setting  and   to   to ignore edits and log activity respectively. In the event that both are disabled, the script will simply exit without attempting to retrieve any data.

Limitations/Additional Notes

 * 1) When specifying the username:
 * 2) *Underscores and spaces are interchangeable
 * 3) *Characters are interchangeable with their HTML character entities
 * 4) *The first character is case-insensitive
 * 5) If a user renames their account, a search based on the previous username will show as having no activity.
 * 6) Desired improvements:
 * 7) *Better timestamp format control
 * 8) *More language support for the "no activity" message