How to prevent plugin from executing in admin section

Question:

I have a Joomla 1.5 project that requires the following

1) Code must run before routing i.e. in parameters we can setup an action identifier that we can intercept before it goes to the default Joomla routing engine. The component will not actually exist but we need to use this to redirect the visitor to a download page. Url would be www.mysite.com/?option=somevalue where somevalue is defined as a parameter

2) The plugin is only for visitors to the site – it must not run as part of the administrator interface – this is because we are logging information to a database and we only want to do this when a visitor hits the site – not when the administrator is doing admin work.

Everything is working mostly – I have a check in the plugin constructor for userid == 0 and only execute if it is 0. However, when you logout from the admin console this results in userid being set to 0 so the plugin runs.

I have setup the plugin as a system plugin – primarily because of the constraint in 1 above but I am still running into issues outlined in 2 where admin logouts result in a write to the db.

I can check SERVER vars for the existence of the word administrator in the script path.

What I need to know is

a) Is there a better way of doing this
b) Is checking for the administrator text in the path the only way of preventing the plugin executing in the admin section?

Solution:

Hello Why don’t you use an exclusion in your plugin  with a regex matching administrator/  directory.

If your url starts with www.mysite.com/administrator -> don’t log visitor hit

I hope it helps.

Luis C. Fernandes

Tags: ·
digg delicious stumbleupon technorati Google live facebook Sphinn Mixx newsvine reddit yahoomyweb
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...