Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-12 21:03:09

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

asv_tracker

asv_tracker is a plugin to capture who is creating and updating content on your TXP install. It creates a new table and will store the user, date/time, and action they performed. Currently it only tracks articles, images, and files. I’ll be adding more as I go along, but I could use some feedback.

asv_tracker

Offline

#2 2006-11-12 21:22:19

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: asv_tracker

Really nice. I got used to this kind of thing with Drupal, but with TXP it’s icing on the cake.

Offline

#3 2006-11-12 21:42:48

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: asv_tracker

Some things you may want to change or add:
  • use doSlash on variables before using them in an SQL query.
  • instead of datetime, you can probably use a timestamp column so you don’t have to set it to NOW() each time.
  • the ‘case’ statements have a lot of duplicate code. The only thing that is different each time is the $action. Might as well just use ‘case’ to set $action and do the SQL query afterwards. In fact, if you let all those functions return $action, you can do all the inserts in the asv_tracker function. All this makes your plugin a lot smaller, I think.
  • sort on ‘id DESC’ (newer dates on top)
  • collation utf8_general_ci (similar to what TXP uses) instead of latin1_general_ci
  • ‘table create’ is defined in two places. Perhaps better to move it in a separate function and call it where required.
  • automatic purging of actions older than, say, 1 month?
  • limit the max number of actions pulled from the database to 1000 (?) or paginate.
  • offer a ‘filter by $txpuser’ (pulldown select menu would be nice).
  • remove ‘The user attempted ‘ from the action strings. Having that in all lines has no extra value and just makes lines break faster.
  • instead of ‘event – $event/ step – $step’, I’d use ‘$event $step’ or perhaps even ‘$step $event’, because the terms ‘event’ and ‘step’ are nice for programmers but have less meaning to end-users.

Last edited by ruud (2006-11-12 22:19:59)

Offline

#4 2006-11-13 00:36:20

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: asv_tracker

Ok I’ve made some updates, most in line with ruud’s suggestions.

http://www.amitvaria.com/compile/asv_tracker.php

I would appreciate help in making sure that the plugin is secure and efficient. I decided to break things apart as well so now you have user, timestamp, event, action, id. I haven’t created a pull down yet, but there is sorting and filtering built-in to the table.

Offline

Board footer

Powered by FluxBB